mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-13 10:00:56 +00:00
Merge pull request #95 from Liujingfang1/crdsupport
Add skeleton for CRD support
This commit is contained in:
@@ -312,3 +312,23 @@ func TestAnnotationsRun(t *testing.T) {
|
||||
t.Fatalf("actual doesn't match expected: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAddPathConfigs(t *testing.T) {
|
||||
aexpected := len(defaultAnnotationsPathConfigs) + 1
|
||||
lexpected := len(defaultLabelsPathConfigs) + 1
|
||||
pathConfigs := []PathConfig{
|
||||
{
|
||||
GroupVersionKind: &schema.GroupVersionKind{Group: "GroupA", Kind: "KindB"},
|
||||
Path: []string{"path", "to", "a", "field"},
|
||||
CreateIfNotPresent: true,
|
||||
},
|
||||
}
|
||||
AddLabelsPathConfigs(pathConfigs)
|
||||
AddAnnotationsPathConfigs(pathConfigs)
|
||||
if len(defaultAnnotationsPathConfigs) != aexpected {
|
||||
t.Fatalf("actual %v doesn't match expected: %v", len(defaultAnnotationsPathConfigs), aexpected)
|
||||
}
|
||||
if len(defaultLabelsPathConfigs) != lexpected {
|
||||
t.Fatalf("actual %v doesn't match expected: %v", len(defaultLabelsPathConfigs), lexpected)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,3 +162,13 @@ var defaultAnnotationsPathConfigs = []PathConfig{
|
||||
CreateIfNotPresent: true,
|
||||
},
|
||||
}
|
||||
|
||||
// AddLabelsPathConfigs adds extra path configs to the default one
|
||||
func AddLabelsPathConfigs(pathConfigs []PathConfig) {
|
||||
defaultLabelsPathConfigs = append(defaultLabelsPathConfigs, pathConfigs...)
|
||||
}
|
||||
|
||||
// AddAnnotationsPathConfigs adds extra path configs to the default one
|
||||
func AddAnnotationsPathConfigs(pathConfigs []PathConfig) {
|
||||
defaultAnnotationsPathConfigs = append(defaultAnnotationsPathConfigs, pathConfigs...)
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import (
|
||||
|
||||
"github.com/kubernetes-sigs/kustomize/pkg/resmap"
|
||||
"github.com/kubernetes-sigs/kustomize/pkg/resource"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
)
|
||||
|
||||
func TestNameReferenceRun(t *testing.T) {
|
||||
@@ -199,3 +200,29 @@ func TestNameReferenceRun(t *testing.T) {
|
||||
t.Fatalf("actual doesn't match expected: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAddNameReferencePathConfigs(t *testing.T) {
|
||||
expected := len(defaultNameReferencePathConfigs) + 1
|
||||
|
||||
pathConfigs := []referencePathConfig{
|
||||
{
|
||||
referencedGVK: schema.GroupVersionKind{
|
||||
Kind: "KindA",
|
||||
},
|
||||
pathConfigs: []PathConfig{
|
||||
{
|
||||
GroupVersionKind: &schema.GroupVersionKind{
|
||||
Kind: "KindB",
|
||||
},
|
||||
Path: []string{"path", "to", "a", "field"},
|
||||
CreateIfNotPresent: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
AddNameReferencePathConfigs(pathConfigs)
|
||||
if len(defaultNameReferencePathConfigs) != expected {
|
||||
t.Fatalf("actual %v doesn't match expected: %v", len(defaultAnnotationsPathConfigs), expected)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -733,3 +733,8 @@ var defaultNameReferencePathConfigs = []referencePathConfig{
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
// AddNameReferencePathConfigs adds extra reference path configs to the default one
|
||||
func AddNameReferencePathConfigs(r []referencePathConfig) {
|
||||
defaultNameReferencePathConfigs = append(defaultNameReferencePathConfigs, r...)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user