...

Source file src/sigs.k8s.io/kustomize/api/types/patch.go

Documentation: sigs.k8s.io/kustomize/api/types

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

View as plain text