Skip to content

Commit 6cb59e4

Browse files
nishytarttor
authored andcommitted
adding list values to configMap
1 parent ff25bcf commit 6cb59e4

File tree

7 files changed

+27
-11
lines changed

7 files changed

+27
-11
lines changed

examples/app/templates/daemonset.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ spec:
3232
- mountPath: /var/lib/docker/containers
3333
name: varlibdockercontainers
3434
readOnly: true
35-
imagePullSecrets: {{ .Values.imagePullSecrets | default list | toJson }}
3635
terminationGracePeriodSeconds: 30
3736
tolerations:
3837
- effect: NoSchedule

examples/app/templates/deployment.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@ spec:
8181
- containerPort: 8443
8282
name: https
8383
resources: {}
84-
imagePullSecrets: {{ .Values.imagePullSecrets | default list | toJson }}
8584
securityContext:
8685
runAsNonRoot: true
8786
terminationGracePeriodSeconds: 10

examples/app/templates/my-config-props.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ metadata:
77
data:
88
my.prop1: {{ .Values.myConfigProps.myProp1 | quote }}
99
my.prop2: {{ .Values.myConfigProps.myProp2 | quote }}
10-
my.prop3: {{ .Values.myConfigProps.myProp3 | quote }}
10+
my.prop3: {{ .Values.myConfigProps.myProp3 | quote }}
11+
my.services: {{ toYaml .Values.myConfigProps.myServices | nindent 4 }}

examples/app/templates/my-config.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ data:
1515
healthProbeBindAddress: {{ .Values.myConfig.myConfigYaml.health.healthProbeBindAddress
1616
| quote }}
1717
metrics:
18-
bindAddress: {{ .Values.myConfig.myConfigYaml.metrics.bindAddress | quote }}
18+
bindAddress: {{ .Values.myConfig.myConfigYaml.metrics.bindAddress | quote }}
19+
users: {{ toYaml .Values.myConfig.myConfigYaml.users | nindent 6 }}

examples/app/values.yaml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ fluentdElasticsearch:
99
requests:
1010
cpu: 100m
1111
memory: 200Mi
12-
imagePullSecrets: []
1312
kubernetesClusterDomain: cluster.local
1413
myConfig:
1514
dummyconfigmapkey: dummyconfigmapvalue
@@ -23,10 +22,18 @@ myConfig:
2322
healthProbeBindAddress: :8081
2423
metrics:
2524
bindAddress: 127.0.0.1:8080
25+
users:
26+
- default
27+
- guest
28+
- temp
2629
myConfigProps:
2730
myProp1: "1"
2831
myProp2: val 1
2932
myProp3: "true"
33+
myServices:
34+
- docker
35+
- helm
36+
- k8s
3037
mySecretCa:
3138
caCrt: ""
3239
mySecretVars:

pkg/processor/configmap/configmap.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func (d configMap) Process(appMeta helmify.AppMetadata, obj *unstructured.Unstru
6868

6969
name := appMeta.TrimName(obj.GetName())
7070
var values helmify.Values
71-
if field, exists, _ := unstructured.NestedStringMap(obj.Object, "data"); exists {
71+
if field, exists, _ := unstructured.NestedMap(obj.Object, "data"); exists {
7272
field, values = parseMapData(field, name)
7373
data, err = yamlformat.Marshal(map[string]interface{}{"data": field}, 0)
7474
if err != nil {
@@ -89,7 +89,7 @@ func (d configMap) Process(appMeta helmify.AppMetadata, obj *unstructured.Unstru
8989
}, nil
9090
}
9191

92-
func parseMapData(data map[string]string, configName string) (map[string]string, helmify.Values) {
92+
func parseMapData(data map[string]interface{}, configName string) (map[string]interface{}, helmify.Values) {
9393
values := helmify.Values{}
9494
for key, value := range data {
9595
valuesNamePath := []string{configName, key}
@@ -121,9 +121,9 @@ func parseMapData(data map[string]string, configName string) (map[string]string,
121121
return data, values
122122
}
123123

124-
func parseYaml(value string, path []string, values helmify.Values) (string, error) {
124+
func parseYaml(value interface{}, path []string, values helmify.Values) (string, error) {
125125
config := map[string]interface{}{}
126-
err := yaml.Unmarshal([]byte(value), &config)
126+
err := yaml.Unmarshal([]byte(value.(string)), &config)
127127
if err != nil {
128128
return "", errors.Wrapf(err, "unable to unmarshal configmap %v", path)
129129
}
@@ -135,9 +135,10 @@ func parseYaml(value string, path []string, values helmify.Values) (string, erro
135135
return string(confBytes), nil
136136
}
137137

138-
func parseProperties(properties string, path []string, values helmify.Values) (string, error) {
138+
// func parseProperties(properties string, path []string, values helmify.Values) (string, error) {
139+
func parseProperties(properties interface{}, path []string, values helmify.Values) (string, error) {
139140
var res strings.Builder
140-
for _, line := range strings.Split(strings.TrimSuffix(properties, "\n"), "\n") {
141+
for _, line := range strings.Split(strings.TrimSuffix(properties.(string), "\n"), "\n") {
141142
prop := strings.Split(line, "=")
142143
if len(prop) != 2 {
143144
return "", errors.Errorf("wrong property format in %v: %s", path, line)

test_data/sample-app.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,10 @@ data:
184184
healthProbeBindAddress: :8081
185185
metrics:
186186
bindAddress: 127.0.0.1:8080
187+
users:
188+
- default
189+
- guest
190+
- temp
187191
my_config.properties: |
188192
health.healthProbeBindAddress=8081
189193
metrics.bindAddress=127.0.0.1:8080
@@ -197,6 +201,10 @@ data:
197201
my.prop1: "1"
198202
my.prop2: "val 1"
199203
my.prop3: "true"
204+
my.services:
205+
- docker
206+
- helm
207+
- k8s
200208
---
201209
apiVersion: apps/v1
202210
kind: DaemonSet

0 commit comments

Comments
 (0)