mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-10 08:20:59 +00:00
Add integration test for glob support
This commit is contained in:
@@ -6,5 +6,4 @@ commonLabels:
|
||||
commonAnnotations:
|
||||
note: This is a test annotation
|
||||
resources:
|
||||
- deployment.yaml
|
||||
- service.yaml
|
||||
- resources/*.yaml
|
||||
|
||||
@@ -2,8 +2,7 @@ namePrefix: staging-
|
||||
commonLabels:
|
||||
env: staging
|
||||
patches:
|
||||
- deployment-patch1.yaml
|
||||
- deployment-patch2.yaml
|
||||
- patches/deployment-patch*.yaml
|
||||
bases:
|
||||
- ../package/
|
||||
configMapGenerator:
|
||||
|
||||
@@ -18,6 +18,7 @@ package crds
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"sort"
|
||||
"testing"
|
||||
|
||||
"github.com/kubernetes-sigs/kustomize/pkg/internal/loadertest"
|
||||
@@ -150,30 +151,36 @@ func makeLoader(t *testing.T) loader.Loader {
|
||||
}
|
||||
|
||||
func TestRegisterCRD(t *testing.T) {
|
||||
refpathconfigs := []transformers.ReferencePathConfig{
|
||||
transformers.NewReferencePathConfig(
|
||||
schema.GroupVersionKind{Kind: "Bee", Version: "v1beta1"},
|
||||
[]transformers.PathConfig{
|
||||
{
|
||||
CreateIfNotPresent: false,
|
||||
GroupVersionKind: &schema.GroupVersionKind{Kind: "MyKind"},
|
||||
Path: []string{"spec", "beeRef", "name"},
|
||||
},
|
||||
},
|
||||
),
|
||||
transformers.NewReferencePathConfig(
|
||||
schema.GroupVersionKind{Kind: "Secret", Version: "v1"},
|
||||
[]transformers.PathConfig{
|
||||
{
|
||||
CreateIfNotPresent: false,
|
||||
GroupVersionKind: &schema.GroupVersionKind{Kind: "MyKind"},
|
||||
Path: []string{"spec", "secretRef", "name"},
|
||||
},
|
||||
},
|
||||
),
|
||||
}
|
||||
|
||||
sort.Slice(refpathconfigs, func(i, j int) bool {
|
||||
return refpathconfigs[i].GVK() < refpathconfigs[j].GVK()
|
||||
})
|
||||
|
||||
expected := []pathConfigs{
|
||||
{
|
||||
namereferencePathConfigs: []transformers.ReferencePathConfig{
|
||||
transformers.NewReferencePathConfig(
|
||||
schema.GroupVersionKind{Kind: "Bee", Version: "v1beta1"},
|
||||
[]transformers.PathConfig{
|
||||
{
|
||||
CreateIfNotPresent: false,
|
||||
GroupVersionKind: &schema.GroupVersionKind{Kind: "MyKind"},
|
||||
Path: []string{"spec", "beeRef", "name"},
|
||||
},
|
||||
},
|
||||
),
|
||||
transformers.NewReferencePathConfig(
|
||||
schema.GroupVersionKind{Kind: "Secret", Version: "v1"},
|
||||
[]transformers.PathConfig{
|
||||
{
|
||||
CreateIfNotPresent: false,
|
||||
GroupVersionKind: &schema.GroupVersionKind{Kind: "MyKind"},
|
||||
Path: []string{"spec", "secretRef", "name"},
|
||||
},
|
||||
},
|
||||
),
|
||||
},
|
||||
namereferencePathConfigs: refpathconfigs,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -181,6 +188,10 @@ func TestRegisterCRD(t *testing.T) {
|
||||
|
||||
pathconfig, _ := registerCRD(loader, "/testpath/crd.json")
|
||||
|
||||
sort.Slice(pathconfig[0].namereferencePathConfigs, func(i, j int) bool {
|
||||
return pathconfig[0].namereferencePathConfigs[i].GVK() < pathconfig[0].namereferencePathConfigs[j].GVK()
|
||||
})
|
||||
|
||||
if !reflect.DeepEqual(pathconfig, expected) {
|
||||
t.Fatalf("expected\n %v\n but got\n %v\n", expected, pathconfig)
|
||||
}
|
||||
|
||||
@@ -61,3 +61,8 @@ func NewReferencePathConfig(gvk schema.GroupVersionKind, pathconfigs []PathConfi
|
||||
pathConfigs: pathconfigs,
|
||||
}
|
||||
}
|
||||
|
||||
// GVK returns the Group version kind of a Reference PathConfig
|
||||
func (r ReferencePathConfig) GVK() string {
|
||||
return r.referencedGVK.String()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user