kubecfg

package
v0.34.3 Latest Latest
Warning

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

Go to latest
Published: Feb 19, 2024 License: Apache-2.0 Imports: 62 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProvenanceFileAnnotation = "kubecfg.github.com/provenance-file"
	ProvenancePathAnnotation = "kubecfg.github.com/provenance-path"
)
View Source
const (
	// AnnotationOrigObject annotation records the resource as it
	// was most recently specified by kubecfg (serialised to
	// JSON).  This is used as input to the strategic-merge-patch
	// 3-way merge when performing updates.
	AnnotationOrigObject = "kubecfg.ksonnet.io/last-applied-configuration"

	// AnnotationGcTag annotation that triggers
	// garbage collection. Objects with value equal to
	// command-line flag that are *not* in config will be deleted.
	//
	// NB: this is in phase1 of a migration to use a label instead.
	// At this stage, both label+migration are written, but the
	// annotation (only) is still used to trigger GC. [gctag-migration]
	AnnotationGcTag = LabelGcTag

	// LabelGcTag label that triggers garbage collection. Objects
	// with value equal to command-line flag that are *not* in
	// config will be deleted.
	//
	// NB: this is in phase1 of a migration from an annotation.
	// At this stage, both label+migration are written, but the
	// annotation (only) is still used to trigger GC. [gctag-migration]
	LabelGcTag = "kubecfg.ksonnet.io/garbage-collect-tag"

	// AnnotationGcStrategy controls gc logic.  Current values:
	// `auto` (default if absent) - do garbage collection
	// `ignore` - never garbage collect this object
	AnnotationGcStrategy = "kubecfg.ksonnet.io/garbage-collect-strategy"

	// GcStrategyAuto is the default automatic gc logic
	GcStrategyAuto = "auto"
	// GcStrategyIgnore means this object should be ignored by garbage collection
	GcStrategyIgnore = "ignore"
)
View Source
const (
	// DefaultFileNameFormat is a Go template expression used to generate the filenames when
	// running the `show --export-dir` command.
	DefaultFileNameFormat = `{{.apiVersion}}.{{.kind}}-{{default "default" .metadata.namespace}}.{{.metadata.name}}`
)

Variables

View Source
var DiffKeyValue = regexp.MustCompile(`"([-._a-zA-Z0-9]+)":\s"([[:alnum:]=+]+)",?`)
View Source
var DiffLineStart = regexp.MustCompile("(^|\n)(.)")

Matches all the line starts on a diff text, which is where we put diff markers and indent

View Source
var ErrDiffFound = fmt.Errorf("Differences found.")

Functions

func JsonnetVM added in v0.29.1

func JsonnetVM(opt ...JsonnetVMOpt) (*jsonnet.VM, error)

JsonnetVM constructs a new jsonnet.VM, according to command line flags

func ReadObjects added in v0.29.1

func ReadObjects(vm *jsonnet.VM, paths []string, opts ...utils.ReadOption) ([]*unstructured.Unstructured, error)

ReadObjects evaluates all jsonnet files in paths and return all the k8s objects found in it. Unlike utils.Read this checks for duplicates and flattens the v1 Lists.

Types

type DeleteCmd added in v0.6.0

type DeleteCmd struct {
	Client           dynamic.Interface
	Mapper           meta.RESTMapper
	Discovery        discovery.DiscoveryInterface
	DefaultNamespace string

	GracePeriod int64
}

DeleteCmd represents the delete subcommand

func (DeleteCmd) Run added in v0.6.0

func (c DeleteCmd) Run(ctx context.Context, apiObjects []*unstructured.Unstructured) error

type DiffCmd added in v0.6.0

type DiffCmd struct {
	Client           dynamic.Interface
	Mapper           meta.RESTMapper
	DefaultNamespace string
	OmitSecrets      bool

	DiffStrategy string
}

DiffCmd represents the diff subcommand

func (DiffCmd) Run added in v0.6.0

func (c DiffCmd) Run(ctx context.Context, apiObjects []*unstructured.Unstructured, out io.Writer) error

type EvalCmd added in v0.29.0

type EvalCmd struct {
	Expr     string
	ShowKeys bool
	Format   string
	Trace    bool
}

EvalCmd represents the eval subcommand

func (EvalCmd) Run added in v0.29.0

func (c EvalCmd) Run(ctx context.Context, vm *jsonnet.VM, path string, tla []string) error

type HttpdCmd added in v0.29.0

