mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-07-17 17:52:12 +00:00
mv mutiplepath_test, nullvalues_test to api/krusty/, Provide another high level example.
This commit is contained in:
@@ -1,16 +1,14 @@
|
|||||||
// Copyright 2019 The Kubernetes Authors.
|
// Copyright 2019 The Kubernetes Authors.
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
package target_test
|
package krusty_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
kusttest_test "sigs.k8s.io/kustomize/api/testutils/kusttest"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func makeCommonFileForMultiplePatchTest(th *kusttest_test.KustTestHarness) {
|
func makeCommonFileForMultiplePatchTest(th testingHarness) {
|
||||||
th.WriteK("/app/base", `
|
th.WriteK("/app/base", `
|
||||||
apiVersion: kustomize.config.k8s.io/v1beta1
|
apiVersion: kustomize.config.k8s.io/v1beta1
|
||||||
kind: Kustomization
|
kind: Kustomization
|
||||||
@@ -89,7 +87,7 @@ configMapGenerator:
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestMultiplePatchesNoConflict(t *testing.T) {
|
func TestMultiplePatchesNoConflict(t *testing.T) {
|
||||||
th := kusttest_test.NewKustTestHarness(t, "/app/overlay/staging")
|
th := makeTestHarness(t)
|
||||||
makeCommonFileForMultiplePatchTest(th)
|
makeCommonFileForMultiplePatchTest(th)
|
||||||
th.WriteF("/app/overlay/staging/deployment-patch1.yaml", `
|
th.WriteF("/app/overlay/staging/deployment-patch1.yaml", `
|
||||||
apiVersion: apps/v1beta2
|
apiVersion: apps/v1beta2
|
||||||
@@ -130,10 +128,7 @@ spec:
|
|||||||
volumes:
|
volumes:
|
||||||
- name: nginx-persistent-storage
|
- name: nginx-persistent-storage
|
||||||
`)
|
`)
|
||||||
m, err := th.MakeKustTarget().MakeCustomizedResMap()
|
m := th.Run("/app/overlay/staging", th.MakeDefaultOptions())
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("Err: %v", err)
|
|
||||||
}
|
|
||||||
th.AssertActualEqualsExpected(m, `
|
th.AssertActualEqualsExpected(m, `
|
||||||
apiVersion: apps/v1beta2
|
apiVersion: apps/v1beta2
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
@@ -233,7 +228,7 @@ metadata:
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestMultiplePatchesWithConflict(t *testing.T) {
|
func TestMultiplePatchesWithConflict(t *testing.T) {
|
||||||
th := kusttest_test.NewKustTestHarness(t, "/app/overlay/staging")
|
th := makeTestHarness(t)
|
||||||
makeCommonFileForMultiplePatchTest(th)
|
makeCommonFileForMultiplePatchTest(th)
|
||||||
th.WriteF("/app/overlay/staging/deployment-patch1.yaml", `
|
th.WriteF("/app/overlay/staging/deployment-patch1.yaml", `
|
||||||
apiVersion: apps/v1beta2
|
apiVersion: apps/v1beta2
|
||||||
@@ -271,7 +266,7 @@ spec:
|
|||||||
- name: ENABLE_FEATURE_FOO
|
- name: ENABLE_FEATURE_FOO
|
||||||
value: FALSE
|
value: FALSE
|
||||||
`)
|
`)
|
||||||
_, err := th.MakeKustTarget().MakeCustomizedResMap()
|
err := th.RunWithErr("/app/overlay/staging", th.MakeDefaultOptions())
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("expected conflict")
|
t.Fatalf("expected conflict")
|
||||||
}
|
}
|
||||||
@@ -325,15 +320,12 @@ spec:
|
|||||||
}
|
}
|
||||||
for _, c := range cases {
|
for _, c := range cases {
|
||||||
t.Run(c.name, func(t *testing.T) {
|
t.Run(c.name, func(t *testing.T) {
|
||||||
th := kusttest_test.NewKustTestHarness(t, "/app/overlay/staging")
|
th := makeTestHarness(t)
|
||||||
|
|
||||||
makeCommonFileForMultiplePatchTest(th)
|
makeCommonFileForMultiplePatchTest(th)
|
||||||
th.WriteF("/app/overlay/staging/deployment-patch1.yaml", c.patch1)
|
th.WriteF("/app/overlay/staging/deployment-patch1.yaml", c.patch1)
|
||||||
th.WriteF("/app/overlay/staging/deployment-patch2.yaml", c.patch2)
|
th.WriteF("/app/overlay/staging/deployment-patch2.yaml", c.patch2)
|
||||||
m, err := th.MakeKustTarget().MakeCustomizedResMap()
|
m := th.Run("/app/overlay/staging", th.MakeDefaultOptions())
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("Err: %v", err)
|
|
||||||
}
|
|
||||||
th.AssertActualEqualsExpected(m, `apiVersion: apps/v1beta2
|
th.AssertActualEqualsExpected(m, `apiVersion: apps/v1beta2
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
metadata:
|
metadata:
|
||||||
@@ -426,7 +418,7 @@ metadata:
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestMultiplePatchesBothWithPatchDeleteDirective(t *testing.T) {
|
func TestMultiplePatchesBothWithPatchDeleteDirective(t *testing.T) {
|
||||||
th := kusttest_test.NewKustTestHarness(t, "/app/overlay/staging")
|
th := makeTestHarness(t)
|
||||||
makeCommonFileForMultiplePatchTest(th)
|
makeCommonFileForMultiplePatchTest(th)
|
||||||
th.WriteF("/app/overlay/staging/deployment-patch1.yaml", `
|
th.WriteF("/app/overlay/staging/deployment-patch1.yaml", `
|
||||||
apiVersion: apps/v1beta2
|
apiVersion: apps/v1beta2
|
||||||
@@ -452,7 +444,7 @@ spec:
|
|||||||
- $patch: delete
|
- $patch: delete
|
||||||
name: nginx
|
name: nginx
|
||||||
`)
|
`)
|
||||||
_, err := th.MakeKustTarget().MakeCustomizedResMap()
|
err := th.RunWithErr("/app/overlay/staging", th.MakeDefaultOptions())
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("Expected error")
|
t.Fatalf("Expected error")
|
||||||
}
|
}
|
||||||
@@ -1,16 +1,14 @@
|
|||||||
// Copyright 2019 The Kubernetes Authors.
|
// Copyright 2019 The Kubernetes Authors.
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
package target_test
|
package krusty_test
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
kusttest_test "sigs.k8s.io/kustomize/api/testutils/kusttest"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNullValues(t *testing.T) {
|
func TestNullValues(t *testing.T) {
|
||||||
th := kusttest_test.NewKustTestHarness(t, "/app")
|
th := makeTestHarness(t)
|
||||||
th.WriteF("/app/deployment.yaml", `
|
th.WriteF("/app/deployment.yaml", `
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
@@ -38,10 +36,7 @@ kind: Kustomization
|
|||||||
resources:
|
resources:
|
||||||
- deployment.yaml
|
- deployment.yaml
|
||||||
`)
|
`)
|
||||||
m, err := th.MakeKustTarget().MakeCustomizedResMap()
|
m := th.Run("/app", th.MakeDefaultOptions())
|
||||||
if err != nil {
|
|
||||||
t.Fatalf("Err: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
th.AssertActualEqualsExpected(m, `
|
th.AssertActualEqualsExpected(m, `
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
Reference in New Issue
Block a user