runtime

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: MPL-2.0 Imports: 18 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Runtime

type Runtime struct {
	// ContextName is the current context name
	ContextName string

	// ProjectRoot is the project root directory path
	ProjectRoot string

	// BasePath is the directory that holds the terraform, kustomize, and contexts directories
	BasePath string

	// ConfigRoot is the config root directory (<base>/contexts/<contextName>)
	ConfigRoot string

	// TemplateRoot is the template directory (<base>/contexts/_template)
	TemplateRoot string

	// WindsorScratchPath is the windsor scratch directory (<projectRoot>/.windsor/contexts/<contextName>)
	WindsorScratchPath string

	// Global indicates the runtime is operating in global mode, where no windsor.yaml
	// project was found and $HOME/.config/windsor is used as the effective project root.
	Global bool

	// Core dependencies
	ConfigHandler config.ConfigHandler
	Shell         shell.Shell
	Evaluator     evaluator.ExpressionEvaluator

	// Resolver dispatches secret references across configured providers
	Resolver *secretsRuntime.Resolver

	// EnvPrinters contains environment printers for various providers and tools
	EnvPrinters struct {
		DotEnvEnv    env.EnvPrinter
		AwsEnv       env.EnvPrinter
		AzureEnv     env.EnvPrinter
		GcpEnv       env.EnvPrinter
		VsphereEnv   env.EnvPrinter
		DockerEnv    env.EnvPrinter
		KubeEnv      env.EnvPrinter
		TalosEnv     env.EnvPrinter
		TerraformEnv env.EnvPrinter
		WindsorEnv   env.EnvPrinter
	}

	// ToolsManager manages tool installation and configuration
	ToolsManager tools.ToolsManager

	// TerraformProvider provides Terraform-specific operations
	TerraformProvider terraform.TerraformProvider

	// Shims holds the system calls that tests replace
	Shims *Shims
	// contains filtered or unexported fields
}

Runtime holds common execution values and core dependencies used across the Windsor CLI. These fields are set during various initialization steps rather than computed on-demand. Includes secret providers for Sops and 1Password, enabling access to secrets across all contexts. Also includes environment printers, tools manager, and environment variable/alias storage.

func NewRuntime

func NewRuntime(opts ...*Runtime) *Runtime

NewRuntime creates a Runtime and applies the non-nil values of opts as overrides. It creates a DefaultShell and a config handler when opts does not supply them. It sets the context name and the project, config, and template roots from the project state. It panics when it cannot create the shell or the config handler.

func (*Runtime) ApplyConfigDefaults

func (rt *Runtime) ApplyConfigDefaults(flagOverrides ...map[string]any) error

ApplyConfigDefaults sets pre-load defaults: dev mode, workstation runtime, platform, and a baseline config set. Defers entirely when dev mode isn't knowable yet (no explicit platform, no confirmed dev mode, nothing loaded), so it doesn't commit platform: "none" before ResolveConfig's post-load call (setConfigDefaults) sees the real value.

func (*Runtime) Base added in v0.10.0

func (rt *Runtime) Base() string

Base returns the base directory of the project. It is ProjectRoot when the runtime has no BasePath, or when BasePath is outside ProjectRoot.

func (*Runtime) BaseRel added in v0.10.0

func (rt *Runtime) BaseRel() string

BaseRel returns the base directory relative to ProjectRoot, with forward slashes. It is empty when the base is ProjectRoot.

func (*Runtime) CheckTools

func (rt *Runtime) CheckTools() error

CheckTools performs tool version checking using the tools manager against the full AllRequirements set. Equivalent to CheckToolsFor(tools.AllRequirements()) and exists for backward compatibility plus the explicit "verify everything" command (`windsor check`). New callers should declare per-command requirements via CheckToolsFor.

func (*Runtime) CheckToolsFor added in v0.9.0

func (rt *Runtime) CheckToolsFor(reqs tools.Requirements) error

CheckToolsFor checks the versions of the tool families in reqs. Each check skips a tool that the config does not use, such as Docker in a context without docker. It creates the tools manager if necessary, and returns an error if it cannot.

func (*Runtime) GenerateBuildID

func (rt *Runtime) GenerateBuildID() (string, error)

