You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
### Disciplined merge the value in structured data with configMapGenerator and secretGenerator
141
141
142
-
This Proposal is add option for [configMapGenerator](https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/configmapgenerator/) and [secretGenerator](https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/secretgenerator/) to allow merge two string literals when the behavior option is setting to merge and string literals value is structured.\
143
-
This idea is add one parameter for `valueStructuredMergeFormat` to `option`. The `valueStructuredMergeFormat` option is used by select to structured data format like "json" or "yaml". And this function needs to work requires setting `behavior: merge`.\
144
-
This merge operation will be implemented for a part of [Overriding Base ConfigMap Values](https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/configmapgenerator/#overriding-base-configmap-values). It will execute to merge two string literal having same [key](https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#define-the-key-to-use-when-creating-a-configmap-from-a-file) name when merging two configMap.
145
-
It will implement in [GeneratorArgs](https://github.com/kubernetes-sigs/kustomize/blob/672c751715be7dd0b43b4a2fce956c84452e0db9/api/types/generatorargs.go#L7-L27) used from configMapGenerator and secretGenerator.
142
+
This Proposal is to add parameters for [configMapGenerator](https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/configmapgenerator/) and [secretGenerator](https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/secretgenerator/) to allow the merging of two string literals when the behavior option is set to merge and string literals value is structured.\
143
+
This idea is to add one parameter, `mergeValues` to [GeneratorArgs](https://github.com/kubernetes-sigs/kustomize/blob/672c751715be7dd0b43b4a2fce956c84452e0db9/api/types/generatorargs.go#L7-L27) used from configMapGenerator and secretGenerator.
144
+
The `mergeValues` option is a list that contains two parameters, `key` and `format`. One element corresponds to one string literal, `key` is used to select a string literal to merge, and `format` is used to designate a format for string literal which is JSON or YAML.\
145
+
This merge operation will be implemented for a part of [Overriding Base ConfigMap Values](https://kubectl.docs.kubernetes.io/references/kustomize/kustomization/configmapgenerator/#overriding-base-configmap-values). It will execute to merge two string literal having same [key](https://kubernetes.io/docs/tasks/configure-pod-container/configure-pod-configmap/#define-the-key-to-use-when-creating-a-configmap-from-a-file) name when merging two configMap or secret.\
146
146
147
147
#### Example
148
148
149
149
```yaml
150
150
configMapGenerator:
151
151
- name: demo-settings
152
152
behavior: merge # This function requires `behavior: merge`.
153
-
option:
154
-
valueStructuredMergeFormat: json # Setting structured data format.
153
+
mergeValues:
154
+
- key: config.json # Key with a target to merge.
155
+
format: json # Setting structured data format MUST be YAML/JSON.
155
156
literals:
156
157
- config.json: |-
157
158
{
@@ -282,7 +283,7 @@ and config they'll use.
282
283
-->
283
284
284
285
Many application needs to be set with json format file. And, That file is handled with configMap when the application is running on kubernetes.\
285
-
So, If kustomize configMapGenerator can overlay to one line inside a configMap data value, A json format file will be simple and easy to handle.
286
+
So, If kustomize configMapGenerator can merge for json inside a configMap data value, A json format file will be simple and easy to handle.
286
287
287
288
#### Source
288
289
```yaml
@@ -308,8 +309,9 @@ resources:
308
309
configMapGenerator:
309
310
- name: demo
310
311
behavior: merge
311
-
option:
312
-
valueMergeFormat: json
312
+
mergeValues:
313
+
- key: config.json # Key with a target to merge.
314
+
format: json # Setting structured data format MUST be YAML/JSON.
0 commit comments