runtime

package
v1.8.7 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2022 License: Apache-2.0 Imports: 51 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate added in v1.3.0

func Generate(path string) error

func RunUnitTests

func RunUnitTests(ctx context.Context, path string, outW, errW io.Writer) (bool, error)

RunUnitTests executes (if found) tests reference by path. Writes test output to w.

func Validate

func Validate(c *Config) error

Validate checks if all required fields are set.

Types

type Command

type Command string

Command is the type of the supported Isopod runtime command.

const (
	// InstallCommand will rollout configurations of all chosen addons by
	// calling the install(ctx) method in each addon.
	InstallCommand Command = "install"
	// RemoveCommand will uninstall all chosen addons by
	// calling the remove(ctx) method in each addon.
	RemoveCommand Command = "remove"
	// ListCommand will list all chosen addons in the Starlark entry file.
	ListCommand Command = "list"
	// TestCommand will run Isopod in unit test mode with external services
	// stubbed with mocks.
	TestCommand Command = "test"
	// GenerateCommand is used to generate Starlark code from yaml input
	GenerateCommand Command = "generate"

	// ClustersStarFunc is the name of the function in Starlark that returns
	// a list of Starlark built-ins that implement cloud.KubernetesVendor
	// interface.
	ClustersStarFunc = "clusters"
	// AddonsStarFunc is the name of the function in Starlark that returns
	// a list of addon() built-ins.
	AddonsStarFunc = "addons"
)

type Config

type Config struct {
	// EntryFile is the path to the main Starlark file that the
	// Isopod runtime initializes to. It must contains ClustersStarFunc
	// and AddonsStarFunc.
	EntryFile string

	// GCPSvcAcctKeyFile is the path to the Google Service Account
	// Credential file. It is used to authenticate with GKE clusters.
	GCPSvcAcctKeyFile string

	// UserAgent is the UserAgent name used by Isopod to communicate with all
	// Kubernetes masters.
	UserAgent string

	// KubeConfigPath is the path to the kubeconfig file on the local machine.
	// It is used to authenticate with self-managed or on-premise Kubernetes.
	KubeConfigPath string

	// DryRun is true if commands run in dry-run mode, which does not alter
	// the live configuration in the cluster. It will print YAML diff against
	// live objects in cluster.
	DryRun bool

	// Force is true if the -force flag is set and will delete and recreate
	// immutable resources without confirmation. By default Force is disabled
	// and will error in case an immutable resource is being updated.
	Force bool

	// Store is the storage to keep all rollout status.
	Store store.Store
}

Config is used to create a new Runtime.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option is an interface that applies (enables) a specific option to a set of options.

func WithAddonRegex

func WithAddonRegex(r *regexp.Regexp) Option

WithAddonRegex returns an Option that filters addons using supplied regex.

func WithHelm

func WithHelm(baseDir string) Option

func WithKube

func WithKube(c *rest.Config, diff bool, diffFilters []string) Option

WithKube returns an Option that enables "kube" package.

func WithNoSpin

func WithNoSpin() Option

WithNoSpin option disables terminal spinner (UI).

func WithVault

func WithVault(c *vapi.Client) Option

WithVault returns an Option that enables "vault" package.

type Runtime

type Runtime interface {
	// Load parses and resolves the main entry Starlark file.
	Load(ctx context.Context) error

	// Run starts the runtime and executes the given command in the main entry
	// Starlark file that has been loaded. The runtime will call AddonsStarFunc.
	Run(ctx context.Context, cmd Command, skyCtx starlark.Value) error

	// ForEachCluster calls the ClustersStarFunc in the main Starlark file with
	// userCtx as argument to get a list of Starlark built-ins that implement
	// the cloud.KubernetesVendor interface. It then iterates through each
	// cluster to call the user given fn.
	ForEachCluster(ctx context.Context, userCtx map[string]string, fn func(k8sVendor cloud.KubernetesVendor)) error
}

Runtime describe the Isopod runtime behaviors.

func New

func New(c *Config, opts ...Option) (Runtime, error)

New returns new Runtime object from path with opts.

Jump to

Keyboard shortcuts

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