process

package
v0.26.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	MetadataPrefix   = "tanka.dev"
	LabelEnvironment = MetadataPrefix + "/environment"
)
View Source
const (
	// AnnotationNamespaced can be set on any resource to override the decision
	// whether 'metadata.namespace' is set by Tanka
	AnnotationNamespaced = MetadataPrefix + "/namespaced"
)

Variables

This section is empty.

Functions

func Extract

func Extract(raw interface{}) (map[string]manifest.Manifest, error)

Extract scans the raw Jsonnet evaluation result (JSON tree) for objects that look like Kubernetes objects and extracts those into a flat map, indexed by their path in the original JSON tree

func Filter

func Filter(list manifest.List, exprs Matchers) manifest.List

Filter returns all elements of the list that match at least one expression and are not ignored

func Label

func Label(list manifest.List, cfg v1alpha1.Environment) manifest.List

Label conditionally adds tanka.dev/** labels to each manifest in the List

func Namespace

func Namespace(list manifest.List, def string) manifest.List

Namespace injects the default namespace of the environment into each resources, that does not already define one. AnnotationNamespaced can be used to disable this per resource

func Process

func Process(cfg v1alpha1.Environment, exprs Matchers) (manifest.List, error)

Process converts the raw Jsonnet evaluation result (JSON tree) into a flat list of Kubernetes objects, also applying some transformations: - tanka.dev/** labels - filtering - best-effort sorting

func ResourceDefaults added in v0.12.0

func ResourceDefaults(list manifest.List, cfg v1alpha1.Environment) manifest.List

func Sort

func Sort(list manifest.List)

Sort orders manifests in a stable order, taking order-dependencies of these into consideration. This is best-effort based: - Use the static kindOrder list if possible - Sort alphabetically by kind otherwise - If kind equal, sort alphabetically by name

func Unwrap

func Unwrap(manifests map[string]manifest.Manifest) error

Unwrap returns all Kubernetes objects in the manifest. If m is not a List type, a one item List is returned

Types

type ErrBadExpr

type ErrBadExpr struct {
	// contains filtered or unexported fields
}

ErrBadExpr occurs when the regexp compiling fails

func (ErrBadExpr) Error

func (e ErrBadExpr) Error() string

type ErrorPrimitiveReached

type ErrorPrimitiveReached struct {
	// contains filtered or unexported fields
}

ErrorPrimitiveReached occurs when walkJSON reaches the end of nested dicts without finding a valid Kubernetes manifest

func (ErrorPrimitiveReached) Error

func (e ErrorPrimitiveReached) Error() string

func (ErrorPrimitiveReached) WithContainingObj added in v0.25.0

func (e ErrorPrimitiveReached) WithContainingObj(obj objx.Map, err error) ErrorPrimitiveReached

type Ignorer added in v0.12.0

type Ignorer interface {
	IgnoreString(string) bool
}

Ignorer is like matcher, but for explicitly ignoring resources

type Matcher

type Matcher interface {
	MatchString(string) bool
}

Matcher is a single filter expression. The passed argument of Matcher is of the form `kind/name` (manifest.KindName())

type Matchers

type Matchers []Matcher

Matchers is a collection of multiple expressions. A matcher may also implement Ignorer to explicitly ignore fields

func MustStrExps

func MustStrExps(strs ...string) Matchers

func RegExps

func RegExps(rs []*regexp.Regexp) Matchers

RegExps is a helper to construct Matchers from regular expressions

func StrExps

func StrExps(strs ...string) (Matchers, error)

func (Matchers) IgnoreString added in v0.12.0

func (e Matchers) IgnoreString(s string) bool

func (Matchers) MatchString

func (e Matchers) MatchString(s string) bool

MatchString returns whether at least one expression (OR) matches the string

type NegMatcher added in v0.12.0

type NegMatcher struct {
	// contains filtered or unexported fields
}

NexMatcher is a matcher that inverts the original behaviour

func (NegMatcher) IgnoreString added in v0.12.0

func (n NegMatcher) IgnoreString(s string) bool

func (NegMatcher) MatchString added in v0.12.0

func (n NegMatcher) MatchString(_ string) bool

Jump to

Keyboard shortcuts

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