mirror of
https://github.com/kubernetes-sigs/kustomize.git
synced 2026-05-17 18:25:26 +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:
@@ -24,10 +24,10 @@ type PatchTransformerPlugin struct {
|
||||
patchText string
|
||||
// patchSource is patch source message
|
||||
patchSource string
|
||||
Path string `json:"path,omitempty" yaml:"path,omitempty"`
|
||||
Patch string `json:"patch,omitempty" yaml:"patch,omitempty"`
|
||||
Target *types.Selector `json:"target,omitempty" yaml:"target,omitempty"`
|
||||
Options map[string]bool `json:"options,omitempty" yaml:"options,omitempty"`
|
||||
Path string `json:"path,omitempty" yaml:"path,omitempty"`
|
||||
Patch string `json:"patch,omitempty" yaml:"patch,omitempty"`
|
||||
Target *types.Selector `json:"target,omitempty" yaml:"target,omitempty"`
|
||||
Options *types.PatchArgs `json:"options,omitempty" yaml:"options,omitempty"`
|
||||
}
|
||||
|
||||
func (p *PatchTransformerPlugin) Config(h *resmap.PluginHelpers, c []byte) error {
|
||||
@@ -70,10 +70,14 @@ func (p *PatchTransformerPlugin) Config(h *resmap.PluginHelpers, c []byte) error
|
||||
if errSM == nil {
|
||||
p.smPatches = patchesSM
|
||||
for _, loadedPatch := range p.smPatches {
|
||||
if p.Options["allowNameChange"] {
|
||||
if p.Options == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
if p.Options.AllowNameChange {
|
||||
loadedPatch.AllowNameChange()
|
||||
}
|
||||
if p.Options["allowKindChange"] {
|
||||
if p.Options.AllowKindChange {
|
||||
loadedPatch.AllowKindChange()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -250,10 +250,10 @@ var transformerConfigurators = map[builtinhelpers.BuiltinPluginType]func(
|
||||
return
|
||||
}
|
||||
var c struct {
|
||||
Path string `json:"path,omitempty" yaml:"path,omitempty"`
|
||||
Patch string `json:"patch,omitempty" yaml:"patch,omitempty"`
|
||||
Target *types.Selector `json:"target,omitempty" yaml:"target,omitempty"`
|
||||
Options map[string]bool `json:"options,omitempty" yaml:"options,omitempty"`
|
||||
Path string `json:"path,omitempty" yaml:"path,omitempty"`
|
||||
Patch string `json:"patch,omitempty" yaml:"patch,omitempty"`
|
||||
Target *types.Selector `json:"target,omitempty" yaml:"target,omitempty"`
|
||||
Options *types.PatchArgs `json:"options,omitempty" yaml:"options,omitempty"`
|
||||
}
|
||||
for _, pc := range kt.kustomization.Patches {
|
||||
c.Target = pc.Target
|
||||
|
||||
Reference in New Issue
Block a user