Merge pull request #722 from Liujingfang1/removeDeprecates

remove patches and imageTags from kustomization.yaml
This commit is contained in:
Kubernetes Prow Robot
2019-01-25 14:41:06 -08:00
committed by GitHub
11 changed files with 24 additions and 344 deletions

View File

@@ -59,7 +59,6 @@ func determineFieldOrder() []string {
"Crds",
"CommonLabels",
"CommonAnnotations",
"Patches",
"PatchesStrategicMerge",
"PatchesJson6902",
"ConfigMapGenerator",
@@ -67,7 +66,6 @@ func determineFieldOrder() []string {
"GeneratorOptions",
"Vars",
"Images",
"ImageTags",
"Configurations",
}
@@ -158,12 +156,12 @@ func (mf *kustomizationFile) Read() (*types.Kustomization, error) {
if err != nil {
return nil, err
}
data = types.DealWithDeprecatedFields(data)
var k types.Kustomization
err = yaml.Unmarshal(data, &k)
if err != nil {
return nil, err
}
k.DealWithDeprecatedFields()
msgs := k.DealWithMissingFields()
if len(msgs) > 0 {
log.Printf(strings.Join(msgs, "\n"))

View File

@@ -45,7 +45,6 @@ func TestFieldOrder(t *testing.T) {
"GeneratorOptions",
"Vars",
"Images",
"ImageTags",
"Configurations",
}
actual := determineFieldOrder()
@@ -85,52 +84,6 @@ func TestWriteAndRead(t *testing.T) {
}
}
// Deprecated fields should not survive being read.
func TestDeprecationOfPatches(t *testing.T) {
hasDeprecatedFields := []byte(`
namePrefix: acme
nameSuffix: emca
patches:
- alice
patchesStrategicMerge:
- bob
`)
fSys := fs.MakeFakeFS()
fSys.WriteTestKustomizationWith(hasDeprecatedFields)
mf, err := NewKustomizationFile(fSys)
if err != nil {
t.Fatalf("Unexpected Error: %v", err)
}
k, err := mf.Read()
if err != nil {
t.Fatalf("Couldn't read kustomization file: %v\n", err)
}
if k.NamePrefix != "acme" {
t.Fatalf("Unexpected name prefix")
}
if k.NameSuffix != "emca" {
t.Fatalf("Unexpected name suffix")
}
if len(k.Patches) > 0 {
t.Fatalf("Expected nothing in Patches.")
}
if len(k.PatchesStrategicMerge) != 2 {
t.Fatalf(
"Expected len(k.PatchesStrategicMerge) == 2, got %d",
len(k.PatchesStrategicMerge))
}
m := make(map[string]bool)
for _, v := range k.PatchesStrategicMerge {
m[string(v)] = true
}
if _, f := m["alice"]; !f {
t.Fatalf("Expected alice in PatchesStrategicMerge")
}
if _, f := m["bob"]; !f {
t.Fatalf("Expected bob in PatchesStrategicMerge")
}
}
func TestNewNotExist(t *testing.T) {
fakeFS := fs.MakeFakeFS()
_, err := NewKustomizationFile(fakeFS)