Skip to content

Commit e0ec802

Browse files
committed
Update TransformerConfig.Merge function to handle nil
1 parent af1e1e6 commit e0ec802

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

pkg/transformers/config/transformerconfig.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ func (t *TransformerConfig) AddNamereferenceFieldSpec(nbrs NameBackReferences) {
6464

6565
// Merge merges two TransformerConfigs objects into a new TransformerConfig object
6666
func (t *TransformerConfig) Merge(input *TransformerConfig) *TransformerConfig {
67+
if input == nil {
68+
return t
69+
}
6770
merged := &TransformerConfig{}
6871
merged.NamePrefix = append(t.NamePrefix, input.NamePrefix...)
6972
merged.NameSpace = append(t.NameSpace, input.NameSpace...)

pkg/transformers/config/transformerconfig_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,9 @@ func TestMerge(t *testing.T) {
141141
if !reflect.DeepEqual(actual, expected) {
142142
t.Fatalf("expected: %v\n but got: %v\n", expected, actual)
143143
}
144+
145+
actual = cfga.Merge(nil)
146+
if !reflect.DeepEqual(actual, cfga) {
147+
t.Fatalf("expected: %v\n but got: %v\n", cfga, actual)
148+
}
144149
}

0 commit comments

Comments
 (0)