diff --git a/pkg/cue/model/sets/operation.go b/pkg/cue/model/sets/operation.go index 8b7fe5068..e7b3093f4 100644 --- a/pkg/cue/model/sets/operation.go +++ b/pkg/cue/model/sets/operation.go @@ -49,7 +49,7 @@ func listMergeProcess(field *ast.Field, key string, baseList, patchList *ast.Lis if _, ok := elt.(*ast.Ellipsis); ok { continue } - nodev, err := lookUp(elt, key) + nodev, err := lookUp(elt, strings.Split(key, ".")...) if err != nil { return } @@ -67,7 +67,7 @@ func listMergeProcess(field *ast.Field, key string, baseList, patchList *ast.Lis continue } - nodev, err := lookUp(elt, key) + nodev, err := lookUp(elt, strings.Split(key, ".")...) if err != nil { return } diff --git a/pkg/cue/model/sets/operation_test.go b/pkg/cue/model/sets/operation_test.go index fd0feae57..ac6694544 100644 --- a/pkg/cue/model/sets/operation_test.go +++ b/pkg/cue/model/sets/operation_test.go @@ -181,6 +181,67 @@ containers: [{ }, ...] `, }, + { + base: `envFrom: [{ + secretRef: { + name: "nginx-rds" + }},...]`, + patch: ` +// +patchKey=secretRef.name +envFrom: [{ + secretRef: { + name: "nginx-redis" + }},...] +`, + result: `// +patchKey=secretRef.name +envFrom: [{ + secretRef: { + name: "nginx-rds" + } +}, { + secretRef: { + name: "nginx-redis" + } +}, ...] +`}, + { + base: ` + containers: [{ + name: "c1" + },{ + name: "c2" + envFrom: [{ + secretRef: { + name: "nginx-rds" + }},...] + },...]`, + patch: ` + // +patchKey=name + containers: [{ + name: "c2" + // +patchKey=secretRef.name + envFrom: [{ + secretRef: { + name: "nginx-redis" + }},...] + }]`, + result: `// +patchKey=name +containers: [{ + name: "c1" +}, { + name: "c2" + // +patchKey=secretRef.name + envFrom: [{ + secretRef: { + name: "nginx-rds" + } + }, { + secretRef: { + name: "nginx-redis" + } + }, ...] +}, ...] +`}, } for i, tcase := range testCase {