patchKey support x.y (#1916)

This commit is contained in:
Jian.Li
2021-07-14 17:03:50 +08:00
committed by GitHub
parent e91deaa4cc
commit fcecd0cc8d
2 changed files with 63 additions and 2 deletions
+2 -2
View File
@@ -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
}
+61
View File
@@ -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 {