mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-14 10:30:59 +00:00
Added test to ensure that individusal files cannot be added to the components list.
This commit is contained in:
@@ -359,18 +359,18 @@ resources:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestResourcesCannotBeAddedToComponents(t *testing.T) {
|
func TestKustomizationsCannotBeAddedToComponents(t *testing.T) {
|
||||||
th := kusttest_test.MakeHarness(t)
|
th := kusttest_test.MakeHarness(t)
|
||||||
writeComponentBase(th)
|
writeComponentBase(th)
|
||||||
writeComponentPatch(th)
|
writeComponentPatch(th)
|
||||||
th.WriteF("/app/resincust/kustomization.yaml", `
|
th.WriteF("/app/kustincomponents/kustomization.yaml", `
|
||||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
kind: Kustomization
|
kind: Kustomization
|
||||||
components:
|
components:
|
||||||
- ../base
|
- ../base
|
||||||
- ../patch
|
- ../patch
|
||||||
`)
|
`)
|
||||||
err := th.RunWithErr("/app/resincust", th.MakeDefaultOptions())
|
err := th.RunWithErr("/app/kustincomponents", th.MakeDefaultOptions())
|
||||||
if !strings.Contains(
|
if !strings.Contains(
|
||||||
err.Error(),
|
err.Error(),
|
||||||
"accumulating components: accumulateDirectory: \"expected kind 'Component' for path '/app/base' but got 'Kustomization'") {
|
"accumulating components: accumulateDirectory: \"expected kind 'Component' for path '/app/base' but got 'Kustomization'") {
|
||||||
@@ -378,6 +378,34 @@ components:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestFilesCannotBeAddedToComponentsList(t *testing.T) {
|
||||||
|
th := kusttest_test.MakeHarness(t)
|
||||||
|
writeComponentBase(th)
|
||||||
|
|
||||||
|
th.WriteF("/app/filesincomponents/stub.yaml", `
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: stub
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
`)
|
||||||
|
|
||||||
|
th.WriteF("/app/filesincomponents/kustomization.yaml", `
|
||||||
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
|
kind: Kustomization
|
||||||
|
components:
|
||||||
|
- stub.yaml
|
||||||
|
- ../patch
|
||||||
|
`)
|
||||||
|
err := th.RunWithErr("/app/filesincomponents", th.MakeDefaultOptions())
|
||||||
|
if !strings.Contains(
|
||||||
|
err.Error(),
|
||||||
|
"'/app/filesincomponents/stub.yaml' must be a directory to be a root") {
|
||||||
|
t.Fatalf("unexpected error: %s", err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func TestMissingOptionalComponentApiVersion(t *testing.T) {
|
func TestMissingOptionalComponentApiVersion(t *testing.T) {
|
||||||
th := kusttest_test.MakeHarness(t)
|
th := kusttest_test.MakeHarness(t)
|
||||||
writeComponentBase(th)
|
writeComponentBase(th)
|
||||||
|
|||||||
Reference in New Issue
Block a user