kyamls

package
v3.7.0 Latest Latest
Warning

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

Go to latest
Published: May 1, 2024 License: Apache-2.0 Imports: 9 Imported by: 34

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Collect added in v3.0.49

func Collect(dir string, filter Filter) ([]yaml.RNode, error)

func CopyFiles added in v3.0.44

func CopyFiles(dir string, filter Filter, suffix string, labels map[string]string) error

func DeleteFiles added in v3.0.44

func DeleteFiles(dir string, deleteFn func(node *yaml.RNode, path string) (bool, error), filter Filter) error

func GetAPIVersion

func GetAPIVersion(node *yaml.RNode, path string) string

GetAPIVersion finds the API Version of the node at the given path

func GetKind

func GetKind(node *yaml.RNode, path string) string

GetKind finds the Kind of the node at the given path

func GetMap added in v3.4.2

func GetMap(node *yaml.RNode, filePath string, mapPath []string) (map[string]string, error)

GetMap return the content of mapPath in node as a map

func GetName

func GetName(node *yaml.RNode, path string) string

GetName returns the name from the metadata

func GetNamespace

func GetNamespace(node *yaml.RNode, path string) string

GetNamespace returns the namespace from the metadata

func GetStringField

func GetStringField(node *yaml.RNode, path string, fields ...string) string

GetStringField returns the given field from the node or returns a blank string if the field cannot be found

func IsClusterKind

func IsClusterKind(kind string) bool

IsClusterKind returns true if the kind is a cluster kind

func IsCustomResourceDefinition added in v3.0.16

func IsCustomResourceDefinition(kind string) bool

IsCustomResourceDefinition returns true if the kind is a customresourcedefinition

func JSONPath

func JSONPath(fields ...string) string

JSONPath returns the fields separated by dots

func ModifyFiles

func ModifyFiles(dir string, modifyFn func(node *yaml.RNode, path string) (bool, error), filter Filter) error

ModifyFiles recursively walks the given directory and modifies any suitable file

func SetStringValue

func SetStringValue(node *yaml.RNode, path string, value string, fields ...string) error

SetStringValue sets the string value at the given path

func TrimSpaceAndQuotes

func TrimSpaceAndQuotes(answer string) string

TrimSpaceAndQuotes trims any whitespace and quotes around a value

Types

type APIVersionKindsFilter

type APIVersionKindsFilter struct {
	Kinds       []KindFilter
	KindsIgnore []KindFilter
}

APIVersionKindsFilter a filter of kinds and/or API versions

type Filter

type Filter struct {
	Kinds          []string
	KindsIgnore    []string
	Names          []string
	SelectTarget   string
	Selector       map[string]string
	InvertSelector bool
}

Filter for filtering

func (*Filter) AddFlags

func (f *Filter) AddFlags(cmd *cobra.Command)

AddFlags add CLI flags for specifying a filter

func (*Filter) AddKindFlags added in v3.6.0

func (f *Filter) AddKindFlags(cmd *cobra.Command)

AddKindFlags add CLI flags for specifying the kind part of a filter

func (*Filter) AddSelectorFlags added in v3.6.0

func (f *Filter) AddSelectorFlags(cmd *cobra.Command)

AddSelectorFlags add CLI flags for specifying the selector part of a filter

func (*Filter) Parse

func (f *Filter) Parse() APIVersionKindsFilter

Parse parses the filter strings

func (*Filter) ToFilterFn

func (f *Filter) ToFilterFn() (func(node *yaml.RNode, path string) (bool, error), error)

ToFilterFn creates a filter function

type KindFilter

type KindFilter struct {
	APIVersion *string
	Kind       *string
}

KindFilter a filter on a kind and an optional APIVersion

func ParseKindFilter

func ParseKindFilter(text string) KindFilter

ParseKindFilter parses a kind filter

func (*KindFilter) Matches

func (f *KindFilter) Matches(node *yaml.RNode, path string) bool

Matches returns true if this node matches the filter

Jump to

Keyboard shortcuts

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