| 1 | ## set |
| 2 | |
| 3 | [Alpha] Set values on Resources fields values. |
| 4 | |
| 5 | ### Synopsis |
| 6 | |
| 7 | Set values on Resources fields. May set either the complete or partial field value. |
| 8 | |
| 9 | `set` identifies setters using field metadata published as OpenAPI extensions. |
| 10 | `set` parses both the Kubernetes OpenAPI, as well OpenAPI published inline in |
| 11 | the configuration as comments. |
| 12 | |
| 13 | `set` maybe be used to: |
| 14 | |
| 15 | - edit configuration programmatically from the cli |
| 16 | - create reusable bundles of configuration with custom setters |
| 17 | |
| 18 | DIR |
| 19 | |
| 20 | A directory containing Resource configuration. |
| 21 | |
| 22 | NAME |
| 23 | |
| 24 | Optional. The name of the setter to perform or display. |
| 25 | |
| 26 | VALUE |
| 27 | |
| 28 | Optional. The value to set on the field. |
| 29 | |
| 30 | |
| 31 | To print the possible setters for the Resources in a directory, run |
| 32 | `list-setters` on a directory -- e.g. `kustomize cfg list-setters DIR/`. |
| 33 | |
| 34 | #### Tips |
| 35 | |
| 36 | - A description of the value may be specified with `--description`. |
| 37 | - The last setter for the field's value may be defined with `--set-by`. |
| 38 | - Create custom setters on Resources, Kustomization.yaml's, patches, etc |
| 39 | |
| 40 | The description and setBy fields are left unmodified unless specified with flags. |
| 41 | |
| 42 | To create a custom setter for a field see: `kustomize help cfg create-setter` |
| 43 | |
| 44 | ### Examples |
| 45 | |
| 46 | Resource YAML: Name Prefix Setter |
| 47 | |
| 48 | # DIR/resources.yaml |
| 49 | ... |
| 50 | metadata: |
| 51 | name: PREFIX-app1 # {"type":"string","x-kustomize":{"setter":[{"name":"name-prefix","value":"PREFIX"}]}} |
| 52 | ... |
| 53 | --- |
| 54 | ... |
| 55 | metadata: |
| 56 | name: PREFIX-app2 # {"type":"string","x-kustomize":{"setter":[{"name":"name-prefix","value":"PREFIX"}]}} |
| 57 | ... |
| 58 | |
| 59 | List setters: Show the possible setters |
| 60 | |
| 61 | $ config list-setters DIR/ |
| 62 | NAME DESCRIPTION VALUE TYPE COUNT SETBY |
| 63 | name-prefix '' PREFIX string 2 |
| 64 | |
| 65 | Perform set: set a new value, owner and description |
| 66 | |
| 67 | $ kustomize cfg set DIR/ name-prefix "test" --description "test environment" --set-by "dev" |
| 68 | set 2 values |
| 69 | |
| 70 | List setters: Show the new values |
| 71 | |
| 72 | $ config list-setters DIR/ |
| 73 | NAME DESCRIPTION VALUE TYPE COUNT SETBY |
| 74 | name-prefix 'test environment' test string 2 dev |
| 75 | |
| 76 | New Resource YAML: |
| 77 | |
| 78 | # DIR/resources.yaml |
| 79 | ... |
| 80 | metadata: |
| 81 | name: test-app1 # {"description":"test environment","type":"string","x-kustomize":{"setBy":"dev","setter":[{"name":"name-prefix","value":"test"}]}} |
| 82 | ... |
| 83 | --- |
| 84 | ... |
| 85 | metadata: |
| 86 | name: test-app2 # {"description":"test environment","type":"string","x-kustomize":{"setBy":"dev","setter":[{"name":"name-prefix","value":"test"}]}} |
| 87 | ... |