sfio

package
v1.12.2 Latest Latest
Warning

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

Go to latest
Published: Jun 4, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Scheme = runtime.NewScheme()

Scheme is used globally to ensure the runtime helpers produce and consume RNodes with type metadata (kind and apiVersion) and Go typing. In general, there isn't a convenient way to parameterize the Read/Write calls (i.e. no Context), thus the global variable. By default, the scheme is loaded with the known Kubernetes API types and the types from this project (e.g Experiments).

Functions

func DecodeYAMLToJSON

func DecodeYAMLToJSON(node *yaml.RNode, v interface{}) error

DecodeYAMLToJSON is an alternative to `node.YNode().Decode(v)` that explicit round trips through JSON.

func FieldPath

func FieldPath(p string, data map[string]string) ([]string, error)

FieldPath evaluates a path template using the supplied context and then splits it into individual path segments (honoring escaped slashes).

func PreserveFieldMatcherPath

func PreserveFieldMatcherPath(fieldMatcher yaml.FieldMatcher) yaml.Filter

PreserveFieldMatcherPath wraps a field matcher so the resulting nodes have their field path set accordingly (incoming path + field name).

Types

type CommentClearer

type CommentClearer struct {
	// The name of the field to remove comments from.
	Name string
	// The collection of exact matching comments to clear.
	yaml.Comments
}

CommentClearer is filter for clearing specific comments.

func ClearFieldComment

func ClearFieldComment(name string, lineComment string) CommentClearer

ClearFieldComment returns a filter which will clear matching line comments from a named field.

func (CommentClearer) Filter

func (f CommentClearer) Filter(rn *yaml.RNode) (*yaml.RNode, error)

Filter returns the supplied node with the appropriate field comments removed.

type ExperimentMigrationFilter

type ExperimentMigrationFilter struct {
}

ExperimentMigrationFilter is a KYAML filter for perform experiment migration.

func (*ExperimentMigrationFilter) Filter

func (f *ExperimentMigrationFilter) Filter(node *yaml.RNode) (*yaml.RNode, error)

Filter applies migration changes to all recognized experiment nodes in the supplied list.

func (*ExperimentMigrationFilter) MigrateExperimentV1alpha1

func (f *ExperimentMigrationFilter) MigrateExperimentV1alpha1(node *yaml.RNode) (*yaml.RNode, error)

MigrateExperimentV1alpha1 converts a resource node from a v1alpha1 Experiment to a v1beta1 Experiment.

func (*ExperimentMigrationFilter) MigrateExperimentV1beta1

func (f *ExperimentMigrationFilter) MigrateExperimentV1beta1(node *yaml.RNode) (*yaml.RNode, error)

MigrateExperimentV1beta1 converts a resource node from a v1beta1 Experiment to the latest format.

type FieldRenamer

type FieldRenamer struct {
	// The field to rename.
	From string
	// The target field name.
	To string
}

FieldRenamer is a filter for renaming fields.

func RenameField

func RenameField(from, to string) FieldRenamer

RenameField returns a filter that renames a field, merging the content if the "to" field already exists.

func (FieldRenamer) Filter

func (f FieldRenamer) Filter(rn *yaml.RNode) (*yaml.RNode, error)

Filter returns the node representing the (possibly merged) value of the renamed node or nil if the "from" field was not present.

type HasFilter

type HasFilter struct {
	Filters []yaml.Filter
}

HasFilter is an alternative to a "tee" filter in that it applies a list of filters. However, unlike "tee" filter, if the result of the filters is nil, the final result is also nil. This allows for constructing filter pipelines that with simplified conditional logic.

func Has

func Has(filters ...yaml.Filter) HasFilter

Has works like `yaml.Tee` except that is also preserves a nil filter result.

func (HasFilter) Filter

func (f HasFilter) Filter(rn *yaml.RNode) (*yaml.RNode, error)

Filter returns the supplied node or nil if the the result of applying the configured filters is nil.

type IntOrString

type IntOrString struct {
	intstr.IntOrString
}

func (*IntOrString) UnmarshalYAML

func (is *IntOrString) UnmarshalYAML(value *yaml.Node) error

type ObjectList

type ObjectList corev1.List

ObjectList allows a generic list type to be used as a KYAML writer to provide interoperability between the YAML streaming and runtime objects.

func (*ObjectList) Write

func (o *ObjectList) Write(nodes []*yaml.RNode) error

Write converts the resource nodes into runtime objects.

type ObjectSlice

type ObjectSlice []runtime.Object

ObjectSlices allows a slice of object instances to be read as resource nodes.

func (ObjectSlice) Read

func (os ObjectSlice) Read() ([]*yaml.RNode, error)

Read converts the objects to JSON and then to YAML RNodes.

type TeeMatchedFilter

type TeeMatchedFilter struct {
	PathMatcher yaml.PathMatcher
	Filters     []yaml.Filter
}

TeeMatchedFilter is a filter that applies a set of filters to the nodes matched by a path matcher.

func TeeMatched

func TeeMatched(pathMatcher yaml.PathMatcher, filters ...yaml.Filter) TeeMatchedFilter

TeeMatched acts as a "tee" filter for nodes matched by the supplied path matcher: each matched node is processed by the supplied filters and the result of the entire operation is the initial node (or an error).

func (TeeMatchedFilter) Filter

func (f TeeMatchedFilter) Filter(rn *yaml.RNode) (*yaml.RNode, error)

Filter always returns the supplied node, however all matching nodes will have been processed by the configured filters.

Jump to

Keyboard shortcuts

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