Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion api/internal/plugins/builtinconfig/transformerconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,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
}
Expand Down
39 changes: 39 additions & 0 deletions api/krusty/customconfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,45 @@ spec:
`)
}

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
`)
}

func TestLabelTransformerConfig(t *testing.T) {
testCases := []struct {
name string
Expand Down