edit

package
v0.10.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadDepListFromConfig added in v0.9.1

func LoadDepListFromConfig(cli *client.KpmClient, dependencies string) ([]string, error)

LoadDepsFrom parses the kcl external package option from a path. It will find `kcl.mod` recursively from the path, resolve deps in the `kcl.mod` and return the option. If not found, return the empty option.

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 []*yaml.RNode objects that represent the output YAML objects of the KCL program.

func RunKCLWithConfig added in v0.9.1

func RunKCLWithConfig(name, source string, dependencies []string, resourceList *yaml.RNode, config *api.ConfigSpec, getterOptions ...getter.ClientOption) ([]*yaml.RNode, error)

RunKCLWithConfig 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. - config: a pointer to a ConfigSpec that represents the compile config.

Return: A pointer to []*yaml.RNode objects that represent the output YAML objects of the KCL program.

func SourceToTempEntry added in v0.9.1

func SourceToTempEntry(src string, opts ...getter.ClientOption) (string, error)

SourceToTempEntry convert source to a temp KCL file.

func ToKCLValueString

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

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

func UnwrapResources

func UnwrapResources(nodes []*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
	// Dependencies are the external dependencies for the KCL code.
	Dependencies []string
	// FunctionConfig is the functionConfig for the function.
	FunctionConfig *yaml.RNode
	// Config is the compile config.
	Config *api.ConfigSpec
	// Getter options
	GetterOptions []getter.ClientOption
}

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