Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Decode ¶
func Decode(rn *yaml.RNode, fcd *CreateSetters) error
* Decode decodes the input yaml node into CreatSetters struct places the setter either in ScalarSetters or ArraySetters sorts the ScalarSetters using CompareSetters
e.g.for input ScalarSetters
[[name: image, value: nginx], [name: ubuntu, value: nginx-abc]]
for scalar node:
spec: nginx-development
Sorts the ScalarSetters to avoid following case of substrings
spec: nginx-abc-development # kpt-set: ${image}-abc-development
ScalarSetters array is transformed to
[[name: ubuntu, value: nginx-abc], [name: image, value: nginx]]
Types ¶
type ArraySetter ¶
type ArraySetter struct { // Name is the name of the setter Name string // Values are the values of the field to which setter comment is added. Values []string }
ArraySetter stores name and values of the array setter
type CompareSetters ¶
type CompareSetters []ScalarSetter
CompareSetters is to sort the setter values
func (CompareSetters) Len ¶
func (a CompareSetters) Len() int
func (CompareSetters) Less ¶
func (a CompareSetters) Less(i, j int) bool
node with value of maximum length is placed first
func (CompareSetters) Swap ¶
func (a CompareSetters) Swap(i, j int)
type CreateSetters ¶
type CreateSetters struct { // ScalarSetters holds the user provided values for simple scalar setters ScalarSetters []ScalarSetter // ArraySetters holds the user provided values for array setters ArraySetters []ArraySetter // Results are the results of adding setter comments Results []*Result // contains filtered or unexported fields }
CreateSetters creates a comment for the resource fields which contain the same value as setter value
type Result ¶
type Result struct { // FilePath is the file path of the matching value FilePath string // FieldPath is field path of the matching value FieldPath string // Value is the value of the field to which setter comment is added. Value string // Comment is the line comment of the matching value Comment string }
Result holds result of create-setters operation
type ScalarSetter ¶
type ScalarSetter struct { // Name is the name of the setter Name string // Value is the value of the field to which setter comment is added. Value string }
ScalarSetter stores name and value of the map setter