kyamls

package
v3.0.13 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2020 License: Apache-2.0 Imports: 8 Imported by: 34

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

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 GetLabels

func GetLabels(node *yaml.RNode, path string) (map[string]string, error)

GetLabels returns the labels for the given file

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 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
	Selector    map[string]string
}

Filter for filtering

func (*Filter) AddFlags

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

AddFlags add CLI flags for specifying 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