GenerateBuildID makes a new build ID and writes it to .windsor/.build-id, over any existing value. It returns the new build ID.

func (*Runtime) GetAliases

func (rt *Runtime) GetAliases() map[string]string

GetAliases returns a copy of the collected aliases.

func (*Runtime) GetBuildID

func (rt *Runtime) GetBuildID() (string, error)

GetBuildID returns the build ID in .windsor/.build-id, or an empty string if the file does not exist. It does not create a build ID. It creates the project root if the project root does not exist. A file that it cannot read returns an error with a hint.

func (*Runtime) GetEnvVars

func (rt *Runtime) GetEnvVars() map[string]string

GetEnvVars returns a copy of the collected environment variables.

func (*Runtime) HandleSessionReset

func (rt *Runtime) HandleSessionReset(quiet ...bool) error

HandleSessionReset resets the managed env vars when the shell sets a reset flag or WINDSOR_SESSION_TOKEN is not set. A reset sets NO_CACHE to "true" only if NO_CACHE is not set, so an explicit NO_CACHE=false stays. This is necessary because commands such as `windsor exec` have no session token, so each run resets. A reset also clears the Terraform output cache. When quiet is true, the reset does not print the unset commands.

func (*Runtime) InitializeComponents added in v0.9.0

func (rt *Runtime) InitializeComponents() error

InitializeComponents initializes all environment-related components required after setup. Initializes TerraformProvider if terraform is enabled. Returns an error if initialization fails.

func (*Runtime) LoadEnvironment

func (rt *Runtime) LoadEnvironment(decrypt bool) error

LoadEnvironment collects the env vars and aliases of each configured env printer and sets the env vars in the process. If decrypt is true, it loads the secrets before the printers run. After it sets the env vars, it runs the post-env hook of each printer and returns the first hook error.

func (*Runtime) ManagedNames added in v0.10.0

func (rt *Runtime) ManagedNames() (envs, aliases []string)

ManagedNames returns the env var and alias names that WINDSOR_MANAGED_ENV and WINDSOR_MANAGED_ALIAS list. These are the names that the previous windsor env run set in the shell.

func (*Runtime) PrepareTools

func (rt *Runtime) PrepareTools() error

PrepareTools checks and installs every tool family. Equivalent to PrepareToolsFor with AllRequirements; preserved for backward compatibility. New callers should narrow their requirements via PrepareToolsFor so commands like `windsor init` don't trip checks they won't actually exercise.

func (*Runtime) PrepareToolsFor added in v0.9.0

func (rt *Runtime) PrepareToolsFor(reqs tools.Requirements) error

PrepareToolsFor checks the tool families in reqs, then installs the tools that are missing or out of date. Each check skips a tool that the config does not use. It creates the tools manager if necessary, and returns an error if it cannot.

func (*Runtime) ResolveConfig added in v0.9.0

func (rt *Runtime) ResolveConfig(flagOverrides map[string]any) error

ResolveConfig runs the config pipeline one time for a command. The steps are:

  • Set the pre-load defaults, load the config from disk, and set the post-load defaults.
  • Fail when the context sets both registries and docker.registries. Warn when it sets only docker.registries.
  • Set the flag overrides. A legacy "provider" override sets the platform.
  • Set the DNS defaults of a workstation, and in dev mode change a colima and incus vm.runtime to platform incus.

func (*Runtime) SaveConfig added in v0.9.0

func (rt *Runtime) SaveConfig(overwrite ...bool) error

SaveConfig saves the config through the config handler. The handler writes the workstation keys to .windsor/contexts/<context>/workstation.yaml and not to values.yaml.

type Shims added in v0.10.0

type Shims struct {
	shims.Shims
	OpenRoot func(name string) (*os.Root, error)
}

Shims holds the shared system call primitives and the runtime-specific shims.

func NewShims added in v0.10.0

func NewShims() *Shims

NewShims returns a Shims with every field set to its real implementation.

Directories

Path Synopsis
The VirtEnvPrinter is a specialized component that manages virtual machine and container runtime environment configuration.
The VirtEnvPrinter is a specialized component that manages virtual machine and container runtime environment configuration.
internal

Jump to

Keyboard shortcuts

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