diff --git a/api/internal/plugins/builtinconfig/transformerconfig.go b/api/internal/plugins/builtinconfig/transformerconfig.go index ab847eb6ecf..634c0b50fb1 100644 --- a/api/internal/plugins/builtinconfig/transformerconfig.go +++ b/api/internal/plugins/builtinconfig/transformerconfig.go @@ -76,8 +76,23 @@ func MakeDefaultConfig() *TransformerConfig { // MakeTransformerConfig returns a merger of custom config, // if any, with default config. func MakeTransformerConfig( - ldr ifc.Loader, paths []string) (*TransformerConfig, error) { + ldr ifc.Loader, configurations []string) (*TransformerConfig, error) { t1 := MakeDefaultConfig() + if len(configurations) == 0 { + return t1, nil + } + var paths []string + for _, configuration := range configurations { + config, err := makeTransformerConfigFromBytes([]byte(configuration)) + if err != nil { + paths = append(paths, configuration) + continue + } + t1, err = t1.Merge(config) + if err != nil { + return nil, err + } + } if len(paths) == 0 { return t1, nil } diff --git a/api/krusty/customconfig_test.go b/api/krusty/customconfig_test.go index e563d64c2eb..b4ed2254956 100644 --- a/api/krusty/customconfig_test.go +++ b/api/krusty/customconfig_test.go @@ -335,3 +335,42 @@ spec: location: Arizona `) } + +func TestInlineConfig(t *testing.T) { + th := kusttest_test.MakeEnhancedHarness(t) + defer th.Reset() + + th.WriteF("/app/resource.yaml", ` +apiVersion: config/v1 +kind: MyKind +metadata: + name: testSvc +spec: + container: + image: crd-image +`) + th.WriteK("/app", ` +resources: +- resource.yaml +images: +- name: crd-image + newName: new-crd-image + newTag: new-v1-tag +configurations: +- |- + images: + - kind: MyKind + path: spec/container/image +`) + + m := th.Run("/app", th.MakeDefaultOptions()) + th.AssertActualEqualsExpected(m, ` +apiVersion: config/v1 +kind: MyKind +metadata: + name: testSvc +spec: + container: + image: new-crd-image:new-v1-tag +`) +}