Documentation ¶
Overview ¶
Package tanka allows to use most of Tanka's features available on the command line programmatically as a Golang library. Keep in mind that the API is still experimental and may change without and signs of warnings while Tanka is still in alpha. Nevertheless, we try to avoid breaking changes.
Index ¶
- func Apply(baseDir string, mods ...Modifier) error
- func Diff(baseDir string, mods ...Modifier) (*string, error)
- func Eval(dir string, mods ...Modifier) (raw map[string]interface{}, err error)
- func Format(filename string, content string) (string, error)
- func FormatFiles(fds []string, opts *FormatOpts) ([]string, error)
- func Show(baseDir string, mods ...Modifier) (manifest.List, error)
- type FormatOpts
- type Info
- type Modifier
- type OutFn
- type ParseResult
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Apply ¶
Apply parses the environment at the given directory (a `baseDir`) and applies the evaluated jsonnet to the Kubernetes cluster defined in the environments `spec.json`. NOTE: This function prints on screen in default configuration. Use the `WithWarnWriter` modifier to change that. The `WithApply*` modifiers may be used to further influence the behavior.
func Diff ¶
Diff parses the environment at the given directory (a `baseDir`) and returns the differences from the live cluster state in `diff(1)` format. If the `WithDiffSummarize` modifier is used, a histogram created using `diffstat(1)` is returned instead. The cluster information is retrieved from the environments `spec.json`. NOTE: This function requires on `diff(1)`, `kubectl(1)` and perhaps `diffstat(1)`
func Eval ¶ added in v0.7.0
Eval returns the raw evaluated Jsonnet output (without any transformations)
func Format ¶ added in v0.9.0
Format takes a file's name and contents and returns them in properly formatted. The file does not have to exist on disk.
func FormatFiles ¶ added in v0.9.0
func FormatFiles(fds []string, opts *FormatOpts) ([]string, error)
FormatFiles takes a list of files and directories, processes them and returns which files were formatted and perhaps an error.
Types ¶
type FormatOpts ¶ added in v0.9.0
type FormatOpts struct { // Excludes are a list of globs to exclude files while searching for Jsonnet // files Excludes []glob.Glob // OutFn receives the formatted file and it's name. If left nil, the file // will be formatted in place. OutFn OutFn // PrintNames causes all filenames to be printed PrintNames bool }
FormatOpts modify the behaviour of Format
type Info ¶
Info holds information about a particular environment, including its Config, the individual resources of the desired state and also the status of the client.
type Modifier ¶
type Modifier func(*options)
Modifier allow to influence the behavior of certain `tanka.*` actions. They are roughly equivalent to flags on the command line. See the `tanka.With*` functions for available options.
func WithApplyAutoApprove ¶
WithApplyAutoApprove allows to skip the interactive approval
func WithApplyForce ¶
WithApplyForce allows to invoke `kubectl apply` with the `--force` flag
func WithApplyValidate ¶ added in v0.7.1
WithApplyValidate allows to invoke `kubectl apply` with the `--validate=false` flag
func WithDiffStrategy ¶
WithDiffStrategy allows to set the used diff strategy. An empty string is ignored.
func WithDiffSummarize ¶
WithDiffSummarize enables summary mode, which invokes `diffstat(1)` on the set of changes to create an overview
func WithExtCode ¶ added in v0.7.0
WithExtCode allows to pass external variables (jsonnet code) to the VM
func WithTargets ¶
WithTargets allows to submit regular expressions to limit the working set of objects (https://tanka.dev/output-filtering/).