Check for config merge conflicts and duplication.

This commit is contained in:
jregan
2018-12-29 08:19:37 -08:00
parent 20b13a03e0
commit 8c994725cb
12 changed files with 325 additions and 69 deletions

View File

@@ -150,9 +150,6 @@ spec:
`)
}
// TODO: this test demonstrates #658
// The prefix "x-" is applied twice (search for x-x-sandiego), because the
// config from the base isn't properly merged with the config in the overlay.
func TestCustomConfigWithDefaultOverspecification(t *testing.T) {
th := NewKustTestHarness(t, "/app/base")
makeBaseReferencingCustomConfig(th)
@@ -184,21 +181,21 @@ kind: AnimalPark
metadata:
labels:
app: myApp
name: x-x-sandiego
name: x-sandiego
spec:
food:
- mimosa
- bambooshoots
giraffeRef:
name: x-x-april
name: x-april
gorillaRef:
name: x-x-koko
name: x-koko
---
kind: Giraffe
metadata:
labels:
app: myApp
name: x-x-april
name: x-april
spec:
diet: mimosa
location: NE
@@ -207,7 +204,7 @@ kind: Giraffe
metadata:
labels:
app: myApp
name: x-x-may
name: x-may
spec:
diet: acacia
location: SE
@@ -216,7 +213,7 @@ kind: Gorilla
metadata:
labels:
app: myApp
name: x-x-koko
name: x-koko
spec:
diet: bambooshoots
location: SW

View File

@@ -134,7 +134,7 @@ func mergeCustomConfigWithDefaults(
if err != nil {
return nil, err
}
return t1.Merge(t2), nil
return t1.Merge(t2)
}
// MakeCustomizedResMap creates a ResMap per kustomization instructions.
@@ -194,10 +194,13 @@ func (kt *KustTarget) loadCustomizedResMap() (resmap.ResMap, error) {
errs.Append(errors.Wrap(err, "loadResMapFromBasesAndResources"))
}
crdTc, err := config.NewFactory(kt.ldr).LoadCRDs(kt.kustomization.Crds)
kt.tConfig = kt.tConfig.Merge(crdTc)
if err != nil {
errs.Append(errors.Wrap(err, "LoadCRDs"))
}
kt.tConfig, err = kt.tConfig.Merge(crdTc)
if err != nil {
errs.Append(errors.Wrap(err, "merge CRDs"))
}
resMap, err := kt.generateConfigMapsAndSecrets(errs)
if err != nil {
errs.Append(errors.Wrap(err, "generateConfigMapsAndSecrets"))