sfio

package
v2.1.7 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2022 License: Apache-2.0 Imports: 21 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 PathMatcher

func PathMatcher(p ...string) yaml.PathMatcher

PathMatcher returns a `yaml.PathMatcher` from the supplied path.

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 {
	ApplicationsAPI applications.API
}

ExperimentMigrationFilter is a KYAML filter for performing 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) MayNeedConversionFromV1alpha1 added in v2.0.1

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

MayNeedConversionFromV1alpha1 mimics the legacy conversion behavior of checking for a "spec.template" field to determine if an Experiment should be treated as if the version were "v1alpha1".

func (*ExperimentMigrationFilter) MigrateApplicationV1alpha1

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

MigrateApplicationV1alpha1 converts a resource node from a v1alpha1 Application to the latest format.

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 a v1beta2 Experiment.

func (*ExperimentMigrationFilter) MigrateExperimentV1beta2

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

MigrateExperimentV1beta2 converts a resource node from a v1beta2 Experiment to the latest format.

func (*ExperimentMigrationFilter) MigrateRSOApplicationV1alpha1

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

MigrateRSOApplicationV1alpha1 converts a resource node from an apps.redskyops.dev/v1alpha1 Application to a v1alpha1 Application.

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 MetadataMigrationFilter

type MetadataMigrationFilter struct {
}

MetadataMigrationFilter is a KYAML filter for performing label/annotation migration.

func (*MetadataMigrationFilter) Filter

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

Filter replaces legacy prefixes found on labels and annotations.

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 PrefixClearer

type PrefixClearer struct {
	Value string
}

PrefixClearer removes a prefix from a node value.

func (*PrefixClearer) Filter

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

Filter removes the prefix from the node value or returns a nil node.

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