cmd

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2025 License: MIT Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RootCmd = &cobra.Command{
	Use:   "kr8",
	Short: "Kubernetes config parameter framework",
	Long: `A tool to generate Kubernetes configuration from a hierarchy
	of jsonnet files`,
}

RootCmd represents the base command when called without any subcommands

View Source
var Version string

exported Version variable

Functions

func Execute

func Execute(version string)

Execute adds all child commands to the root command sets flags appropriately. This is called by main.main(). It only needs to happen once to the rootCmd.

func JsonnetVM

func JsonnetVM(vmconfig VMConfig) (*jsonnet.VM, error)

func Pretty

func Pretty(input string, colorOutput bool) string

func RegisterNativeFuncs

func RegisterNativeFuncs(vm *jsonnet.VM)

Types

type Cluster

type Cluster struct {
	Name string `json:"name"`
	Path string `json:"-"`
}

init a struct for a single item

type ClusterComponent

type ClusterComponent struct {
	// The path to a component folder that contains a params.jsonnet file
	Path string `json:"path"`
}

type ClusterJsonnet

type ClusterJsonnet struct {
	// kr8 configuration for how to process the cluster
	ClusterSpec ClusterSpec `json:"_kr8_spec"`
	// Cluster Level configuration that components can reference
	Cluster Cluster `json:"_cluster"`
	// Distictly named components.
	Components map[string]ClusterComponent `json:"_components"`
}

type ClusterSpec

type ClusterSpec struct {
	// A jsonnet function that each output entry is processed through. Default `function(input) input`
	PostProcessor string `json:"postprocessor"`
	// The name of the root generate directory. Default `generated`
	GenerateDir string `json:"generate_dir"`
	// if this is true, we don't use the full file path to generate output file names
	GenerateShortNames bool `json:"generate_short_names"`
	// if this is true, we prune component parameters
	PruneParams bool `json:"prune_params"`
	// The root directory for the cluster. Default `clusters`
	ClusterDir string `json:"-"`
	// The name of the current cluster
	Name string `json:"-"`
}

func CreateClusterSpec

func CreateClusterSpec(clusterName string, spec gjson.Result, baseDir string, genDirOverride string) (ClusterSpec, error)

type Clusters

type Clusters struct {
	Cluster []Cluster
}

init a grouping struct

type CmdGetOptions

type CmdGetOptions struct {
	ClusterParams string
	NoTable       bool
	FieldName     string
	Cluster       string
	Component     string
	ParamField    string
}

type CmdJsonnetOptions

type CmdJsonnetOptions struct {
	Prune         bool
	Cluster       string
	ClusterParams string
	Component     string
	Format        string
}

type ComponentJsonnet

type ComponentJsonnet struct {
	// The default namespace to deploy the component to (optional)
	Namespace string `json:"namespace"`
	// A unique name for the component (optional)
	ReleaseName string `json:"release_name"`
	// Component version number (optional)
	Version string `json:"version"`
	// Component-specific configuration for kr8 (required)
	Kr8Spec ComponentSpec `json:"kr8_spec"`
}

type ComponentSpec

type ComponentSpec struct {
	// If true, includes the parameters of the current cluster when generating this component
	Kr8_allparams bool `json:"enable_kr8_allparams"`
	// If true, includes the parameters of all other clusters when generating this component
	Kr8_allclusters bool `json:"enable_kr8_allclusters"`
	// If false, all non-generated files present in the output directory will be removed
	DisableOutputDirClean bool `json:"disable_output_clean"`
	// A list of filenames to include as jsonnet vm external vars
	ExtFiles ExtFileVar `json:"extfiles"`
	// Additional jsonnet libs to the jsonnet vm, path component scoped
	JPaths []string `json:"jpaths"`
	// A list of filenames to include and output as files
	Includes []interface{} `json:"includes"`
}

kr8_spec object in cluster config

func CreateComponentSpec

func CreateComponentSpec(spec gjson.Result) (ComponentSpec, error)

type ExtFileVar

type ExtFileVar map[string]string

file to load as a string into the jsonnet vm name to reference the variable in jsonnet code through std.extvar() value of the variable, loaded from a file or provided directly

type IncludeFileEntryStruct

type IncludeFileEntryStruct struct {
	// an input file to process
	// accepted filetypes: .jsonnet .yml .yaml .tmpl .tpl
	File string `json:"file"`
	// handle alternate output directory for file
	DestDir string `json:"dest_dir,omitempty"`
	// override destination file name
	DestName string `json:"dest_name,omitempty"`
	// override destination file extension
	DestExt string `json:"dest_ext,omitempty"`
}

type IncludeFileSpec

type IncludeFileSpec interface {
	string
	IncludeFileEntryStruct
}

A struct describing an included file

type PathFilterOptions

type PathFilterOptions struct {
	Includes string
	Excludes string
}

type VMConfig

type VMConfig struct {
	// VMConfig is a configuration for the Jsonnet VM
	Jpaths  []string `json:"jpath" yaml:"jpath"`
	ExtVars []string `json:"ext_str_file" yaml:"ext_str_files"`
}

Jump to

Keyboard shortcuts

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