mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-14 10:30:59 +00:00
Maintain resources in order loaded.
This commit is contained in:
@@ -22,21 +22,6 @@ import (
|
||||
"sigs.k8s.io/kustomize/pkg/kusttest"
|
||||
)
|
||||
|
||||
// TODO(monopole): Add a feature test example covering secret generation.
|
||||
|
||||
// WARNING: These tests use a fake file system, and any attempt to use a
|
||||
// feature that spawns shells will fail, because said shells expect a working
|
||||
// directory corresponding to a real directory on disk - see
|
||||
// these lines in secretfactory.go:
|
||||
// cmd := exec.CommandContext(ctx, commands[0], commands[1:]...)
|
||||
// cmd.Dir = f.wd
|
||||
// Worse, the fake directory might match a real directory on the your system,
|
||||
// making the failure less obvious (and maybe hurting something if your secret
|
||||
// generation technique writes data to disk). So no use of secret generation
|
||||
// in these particular tests.
|
||||
// To eventually fix this, we could write the data to a real filesystem, and
|
||||
// clean up after, or use some other trick compatible with exec.
|
||||
|
||||
func writeMediumBase(th *kusttest_test.KustTestHarness) {
|
||||
th.WriteK("/app/base", `
|
||||
namePrefix: baseprefix-
|
||||
|
||||
@@ -93,7 +93,7 @@ func TestResources(t *testing.T) {
|
||||
th.WriteF("/whatever/namespace.yaml", namespaceContent)
|
||||
th.WriteF("/whatever/jsonpatch.json", jsonpatchContent)
|
||||
|
||||
expected := resmap.ResMap{
|
||||
expected := resmap.FromMap(map[resid.ResId]*resource.Resource{
|
||||
resid.NewResIdWithPrefixSuffixNamespace(
|
||||
gvk.Gvk{Group: "apps", Version: "v1", Kind: "Deployment"},
|
||||
"dply1", "foo-", "-bar", "ns1"): th.FromMap(
|
||||
@@ -192,14 +192,13 @@ func TestResources(t *testing.T) {
|
||||
},
|
||||
},
|
||||
}),
|
||||
}
|
||||
})
|
||||
actual, err := th.MakeKustTarget().MakeCustomizedResMap()
|
||||
if err != nil {
|
||||
t.Fatalf("unexpected Resources error %v", err)
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(actual, expected) {
|
||||
err = expected.ErrorIfNotEqual(actual)
|
||||
if err = expected.ErrorIfNotEqual(actual); err != nil {
|
||||
t.Fatalf("unexpected inequality: %v", err)
|
||||
}
|
||||
}
|
||||
@@ -229,7 +228,7 @@ func TestResourceNotFound(t *testing.T) {
|
||||
}
|
||||
|
||||
func findSecret(m resmap.ResMap) *resource.Resource {
|
||||
for id, res := range m {
|
||||
for id, res := range m.AsMap() {
|
||||
if id.Gvk().Kind == "Secret" {
|
||||
return res
|
||||
}
|
||||
|
||||
@@ -720,7 +720,7 @@ spec:
|
||||
`)
|
||||
}
|
||||
|
||||
func TestVariableRefMounthPath(t *testing.T) {
|
||||
func TestVariableRefMountPath(t *testing.T) {
|
||||
th := kusttest_test.NewKustTestHarness(t, "/app/base")
|
||||
th.WriteK("/app/base", `
|
||||
resources:
|
||||
|
||||
Reference in New Issue
Block a user