refactor edit add patch command

This commit is contained in:
Donny Xia
2020-10-21 14:56:20 -07:00
parent 2a8edd2859
commit 41abeb85be
4 changed files with 245 additions and 37 deletions

View File

@@ -17,3 +17,12 @@ type Patch struct {
// Target points to the resources that the patch is applied to
Target *Selector `json:"target,omitempty" yaml:"target,omitempty"`
}
// Equals return true if p equals another.
func (p *Patch) Equals(another Patch) bool {
targetEqual := (p.Target == another.Target) ||
(p.Target != nil && another.Target != nil && *p.Target == *another.Target)
return p.Path == another.Path &&
p.Patch == another.Patch &&
targetEqual
}