mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-07-17 09:49:13 +00:00
Additional tests around reusing the same bases and components
This commit is contained in:
@@ -158,6 +158,8 @@ func (kt *KustTarget) AccumulateTarget() (
|
|||||||
return kt.accumulateTarget(accumulator.MakeEmptyAccumulator())
|
return kt.accumulateTarget(accumulator.MakeEmptyAccumulator())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ra should be empty when this KustTarget is a Kustomization, or the ra of the parent if this KustTarget is a Component
|
||||||
|
// (or empty if the Component does not have a parent).
|
||||||
func (kt *KustTarget) accumulateTarget(ra *accumulator.ResAccumulator) (
|
func (kt *KustTarget) accumulateTarget(ra *accumulator.ResAccumulator) (
|
||||||
resRa *accumulator.ResAccumulator, err error) {
|
resRa *accumulator.ResAccumulator, err error) {
|
||||||
ra, err = kt.accumulateResources(ra, kt.kustomization.Resources)
|
ra, err = kt.accumulateResources(ra, kt.kustomization.Resources)
|
||||||
@@ -324,10 +326,13 @@ func (kt *KustTarget) accumulateDirectory(
|
|||||||
}
|
}
|
||||||
|
|
||||||
var subRa *accumulator.ResAccumulator
|
var subRa *accumulator.ResAccumulator
|
||||||
if subKt.kustomization.Kind == types.ComponentKind {
|
if isComponent {
|
||||||
|
// Components don't create a new accumulator: the kustomization directives are added to the current accumulator
|
||||||
subRa, err = subKt.accumulateTarget(ra)
|
subRa, err = subKt.accumulateTarget(ra)
|
||||||
ra = accumulator.MakeEmptyAccumulator()
|
ra = accumulator.MakeEmptyAccumulator()
|
||||||
} else {
|
} else {
|
||||||
|
// Child Kustomizations create a new accumulator which resolves their kustomization directives, which will later
|
||||||
|
// be merged into the current accumulator.
|
||||||
subRa, err = subKt.AccumulateTarget()
|
subRa, err = subKt.AccumulateTarget()
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -463,7 +463,7 @@ configMapGenerator:
|
|||||||
err := th.RunWithErr("/app/prod", th.MakeDefaultOptions())
|
err := th.RunWithErr("/app/prod", th.MakeDefaultOptions())
|
||||||
if !strings.Contains(
|
if !strings.Contains(
|
||||||
err.Error(),
|
err.Error(),
|
||||||
"apiVersion should be kustomize.config.k8s.io/v1alpha1") {
|
"apiVersion for Component should be kustomize.config.k8s.io/v1alpha1") {
|
||||||
t.Fatalf("unexpected error: %s", err)
|
t.Fatalf("unexpected error: %s", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -158,7 +158,7 @@ func (k *Kustomization) EnforceFields() []string {
|
|||||||
requiredVersion = ComponentVersion
|
requiredVersion = ComponentVersion
|
||||||
}
|
}
|
||||||
if k.APIVersion != "" && k.APIVersion != requiredVersion {
|
if k.APIVersion != "" && k.APIVersion != requiredVersion {
|
||||||
errs = append(errs, "apiVersion should be "+requiredVersion)
|
errs = append(errs, "apiVersion for "+k.Kind+" should be "+requiredVersion)
|
||||||
}
|
}
|
||||||
return errs
|
return errs
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user