Files
kustomize/api/types/patch.go
Adoram Shoval 9043c223d4 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.
2025-08-08 07:34:20 -04:00

35 lines
1.1 KiB
Go

// Copyright 2019 The Kubernetes Authors.
// SPDX-License-Identifier: Apache-2.0
package types
// Patch represent either a Strategic Merge Patch or a JSON patch
// and its targets.
// The content of the patch can either be from a file
// or from an inline string.
type Patch struct {
// Path is a relative file path to the patch file.
Path string `json:"path,omitempty" yaml:"path,omitempty"`
// Patch is the content of a patch.
Patch string `json:"patch,omitempty" yaml:"patch,omitempty"`
// Target points to the resources that the patch is applied to
Target *Selector `json:"target,omitempty" yaml:"target,omitempty"`
// Options is a list of options for the patch
Options *PatchArgs `json:"options,omitempty" yaml:"options,omitempty"`
}
// Equals return true if p equals o.
func (p *Patch) Equals(o Patch) bool {
targetEqual := (p.Target == o.Target) ||
(p.Target != nil && o.Target != nil && *p.Target == *o.Target)
optionsEqual := (p.Options == o.Options) ||
(p.Options != nil && o.Options != nil && *p.Options == *o.Options)
return p.Path == o.Path &&
p.Patch == o.Patch &&
targetEqual &&
optionsEqual
}