Debian Codegraph @

cmd/config/docs/commands/create-setter.md

raw symbols SCIP
1 ## create-setter
2
3 [Alpha] Create a custom setter for a Resource field
4
5 ### Synopsis
6
7 Create a custom setter for a Resource field by inlining OpenAPI as comments.
8
9 DIR
10
11 A directory containing Resource configuration.
12
13 NAME
14
15 The name of the setter to create.
16
17 VALUE
18
19 The current value of the field, or a substring within the field.
20
21 ### Creating a Custom Setter
22
23 **Given the YAML:**
24
25 # resource.yaml
26 apiVersion: v1
27 kind: Service
28 metadata:
29 ...
30 spec:
31 ...
32 ports:
33 ...
34 - name: http
35 port: 8080
36 ...
37
38 **Create a new setter:**
39
40 # create a setter for ports
41 $ kustomize cfg set create DIR/ http-port 8080 --type "integer" --field "port"
42
43 Resources fields with a field name matching `--field` and field value matching `VALUE` will
44 have a line comment added marking this field as settable.
45
46 **Newly modified YAML:**
47
48 # resource.yaml
49 apiVersion: v1
50 kind: Service
51 metadata:
52 ...
53 spec:
54 ...
55 ports:
56 ...
57 - name: http
58 port: 8080 # {"type":"integer","x-kustomize":{"partialFieldSetters":[{"name":"http-port","value":"8080"}]}}
59 ...
60
61 Setters may also be defined directly by editing the yaml and adding the comment.
62
63 Users may not set the field value using the `set` command:
64
65 # change the http-port value to 8081
66 $ kustomize cfg set DIR/ http-port 8081
67
68 ### Using default values
69
70 The default values for a setter may be:
71
72 - valid field values (e.g. `8080` or `008080` for a port)
73 - invalid values that adhere to the schema (e.g. `0000` for a port)
74 - values that do not adhere to the schema (e.g. `[PORT]` for port)
75
76 A setter may be for a substring of a full field:
77
78 $ kustomize cfg set create DIR/ image-tag v1.0.01 --type "string" --field "image"
79
80 image: gcr.io/example/app:v1.0.1 # # {"type":"string","x-kustomize":{"partialFieldSetters":[{"name":"image-tag","value":"v1.0.1"}]}}
81
82 A single field value may have multiple setters applied to it for different parts of the field.
83
84 ### Examples
85
86 # create a setter for port fields matching "8080"
87 kustomize cfg create-setter DIR/ port 8080 --type "integer" --field port \
88 --description "default port used by the app"
89
90 # create a setter for a substring of a field rather than the full field -- e.g. only the
91 # image tag, not the full image
92 kustomize cfg create-setter DIR/ image-tag v1.0.1 --type "string" \
93 --field image --description "current stable release"