Debian Codegraph @

api/types/patch.go

raw
1 // Copyright 2019 The Kubernetes Authors.
2 // SPDX-License-Identifier: Apache-2.0
3
4 package types
5
6 // Patch represent either a Strategic Merge Patch or a JSON patch
7 // and its targets.
8 // The content of the patch can either be from a file
9 // or from an inline string.
10 type Patch struct {
11 // Path is a relative file path to the patch file.
12 Path string `json:"path,omitempty" yaml:"path,omitempty"`
13
14 // Patch is the content of a patch.
15 Patch string `json:"patch,omitempty" yaml:"patch,omitempty"`
16
17 // Target points to the resources that the patch is applied to
18 Target *Selector `json:"target,omitempty" yaml:"target,omitempty"`
19
20 // Options is a list of options for the patch
21 Options *PatchArgs `json:"options,omitempty" yaml:"options,omitempty"`
22 }
23
24 // Equals return true if p equals o.
25 func (p *Patch) Equals(o Patch) bool {
26 targetEqual := (p.Target == o.Target) ||
27 (p.Target != nil && o.Target != nil && *p.Target == *o.Target)
28 optionsEqual := (p.Options == o.Options) ||
29 (p.Options != nil && o.Options != nil && *p.Options == *o.Options)
30 return p.Path == o.Path &&
31 p.Patch == o.Patch &&
32 targetEqual &&
33 optionsEqual
34 }