mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-12 01:14:22 +00:00
configmap binarydata comments and small tweaks
the BinaryData map is nil until the generator finds a file with contents that needs injected into the BinaryData field of the configmap
This commit is contained in:
@@ -49,7 +49,6 @@ func (f *ConfigMapFactory) makeFreshConfigMap(
|
|||||||
cm.Name = args.Name
|
cm.Name = args.Name
|
||||||
cm.Namespace = args.Namespace
|
cm.Namespace = args.Namespace
|
||||||
cm.Data = map[string]string{}
|
cm.Data = map[string]string{}
|
||||||
cm.BinaryData = map[string][]byte{}
|
|
||||||
return cm
|
return cm
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,6 +143,8 @@ func addKvToConfigMap(configMap *v1.ConfigMap, keyName, data string) error {
|
|||||||
|
|
||||||
keyExistsErrorMsg := "cannot add key %s, another key by that name already exists: %v"
|
keyExistsErrorMsg := "cannot add key %s, another key by that name already exists: %v"
|
||||||
|
|
||||||
|
// If the configmap data contains byte sequences that are all in the UTF-8
|
||||||
|
// range, we will write it to .Data
|
||||||
if utf8.Valid([]byte(data)) {
|
if utf8.Valid([]byte(data)) {
|
||||||
if _, entryExists := configMap.Data[keyName]; entryExists {
|
if _, entryExists := configMap.Data[keyName]; entryExists {
|
||||||
return fmt.Errorf(keyExistsErrorMsg, keyName, configMap.Data)
|
return fmt.Errorf(keyExistsErrorMsg, keyName, configMap.Data)
|
||||||
@@ -152,7 +153,10 @@ func addKvToConfigMap(configMap *v1.ConfigMap, keyName, data string) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// binary data
|
// otherwise, it's BinaryData
|
||||||
|
if configMap.BinaryData == nil {
|
||||||
|
configMap.BinaryData = map[string][]byte{}
|
||||||
|
}
|
||||||
if _, entryExists := configMap.BinaryData[keyName]; entryExists {
|
if _, entryExists := configMap.BinaryData[keyName]; entryExists {
|
||||||
return fmt.Errorf(keyExistsErrorMsg, keyName, configMap.BinaryData)
|
return fmt.Errorf(keyExistsErrorMsg, keyName, configMap.BinaryData)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ Licensed under the Apache License, Version 2.0 (the "License");
|
|||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
You may obtain a copy of the License at
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
http://www.apache.org/licenses/LICENSE-2.0
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
Unless required by applicable law or agreed to in writing, software
|
Unless required by applicable law or agreed to in writing, software
|
||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
@@ -40,7 +40,6 @@ func makeEnvConfigMap(name string) *corev1.ConfigMap {
|
|||||||
"DB_USERNAME": "admin",
|
"DB_USERNAME": "admin",
|
||||||
"DB_PASSWORD": "somepw",
|
"DB_PASSWORD": "somepw",
|
||||||
},
|
},
|
||||||
BinaryData: map[string][]byte{},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -79,7 +78,6 @@ func makeLiteralConfigMap(name string) *corev1.ConfigMap {
|
|||||||
"c": "Hello World",
|
"c": "Hello World",
|
||||||
"d": "true",
|
"d": "true",
|
||||||
},
|
},
|
||||||
BinaryData: map[string][]byte{},
|
|
||||||
}
|
}
|
||||||
cm.SetLabels(map[string]string{"foo": "bar"})
|
cm.SetLabels(map[string]string{"foo": "bar"})
|
||||||
return cm
|
return cm
|
||||||
|
|||||||
Reference in New Issue
Block a user