Skip to content

Commit 2831689

Browse files
committed
update configMapGenerator section
1 parent 069c5fd commit 2831689

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

proposals/22-03-value-in-the-structured-data.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,19 +139,20 @@ Please check [Story 1](#Story-1).
139139

140140
### Disciplined merge the value in structured data with configMapGenerator and secretGenerator
141141

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.\
146146

147147
#### Example
148148

149149
```yaml
150150
configMapGenerator:
151151
- name: demo-settings
152152
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.
155156
literals:
156157
- config.json: |-
157158
{
@@ -282,7 +283,7 @@ and config they'll use.
282283
-->
283284
284285
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.
286287
287288
#### Source
288289
```yaml
@@ -308,8 +309,9 @@ resources:
308309
configMapGenerator:
309310
- name: demo
310311
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.
313315
literals:
314316
- config.json: |-
315317
{

0 commit comments

Comments
 (0)