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:
Adoram Shoval
2025-05-23 14:28:43 -04:00
parent 2859474e3c
commit 9043c223d4
8 changed files with 93 additions and 143 deletions

View File

@@ -25,10 +25,10 @@ type plugin 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"`
}
var KustomizePlugin plugin //nolint:gochecknoglobals
@@ -73,10 +73,14 @@ func (p *plugin) 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()
}
}