kr8_init

import "github.com/ice-bergtech/kr8/pkg/kr8_init"

Package kr8_init contains logic for initializing a kr8+ starter repo. It is able to generate starter configs for components, clusters, and full repos.

Index

func GenerateChartJsonnet

func GenerateChartJsonnet(compJson kr8_types.Kr8ComponentJsonnet, componentOptions Kr8InitOptions, folderDir string) error

Generates a jsonnet files that references a local helm chart.

func GenerateChartTaskfile

func GenerateChartTaskfile(comp kr8_types.Kr8ComponentJsonnet, componentOptions Kr8InitOptions, folderDir string) error

Generates a go-task taskfile that's setup to download a helm chart into a local `vendor` directory.

func GenerateClusterJsonnet

func GenerateClusterJsonnet(cSpec kr8_types.Kr8ClusterSpec, dstDir string) error

Generate a cluster.jsonnet file based on the provided Kr8ClusterSpec and store it in the specified directory.

func GenerateComponentJsonnet

func GenerateComponentJsonnet(componentOptions Kr8InitOptions, dstDir string) error

Generate default component kr8_spec values and store in params.jsonnet. Based on the type:

jsonnet: create a component.jsonnet file and reference it from the params.jsonnet file

yml: leave a note in the params.jsonnet file about where and how the yml files can be referenced

chart: generate a simple taskfile that handles vendoring the chart data

func GenerateLib

func GenerateLib(fetch bool, dstDir string) error

Downloads a starter kr8+ jsonnet lib from github. If fetch is true, downloads the repo in the /lib directory. If false, prints the git commands to run. Repo: https://github.com/ice-bergtech/kr8-libsonnet . return util.FetchRepoUrl("https://github.com/ice-bergtech/kr8-libsonnet", dstDir+"/kr8-lib", !fetch).

func GenerateReadme

func GenerateReadme(dstDir string, cmdOptions Kr8InitOptions, clusterSpec kr8_types.Kr8ClusterSpec) error

Generates a starter readme for the repo, and writes it to the destination directory.

func InitComponentChart

func InitComponentChart(dstDir string, componentOptions Kr8InitOptions, compJson kr8_types.Kr8ComponentJsonnet) error

Initializes the basic parts of a helm chart component.

func InitComponentJsonnet

func InitComponentJsonnet(compJson kr8_types.Kr8ComponentJsonnet, dstDir string, componentOptions Kr8InitOptions) error

Initializes the basic parts of a jsonnet-based component.

func InitComponentTemplate

func InitComponentTemplate(compJson kr8_types.Kr8ComponentJsonnet, dstDir string, componentOptions Kr8InitOptions) error

Initializes the based parts of a template-based component.

func InitComponentYaml

func InitComponentYaml(compJson kr8_types.Kr8ComponentJsonnet, dstDir string, componentOptions Kr8InitOptions) error

Initializes the basic parts of a yaml-based component.

type Kr8InitOptions

Kr8InitOptions defines the options used by the init subcommands.

type Kr8InitOptions struct {
    // URL to fetch the skeleton directory from
    InitUrl string
    // Name of the cluster to initialize
    ClusterName string
    // Name of the component to initialize
    ComponentName string
    // Type of component to initialize (e.g. jsonnet, yml, chart, compose)
    ComponentType string
    // Determines whether to run in interactive mode
    Interactive bool
    // Determines whether to fetch remote resources
    Fetch bool
}