Break the dep between fs and pgmconfig.

This commit is contained in:
Jeffrey Regan
2019-10-02 12:01:45 -07:00
parent 5372fc6f6c
commit 2d58f8b81c
46 changed files with 600 additions and 419 deletions

View File

@@ -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
}