mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-13 01:50:55 +00:00
Reinstate configmap/secret generator env field.
This commit is contained in:
@@ -155,7 +155,6 @@ type Kustomization struct {
|
||||
// moving content of deprecated fields to newer
|
||||
// fields.
|
||||
func (k *Kustomization) FixKustomizationPostUnmarshalling() {
|
||||
|
||||
if k.Kind == "" {
|
||||
k.Kind = KustomizationKind
|
||||
}
|
||||
@@ -168,6 +167,20 @@ func (k *Kustomization) FixKustomizationPostUnmarshalling() {
|
||||
}
|
||||
k.Resources = append(k.Resources, k.Bases...)
|
||||
k.Bases = nil
|
||||
for i, g := range k.ConfigMapGenerator {
|
||||
if g.EnvSource != "" {
|
||||
k.ConfigMapGenerator[i].EnvSources =
|
||||
append(g.EnvSources, g.EnvSource)
|
||||
k.ConfigMapGenerator[i].EnvSource = ""
|
||||
}
|
||||
}
|
||||
for i, g := range k.SecretGenerator {
|
||||
if g.EnvSource != "" {
|
||||
k.SecretGenerator[i].EnvSources =
|
||||
append(g.EnvSources, g.EnvSource)
|
||||
k.SecretGenerator[i].EnvSource = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FixKustomizationPreMarshalling fixes things
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package types
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
@@ -15,6 +16,12 @@ func fixKustomizationPostUnmarshallingCheck(k, e *Kustomization) bool {
|
||||
func TestFixKustomizationPostUnmarshalling(t *testing.T) {
|
||||
var k Kustomization
|
||||
k.Bases = append(k.Bases, "foo")
|
||||
k.ConfigMapGenerator = []ConfigMapArgs{{GeneratorArgs{
|
||||
KvPairSources: KvPairSources{
|
||||
EnvSources: []string{"a", "b"},
|
||||
EnvSource: "c",
|
||||
},
|
||||
}}}
|
||||
k.FixKustomizationPostUnmarshalling()
|
||||
|
||||
expected := Kustomization{
|
||||
@@ -23,8 +30,15 @@ func TestFixKustomizationPostUnmarshalling(t *testing.T) {
|
||||
APIVersion: KustomizationVersion,
|
||||
},
|
||||
Resources: []string{"foo"},
|
||||
ConfigMapGenerator: []ConfigMapArgs{{GeneratorArgs{
|
||||
KvPairSources: KvPairSources{
|
||||
EnvSources: []string{"a", "b", "c"},
|
||||
},
|
||||
}}},
|
||||
}
|
||||
if !reflect.DeepEqual(k, expected) {
|
||||
t.Fatalf("unexpected output: %v", k)
|
||||
}
|
||||
|
||||
if !fixKustomizationPostUnmarshallingCheck(&k, &expected) {
|
||||
t.Fatalf("unexpected output: %v", k)
|
||||
}
|
||||
|
||||
@@ -28,4 +28,9 @@ type KvPairSources struct {
|
||||
// or npm ".env" file or a ".ini" file
|
||||
// (wikipedia.org/wiki/INI_file)
|
||||
EnvSources []string `json:"envs,omitempty" yaml:"envs,omitempty"`
|
||||
|
||||
// Older, singular form of EnvSources.
|
||||
// On edits (e.g. `kustomize fix`) this is merged into the plural form
|
||||
// for consistency with LiteralSources and FileSources.
|
||||
EnvSource string `json:"env,omitempty" yaml:"env,omitempty"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user