createsetters

package
v0.0.0-...-3df40d5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 30, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

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]]

func VisitElements

func VisitElements(rn *yaml.RNode, fn func(node *yaml.RNode, i int) error) error

VisitElements calls fn for each element in a SequenceNode. Returns an error for non-SequenceNodes

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

func (*CreateSetters) Filter

func (cs *CreateSetters) Filter(nodes []*yaml.RNode) ([]*yaml.RNode, error)

Filter implements CreatSetters as a yaml.Filter

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL