edit

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2023 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunKCL

func RunKCL(name, source string, resourceList *yaml.RNode) (*yaml.RNode, error)

RunKCL runs a KCL program specified by the given source code or url, with the given resource list as input, and returns the resulting KRM resource list.

Parameters: - name: a string that represents the name of the KCL program. Not used in the function. - source: a string that represents the source code of the KCL program. - resourceList: a pointer to a yaml.RNode object that represents the input KRM resource list.

Return: A pointer to a yaml.RNode object that represents the output YAML objects of the KCL program, and an error if any.

func SourceToTempFile

func SourceToTempFile(source string) (string, error)

SourceToTempFile convert source to a temp KCL file.

func ToKCLValueString

func ToKCLValueString(value *yaml.RNode) (string, error)

ToKCLValueString converts YAML value to KCL top level argument json value.

func UnwrapResources

func UnwrapResources(in *yaml.RNode) ([]*yaml.RNode, *yaml.RNode, error)

UnwrapResources unwraps the resources and the functionConfig from a resourceList

func WrapResources

func WrapResources(nodes []*yaml.RNode, fc *yaml.RNode) (*yaml.RNode, error)

WrapResources wraps resources and an optional functionConfig in a resourceList

Types

type SimpleTransformer

type SimpleTransformer struct {
	// Name of the KCL program
	Name string
	// Source is a KCL script which will be run against the resources
	Source string
	// FunctionConfig is the functionConfig for the function.
	FunctionConfig *yaml.RNode
}

SimpleTransformer transforms a set of resources through the provided KCL program. It doesn't touch the id annotation. It doesn't copy comments.

func (*SimpleTransformer) String

func (st *SimpleTransformer) String() string

Format transformer using the name and source.

func (*SimpleTransformer) Transform

func (st *SimpleTransformer) Transform(nodes []*yaml.RNode) ([]*yaml.RNode, error)

Transform YAML nodes and return error if any error occurs.

type Transformer

type Transformer interface {
	// Transform YAML nodes and return error if any error occurs.
	Transform(nodes []*yaml.RNode) ([]*yaml.RNode, error)
}

Transformer is an interface that defines the transformer operations for YAML values.

Jump to

Keyboard shortcuts

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