mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-06-12 01:14:22 +00:00
feat: add PatchArgs API type to populate patch options
This commit converts the Options section of a patch into an object instead of map. This allows better clarification of the available options.
This commit is contained in:
@@ -241,7 +241,7 @@ func constructTargets(file string, node *kyaml.RNode, fieldPaths []string,
|
||||
}
|
||||
|
||||
if patch, ok := patchTarget[file]; ok {
|
||||
if !patch.Options["allowNameChange"] || !patch.Options["allowKindChange"] {
|
||||
if patch.Options == nil || (!patch.Options.AllowNameChange || !patch.Options.AllowKindChange) {
|
||||
return writePatchTargets(patch, node, fieldPaths, options)
|
||||
}
|
||||
}
|
||||
@@ -299,11 +299,13 @@ func writePatchTargets(patch types.Patch, node *kyaml.RNode, fieldPaths []string
|
||||
if options[i].String() != "" {
|
||||
target.Options = options[i]
|
||||
}
|
||||
if patch.Options["allowNameChange"] {
|
||||
target.Select.ResId.Name = node.GetName()
|
||||
}
|
||||
if patch.Options["allowKindChange"] {
|
||||
target.Select.ResId.Kind = node.GetKind()
|
||||
if patch.Options != nil {
|
||||
if patch.Options.AllowNameChange {
|
||||
target.Select.ResId.Name = node.GetName()
|
||||
}
|
||||
if patch.Options.AllowKindChange {
|
||||
target.Select.ResId.Kind = node.GetKind()
|
||||
}
|
||||
}
|
||||
if node.GetNamespace() != "" {
|
||||
target.Select.ResId.Namespace = node.GetNamespace()
|
||||
|
||||
Reference in New Issue
Block a user