Documentation
¶
Index ¶
- type Runtime
- func (rt *Runtime) ApplyConfigDefaults(flagOverrides ...map[string]any) error
- func (rt *Runtime) Base() string
- func (rt *Runtime) BaseRel() string
- func (rt *Runtime) CheckTools() error
- func (rt *Runtime) CheckToolsFor(reqs tools.Requirements) error
- func (rt *Runtime) GenerateBuildID() (string, error)
- func (rt *Runtime) GetAliases() map[string]string
- func (rt *Runtime) GetBuildID() (string, error)
- func (rt *Runtime) GetEnvVars() map[string]string
- func (rt *Runtime) HandleSessionReset(quiet ...bool) error
- func (rt *Runtime) InitializeComponents() error
- func (rt *Runtime) LoadEnvironment(decrypt bool) error
- func (rt *Runtime) ManagedNames() (envs, aliases []string)
- func (rt *Runtime) PrepareTools() error
- func (rt *Runtime) PrepareToolsFor(reqs tools.Requirements) error
- func (rt *Runtime) ResolveConfig(flagOverrides map[string]any) error
- func (rt *Runtime) SaveConfig(overwrite ...bool) error
- type Shims
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 ¶
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 ¶
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
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
BaseRel returns the base directory relative to ProjectRoot, with forward slashes. It is empty when the base is ProjectRoot.
func (*Runtime) CheckTools ¶
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 ¶
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 ¶
GetAliases returns a copy of the collected aliases.
func (*Runtime) GetBuildID ¶
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 ¶
GetEnvVars returns a copy of the collected environment variables.
func (*Runtime) HandleSessionReset ¶
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
InitializeComponents initializes all environment-related components required after setup. Initializes TerraformProvider if terraform is enabled. Returns an error if initialization fails.
func (*Runtime) LoadEnvironment ¶
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
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 ¶
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
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
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.
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
|
|