mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-14 10:30:59 +00:00
Break the dep between fs and pgmconfig.
This commit is contained in:
@@ -64,7 +64,7 @@ const metaNamespace = "metadata/namespace"
|
||||
// that don't exist in a namespace (the Namespace
|
||||
// object itself doesn't live in a namespace).
|
||||
func (p *NamespaceTransformerPlugin) applicableFieldSpecs(id resid.ResId) []config.FieldSpec {
|
||||
res := []config.FieldSpec{}
|
||||
var res []config.FieldSpec
|
||||
for _, fs := range p.FieldSpecs {
|
||||
if id.IsSelected(&fs.Gvk) && (fs.Path != metaNamespace || (fs.Path == metaNamespace && id.IsNamespaceableKind())) {
|
||||
res = append(res, fs)
|
||||
@@ -73,14 +73,14 @@ func (p *NamespaceTransformerPlugin) applicableFieldSpecs(id resid.ResId) []conf
|
||||
return res
|
||||
}
|
||||
|
||||
func (o *NamespaceTransformerPlugin) changeNamespace(
|
||||
func (p *NamespaceTransformerPlugin) changeNamespace(
|
||||
referrer *resource.Resource) func(in interface{}) (interface{}, error) {
|
||||
return func(in interface{}) (interface{}, error) {
|
||||
switch in.(type) {
|
||||
case string:
|
||||
// will happen when the metadata/namespace
|
||||
// value is replaced
|
||||
return o.Namespace, nil
|
||||
return p.Namespace, nil
|
||||
case []interface{}:
|
||||
l, _ := in.([]interface{})
|
||||
for idx, item := range l {
|
||||
@@ -102,7 +102,7 @@ func (o *NamespaceTransformerPlugin) changeNamespace(
|
||||
if name != "default" {
|
||||
continue
|
||||
}
|
||||
inMap["namespace"] = o.Namespace
|
||||
inMap["namespace"] = p.Namespace
|
||||
l[idx] = inMap
|
||||
default:
|
||||
// nothing to do for right now
|
||||
@@ -115,7 +115,7 @@ func (o *NamespaceTransformerPlugin) changeNamespace(
|
||||
// object
|
||||
inMap := in.(map[string]interface{})
|
||||
if len(inMap) == 0 {
|
||||
return o.Namespace, nil
|
||||
return p.Namespace, nil
|
||||
} else {
|
||||
return in, nil
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ func (p *ReplicaCountTransformerPlugin) Transform(m resmap.ResMap) error {
|
||||
for i, replicaSpec := range p.FieldSpecs {
|
||||
gvks[i] = replicaSpec.Gvk.String()
|
||||
}
|
||||
return fmt.Errorf("Resource with name %s does not match a config with the following GVK %v",
|
||||
return fmt.Errorf("resource with name %s does not match a config with the following GVK %v",
|
||||
p.Replica.Name, gvks)
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ const metaNamespace = "metadata/namespace"
|
||||
// that don't exist in a namespace (the Namespace
|
||||
// object itself doesn't live in a namespace).
|
||||
func (p *plugin) applicableFieldSpecs(id resid.ResId) []config.FieldSpec {
|
||||
res := []config.FieldSpec{}
|
||||
var res []config.FieldSpec
|
||||
for _, fs := range p.FieldSpecs {
|
||||
if id.IsSelected(&fs.Gvk) && (fs.Path != metaNamespace || (fs.Path == metaNamespace && id.IsNamespaceableKind())) {
|
||||
res = append(res, fs)
|
||||
@@ -79,14 +79,14 @@ func (p *plugin) applicableFieldSpecs(id resid.ResId) []config.FieldSpec {
|
||||
return res
|
||||
}
|
||||
|
||||
func (o *plugin) changeNamespace(
|
||||
func (p *plugin) changeNamespace(
|
||||
referrer *resource.Resource) func(in interface{}) (interface{}, error) {
|
||||
return func(in interface{}) (interface{}, error) {
|
||||
switch in.(type) {
|
||||
case string:
|
||||
// will happen when the metadata/namespace
|
||||
// value is replaced
|
||||
return o.Namespace, nil
|
||||
return p.Namespace, nil
|
||||
case []interface{}:
|
||||
l, _ := in.([]interface{})
|
||||
for idx, item := range l {
|
||||
@@ -108,7 +108,7 @@ func (o *plugin) changeNamespace(
|
||||
if name != "default" {
|
||||
continue
|
||||
}
|
||||
inMap["namespace"] = o.Namespace
|
||||
inMap["namespace"] = p.Namespace
|
||||
l[idx] = inMap
|
||||
default:
|
||||
// nothing to do for right now
|
||||
@@ -121,7 +121,7 @@ func (o *plugin) changeNamespace(
|
||||
// object
|
||||
inMap := in.(map[string]interface{})
|
||||
if len(inMap) == 0 {
|
||||
return o.Namespace, nil
|
||||
return p.Namespace, nil
|
||||
} else {
|
||||
return in, nil
|
||||
}
|
||||
|
||||
@@ -600,11 +600,6 @@ func addNamespace(namespace string, base string) string {
|
||||
return res
|
||||
}
|
||||
|
||||
// unExpectedError function handles unexpected error
|
||||
func unExpectedError(t *testing.T, name string, err error) {
|
||||
t.Fatalf("%q; - unexpected error %v", name, err)
|
||||
}
|
||||
|
||||
// compareExpectedError compares the expectedError and the actualError return by GetFieldValue
|
||||
func compareExpectedError(t *testing.T, name string, err error, errorMsg string) {
|
||||
if err == nil {
|
||||
@@ -854,7 +849,7 @@ metadata:
|
||||
name: notImportantHere
|
||||
paths:
|
||||
`
|
||||
for idx, _ := range patches {
|
||||
for idx := range patches {
|
||||
config = fmt.Sprintf("%s\n- ./patch%d.yaml", config, idx)
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ func (p *plugin) Transform(m resmap.ResMap) error {
|
||||
for i, replicaSpec := range p.FieldSpecs {
|
||||
gvks[i] = replicaSpec.Gvk.String()
|
||||
}
|
||||
return fmt.Errorf("Resource with name %s does not match a config with the following GVK %v",
|
||||
return fmt.Errorf("resource with name %s does not match a config with the following GVK %v",
|
||||
p.Replica.Name, gvks)
|
||||
}
|
||||
|
||||
|
||||
@@ -229,7 +229,7 @@ spec:
|
||||
t.Fatalf("No match should return an error")
|
||||
}
|
||||
if err.Error() !=
|
||||
"Resource with name service does not match a config with the following GVK [~G_~V_Deployment]" {
|
||||
"resource with name service does not match a config with the following GVK [~G_~V_Deployment]" {
|
||||
t.Fatalf("Unexpected error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user