mirror of
https://github.com/kubevela/kubevela.git
synced 2026-08-19 04:26:39 +00:00
patchKey support x.y (#1916)
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user