tanka

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2020 License: Apache-2.0 Imports: 22 Imported by: 2

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

Constants

View Source
const DEFAULT_DEV_VERSION = "dev"

DEFAULT_DEV_VERSION is the placeholder version used when no actual semver is provided using ldflags

Variables

View Source
var CURRENT_VERSION = DEFAULT_DEV_VERSION

CURRENT_VERSION is the current version of the running Tanka code

Functions

func Apply

func Apply(baseDir string, opts ApplyOpts) error

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`.

func DefaultEvaluator added in v0.13.0

func DefaultEvaluator(path string, opts jsonnet.Opts) (string, error)

DefaultEvaluator evaluates the jsonnet environment at the given file system path

func Delete added in v0.11.0

func Delete(baseDir string, opts DeleteOpts) error

Delete parses the environment at the given directory (a `baseDir`) and deletes the generated objects from the Kubernetes cluster defined in the environment's `spec.json`.

func Diff

func Diff(baseDir string, opts DiffOpts) (*string, error)

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 EnvsOnlyEvaluator added in v0.13.0

func EnvsOnlyEvaluator(path string, opts jsonnet.Opts) (string, error)

EnvsOnlyEvaluator finds the Environment object (without its .data object) at the given file system path intended for use by the `tk env` command

func Eval added in v0.7.0

func Eval(dir string, opts Opts) (raw interface{}, err error)

Eval returns the raw evaluated Jsonnet output (without any transformations)

func Format added in v0.9.0

func Format(filename string, content string) (string, error)

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.

func ParseEnv added in v0.13.0

func ParseEnv(path string, opts ParseOpts) (interface{}, *v1alpha1.Environment, error)

ParseEnv evaluates the jsonnet environment at the given file system path and optionally also returns and Environment object

func Prune added in v0.10.0

func Prune(baseDir string, opts PruneOpts) error

Prune deletes all resources from the cluster, that are no longer present in Jsonnet. It uses the `tanka.dev/environment` label to identify those.

func Show

func Show(baseDir string, opts Opts) (manifest.List, error)

Show parses the environment at the given directory (a `baseDir`) and returns the list of Kubernetes objects. Tip: use the `String()` function on the returned list to get the familiar yaml stream

Types

type ApplyOpts added in v0.12.0

type ApplyOpts struct {
	Opts

	// AutoApprove skips the interactive approval
	AutoApprove bool
	// DiffStrategy to use for printing the diff before approval
	DiffStrategy string

	// Force ignores any warnings kubectl might have
	Force bool
	// Validate set to false ignores invalid Kubernetes schemas
	Validate bool
}

ApplyOpts specify additional properties for the Apply action

type DeleteOpts added in v0.12.0

type DeleteOpts struct {
	Opts

	// AutoApprove skips the interactive approval
	AutoApprove bool

	// Force ignores any warnings kubectl might have
	Force bool
	// Validate set to false ignores invalid Kubernetes schemas
	Validate bool
}

DeleteOpts specify additional properties for the Delete operation

type DiffOpts added in v0.12.0

type DiffOpts struct {
	Opts

	// Strategy must be one of "native" or "subset"
	Strategy string
	// Summarize prints a summary, instead of the actual diff
	Summarize bool
}

DiffOpts specify additional properties for the Diff action

type ErrMultipleEnvs added in v0.13.0

type ErrMultipleEnvs struct {
	// contains filtered or unexported fields
}

ErrMultipleEnvs means that the given jsonnet has multiple Environment objects

func (ErrMultipleEnvs) Error added in v0.13.0

func (e ErrMultipleEnvs) Error() string

type ErrNoEnv added in v0.13.0

type ErrNoEnv struct {
	// contains filtered or unexported fields
}

ErrNoEnv means that the given jsonnet has no Environment object This must not be fatal, some operations work without

func (ErrNoEnv) Error added in v0.13.0

func (e ErrNoEnv) Error() string

type Evaluator added in v0.13.0

type Evaluator func(path string, opts jsonnet.Opts) (string, error)

Evaluator signature for implementing arbitrary Jsonnet evaluators

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

type Info struct {
	Env       *v1alpha1.Environment
	Resources manifest.List
	Client    client.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.

func Status

func Status(baseDir string, opts Opts) (*Info, error)

Status returns information about the particular environment

type JsonnetOpts added in v0.12.0

type JsonnetOpts = jsonnet.Opts

type Opts added in v0.12.0

type Opts struct {
	JsonnetOpts

	// Filters are used to optionally select a subset of the resources
	Filters process.Matchers
}

Opts specify general, optional properties that apply to all actions

type OutFn added in v0.9.0

type OutFn func(name, content string) error

OutFn is a function that receives the formatted file for further action, like persisting to disc

type ParseOpts added in v0.13.0

type ParseOpts struct {
	JsonnetOpts
	Evaluator Evaluator
}

type PruneOpts added in v0.12.0

type PruneOpts struct {
	Opts

	// AutoApprove skips the interactive approval
	AutoApprove bool
	// Force ignores any warnings kubectl might have
	Force bool
}

PruneOpts specify additional properties for the Prune action

Jump to

Keyboard shortcuts

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