type HttpdCmd struct {
	ListenAddr string
}

HttpdCmd represents the eval subcommand

func (HttpdCmd) Run added in v0.29.0

func (c HttpdCmd) Run(ctx context.Context, mkVM func() (*jsonnet.VM, error), paths []string) error

type JsonnetVMOpt added in v0.29.1

type JsonnetVMOpt func(*jsonnetVMOpts)

func WithAlpha added in v0.29.1

func WithAlpha(enable bool) JsonnetVMOpt

func WithImportPath added in v0.29.1

func WithImportPath(importPath ...string) JsonnetVMOpt

func WithImportURLs added in v0.29.1

func WithImportURLs(importURLs ...string) JsonnetVMOpt

func WithResolver added in v0.29.1

func WithResolver(typ ResolverType, failureMode ResolverFailureAction) JsonnetVMOpt

func WithVar added in v0.29.1

func WithVar(v vars.Var) JsonnetVMOpt

func WithWorkingDir added in v0.29.1

func WithWorkingDir(dir string) JsonnetVMOpt

type K8sMetadata added in v0.30.0

type K8sMetadata struct {
	Annotations map[string]string `json:"annotations"`
}

type K8sResource added in v0.30.0

type K8sResource struct {
	Metadata K8sMetadata `json:"metadata"`
}

type PackCmd added in v0.29.0

type PackCmd struct {
	OutputFile       string
	InsecureRegistry bool // use HTTP if true
	DocsTarFile      string
}

PackCmd represents the eval subcommand

func (PackCmd) Run added in v0.29.0

func (c PackCmd) Run(ctx context.Context, vm *jsonnet.VM, ociPackage string, rootFile string) (err error)

type ResolverFailureAction added in v0.29.1

type ResolverFailureAction int
const (
	IgnoreResolverError ResolverFailureAction = iota
	WarnResolverError
	ReportResolverError
)

type ResolverType added in v0.29.1

type ResolverType int
const (
	NoopResolver ResolverType = iota
	RegistryResolver
)

type ShowCmd added in v0.6.0

type ShowCmd struct {
	// OutputFormat is either "yaml" or "json".
	OutputFormat string
	// ExportDir is an optional name of a directory. If not set, the show command
	// will output all the resource concatenated to stdout. Otherwise, it will
	// create one file per resource, using the fileNameTemplate Go template to derive
	// the filename from the resource.
	ExportDir string
	// contains filtered or unexported fields
}

ShowCmd represents the show subcommand

func NewShowCmd added in v0.23.0

func NewShowCmd(outputFormat, exportDir, fileNameFormat, fileNameExt string) (ShowCmd, error)

NewShowCmd builds a ShowCmd initialized with its parameters. FileNameFormat will be parsed as a Go template and any template format error will be returned here.

func (ShowCmd) Run added in v0.6.0

func (c ShowCmd) Run(apiObjects []*unstructured.Unstructured, out io.Writer) error

type TracebackCmd added in v0.30.0

type TracebackCmd struct {
	ShowAll bool
}

TracebackCmd represents the traceback subcommand

func (TracebackCmd) Run added in v0.30.0

func (c TracebackCmd) Run(ctx context.Context, vm *jsonnet.VM, fileloc string) error

type UpdateCmd

type UpdateCmd struct {
	Client           dynamic.Interface
	Mapper           meta.RESTMapper
	Discovery        discovery.DiscoveryInterface
	DefaultNamespace string

	Create          bool
	GcTag           string
	GcTagsFromInput bool
	GcNamespace     string
	SkipGc          bool
	DryRun          bool
}

UpdateCmd represents the update subcommand

func (UpdateCmd) Run

func (c UpdateCmd) Run(ctx context.Context, apiObjects []*unstructured.Unstructured) error

Run executes the update command

type ValidateCmd added in v0.6.0

type ValidateCmd struct {
	Mapper        meta.RESTMapper
	Discovery     discovery.DiscoveryInterface
	IgnoreUnknown bool
}

ValidateCmd represents the validate subcommand

func (ValidateCmd) Run added in v0.6.0

func (c ValidateCmd) Run(apiObjects []*unstructured.Unstructured, out io.Writer) error

Directories

Path Synopsis
Types and constants pertaining to the various ways we can pass variables to a jsonnet VM engine.
Types and constants pertaining to the various ways we can pass variables to a jsonnet VM engine.

Jump to

Keyboard shortcuts

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