mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-09-15 12:18:57 +00:00
Renamed KustomizationPatch to Component
This commit is contained in:
@@ -294,7 +294,7 @@ func (kt *KustTarget) accumulateDirectory(
|
|||||||
}
|
}
|
||||||
|
|
||||||
var subRa *accumulator.ResAccumulator
|
var subRa *accumulator.ResAccumulator
|
||||||
if subKt.kustomization.Kind == types.KustomizationPatchKind {
|
if subKt.kustomization.Kind == types.ComponentKind {
|
||||||
subRa, err = subKt.accumulateTarget(ra)
|
subRa, err = subKt.accumulateTarget(ra)
|
||||||
ra = accumulator.MakeEmptyAccumulator()
|
ra = accumulator.MakeEmptyAccumulator()
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ import (
|
|||||||
kusttest_test "sigs.k8s.io/kustomize/api/testutils/kusttest"
|
kusttest_test "sigs.k8s.io/kustomize/api/testutils/kusttest"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Test kustomization.yaml files with kind: KustomizationPatch
|
// Test kustomization.yaml files with kind: Component
|
||||||
func writeKustomizationPatchBase(th kusttest_test.Harness) {
|
func writeComponentBase(th kusttest_test.Harness) {
|
||||||
th.WriteK("/app/base", `
|
th.WriteK("/app/base", `
|
||||||
resources:
|
resources:
|
||||||
- deploy.yaml
|
- deploy.yaml
|
||||||
@@ -30,10 +30,10 @@ spec:
|
|||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeKustomizationPatchPatch(th kusttest_test.Harness) {
|
func writeComponentPatch(th kusttest_test.Harness) {
|
||||||
th.WriteF("/app/patch/kustomization.yaml", `
|
th.WriteF("/app/patch/kustomization.yaml", `
|
||||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
kind: KustomizationPatch
|
kind: Component
|
||||||
namePrefix: patched-
|
namePrefix: patched-
|
||||||
replicas:
|
replicas:
|
||||||
- name: storefront
|
- name: storefront
|
||||||
@@ -57,7 +57,7 @@ spec:
|
|||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|
||||||
func writeKustomizationPatchProd(th kusttest_test.Harness) {
|
func writeComponentProd(th kusttest_test.Harness) {
|
||||||
th.WriteK("/app/prod", `
|
th.WriteK("/app/prod", `
|
||||||
resources:
|
resources:
|
||||||
- ../base
|
- ../base
|
||||||
@@ -74,13 +74,13 @@ spec:
|
|||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|
||||||
// KustomizationPatch are inserted into the resource hierarchy as the parent of those
|
// Components are inserted into the resource hierarchy as the parent of those
|
||||||
// resources that come before it in the resources list of the parent Kustomization.
|
// resources that come before it in the resources list of the parent Kustomization.
|
||||||
func TestBasicKustomizationPatch(t *testing.T) {
|
func TestBasicComponent(t *testing.T) {
|
||||||
th := kusttest_test.MakeHarness(t)
|
th := kusttest_test.MakeHarness(t)
|
||||||
writeKustomizationPatchBase(th)
|
writeComponentBase(th)
|
||||||
writeKustomizationPatchPatch(th)
|
writeComponentPatch(th)
|
||||||
writeKustomizationPatchProd(th)
|
writeComponentProd(th)
|
||||||
m := th.Run("/app/prod", th.MakeDefaultOptions())
|
m := th.Run("/app/prod", th.MakeDefaultOptions())
|
||||||
th.AssertActualEqualsExpected(m, `
|
th.AssertActualEqualsExpected(m, `
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
@@ -117,14 +117,14 @@ spec:
|
|||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestMultipleKustomizationPatches(t *testing.T) {
|
func TestMultipleComponentes(t *testing.T) {
|
||||||
th := kusttest_test.MakeHarness(t)
|
th := kusttest_test.MakeHarness(t)
|
||||||
writeKustomizationPatchBase(th)
|
writeComponentBase(th)
|
||||||
writeKustomizationPatchPatch(th)
|
writeComponentPatch(th)
|
||||||
writeKustomizationPatchProd(th)
|
writeComponentProd(th)
|
||||||
th.WriteF("/app/additionalpatch/kustomization.yaml", `
|
th.WriteF("/app/additionalpatch/kustomization.yaml", `
|
||||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
kind: KustomizationPatch
|
kind: Component
|
||||||
configMapGenerator:
|
configMapGenerator:
|
||||||
- name: my-configmap
|
- name: my-configmap
|
||||||
behavior: merge
|
behavior: merge
|
||||||
@@ -174,14 +174,14 @@ spec:
|
|||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNestedKustomizationPatches(t *testing.T) {
|
func TestNestedComponents(t *testing.T) {
|
||||||
th := kusttest_test.MakeHarness(t)
|
th := kusttest_test.MakeHarness(t)
|
||||||
writeKustomizationPatchBase(th)
|
writeComponentBase(th)
|
||||||
writeKustomizationPatchPatch(th)
|
writeComponentPatch(th)
|
||||||
writeKustomizationPatchProd(th)
|
writeComponentProd(th)
|
||||||
th.WriteF("/app/additionalpatch/kustomization.yaml", `
|
th.WriteF("/app/additionalpatch/kustomization.yaml", `
|
||||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
kind: KustomizationPatch
|
kind: Component
|
||||||
resources:
|
resources:
|
||||||
- ../patch
|
- ../patch
|
||||||
configMapGenerator:
|
configMapGenerator:
|
||||||
@@ -234,11 +234,11 @@ spec:
|
|||||||
|
|
||||||
// If a patch sets a name prefix on a base, then that base can also be separately included
|
// If a patch sets a name prefix on a base, then that base can also be separately included
|
||||||
// without being affected by the patch in another branch of the resource tree
|
// without being affected by the patch in another branch of the resource tree
|
||||||
func TestBasicKustomizationPatchWithRepeatedBase(t *testing.T) {
|
func TestBasicComponentWithRepeatedBase(t *testing.T) {
|
||||||
th := kusttest_test.MakeHarness(t)
|
th := kusttest_test.MakeHarness(t)
|
||||||
writeKustomizationPatchBase(th)
|
writeComponentBase(th)
|
||||||
writeKustomizationPatchPatch(th)
|
writeComponentPatch(th)
|
||||||
writeKustomizationPatchProd(th)
|
writeComponentProd(th)
|
||||||
th.WriteK("/app/repeated", `
|
th.WriteK("/app/repeated", `
|
||||||
resources:
|
resources:
|
||||||
- ../base
|
- ../base
|
||||||
@@ -295,13 +295,13 @@ spec:
|
|||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestApplyingKustomizationPatchDirectlySameAsKustomization(t *testing.T) {
|
func TestApplyingComponentDirectlySameAsKustomization(t *testing.T) {
|
||||||
th := kusttest_test.MakeHarness(t)
|
th := kusttest_test.MakeHarness(t)
|
||||||
writeKustomizationPatchBase(th)
|
writeComponentBase(th)
|
||||||
writeKustomizationPatchPatch(th)
|
writeComponentPatch(th)
|
||||||
th.WriteF("/app/solopatch/kustomization.yaml", `
|
th.WriteF("/app/solopatch/kustomization.yaml", `
|
||||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
kind: KustomizationPatch
|
kind: Component
|
||||||
resources:
|
resources:
|
||||||
- ../base
|
- ../base
|
||||||
configMapGenerator:
|
configMapGenerator:
|
||||||
@@ -4,10 +4,10 @@
|
|||||||
package types
|
package types
|
||||||
|
|
||||||
const (
|
const (
|
||||||
KustomizationVersion = "kustomize.config.k8s.io/v1beta1"
|
KustomizationVersion = "kustomize.config.k8s.io/v1beta1"
|
||||||
KustomizationKind = "Kustomization"
|
KustomizationKind = "Kustomization"
|
||||||
KustomizationPatchKind = "KustomizationPatch"
|
ComponentKind = "Component"
|
||||||
MetadataNamespacePath = "metadata/namespace"
|
MetadataNamespacePath = "metadata/namespace"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Kustomization holds the information needed to generate customized k8s api resources.
|
// Kustomization holds the information needed to generate customized k8s api resources.
|
||||||
@@ -144,8 +144,8 @@ func (k *Kustomization) EnforceFields() []string {
|
|||||||
if k.APIVersion != "" && k.APIVersion != KustomizationVersion {
|
if k.APIVersion != "" && k.APIVersion != KustomizationVersion {
|
||||||
errs = append(errs, "apiVersion should be "+KustomizationVersion)
|
errs = append(errs, "apiVersion should be "+KustomizationVersion)
|
||||||
}
|
}
|
||||||
if k.Kind != "" && k.Kind != KustomizationKind && k.Kind != KustomizationPatchKind {
|
if k.Kind != "" && k.Kind != KustomizationKind && k.Kind != ComponentKind {
|
||||||
errs = append(errs, "kind should be "+KustomizationKind+" or "+KustomizationPatchKind)
|
errs = append(errs, "kind should be "+KustomizationKind+" or "+ComponentKind)
|
||||||
}
|
}
|
||||||
return errs
|
return errs
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user