generate

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package generate implements the logic for generating output files based on input data.

Combines a directory of cluster configurations with a directory of components (along with some Jsonnet libs) to generate output files.

The package prepares a Jsonnet VM and loads the necessary libraries and extvars. A new VM is created for each component.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckIfUpdateNeeded

func CheckIfUpdateNeeded(outFile string, outStr string) (bool, error)

Check if a file needs updating based on its current contents and the new contents.

func CleanOutputDir

func CleanOutputDir(outputFileMap map[string]bool, componentOutputDir string) error

func GenProcessCluster

func GenProcessCluster(
	clusterName string,
	clusterdir string,
	baseDir string,
	generateDirOverride string,
	kr8Opts types.Kr8Opts,
	clusterParamsFile string,
	filters util.PathFilterOptions,
	vmConfig types.VMConfig,
	pool *ants.Pool,
) error

func GenProcessComponent

func GenProcessComponent(
	vmconfig types.VMConfig,
	componentName string,
	kr8Spec kr8_types.Kr8ClusterSpec,
	kr8Opts types.Kr8Opts,
	config string,
	allConfig *safeString,
	filters util.PathFilterOptions,
	paramsFile string,
) error

func GenerateIncludesFiles

func GenerateIncludesFiles(
	includesFiles []kr8_types.Kr8ComponentSpecIncludeObject,
	kr8Spec kr8_types.Kr8ClusterSpec,
	kr8Opts types.Kr8Opts,
	config string,
	componentName string,
	compPath string,
	componentOutputDir string,
	jvm *jsonnet.VM,
) (map[string]bool, error)

func GetClusterParams

func GetClusterParams(clusterDir string, vmConfig types.VMConfig) (map[string]string, error)

func ProcessFile

func ProcessFile(
	inputFile string,
	outputFile string,
	kr8Spec kr8_types.Kr8ClusterSpec,
	componentName string,
	config string,
	incInfo kr8_types.Kr8ComponentSpecIncludeObject,
	jvm *jsonnet.VM,
) (string, error)

Process an includes file. Based on the extension, the file is processed differently.

  • .jsonnet: Imported and processed using jsonnet VM.
  • .yml, .yaml: Imported and processed through native function ParseYaml.
  • .tpl, .tmpl: Processed using component config and Sprig templating.

func SetupAndConfigureVM

func SetupAndConfigureVM(
	vmconfig types.VMConfig,
	config string,
	kr8Spec kr8_types.Kr8ClusterSpec,
	componentName string,
	compSpec kr8_types.Kr8ComponentSpec,
	allConfig *safeString,
	filters util.PathFilterOptions,
	paramsFile string,
	kr8Opts types.Kr8Opts,
) (*jsonnet.VM, string, error)

func SetupJvmForComponent

func SetupJvmForComponent(
	vmconfig types.VMConfig,
	config string,
	kr8Spec kr8_types.Kr8ClusterSpec,
	componentName string,
) (*jsonnet.VM, error)

This function sets up the JVM for a given component. It registers native functions, sets up post-processing, and prunes parameters as required. It's faster to create this VM for each component, rather than re-use. Default postprocessor just copies input to output.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