{"modulePath":"github.com/windsorcli/cli","version":"v0.10.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package runtime\n\n## Types\n\n```go\ntype Runtime struct {\n\t// ContextName is the current context name\n\tContextName string\n\n\t// ProjectRoot is the project root directory path\n\tProjectRoot string\n\n\t// BasePath is the directory that holds the terraform, kustomize, and contexts directories\n\tBasePath string\n\n\t// ConfigRoot is the config root directory (\u003cbase\u003e/contexts/\u003ccontextName\u003e)\n\tConfigRoot string\n\n\t// TemplateRoot is the template directory (\u003cbase\u003e/contexts/_template)\n\tTemplateRoot string\n\n\t// WindsorScratchPath is the windsor scratch directory (\u003cprojectRoot\u003e/.windsor/contexts/\u003ccontextName\u003e)\n\tWindsorScratchPath string\n\n\t// Global indicates the runtime is operating in global mode, where no windsor.yaml\n\t// project was found and $HOME/.config/windsor is used as the effective project root.\n\tGlobal bool\n\n\t// Core dependencies\n\tConfigHandler config.ConfigHandler\n\tShell         shell.Shell\n\tEvaluator     evaluator.ExpressionEvaluator\n\n\t// Resolver dispatches secret references across configured providers\n\tResolver *secretsRuntime.Resolver\n\n\t// EnvPrinters contains environment printers for various providers and tools\n\tEnvPrinters struct {\n\t\tDotEnvEnv    env.EnvPrinter\n\t\tAwsEnv       env.EnvPrinter\n\t\tAzureEnv     env.EnvPrinter\n\t\tGcpEnv       env.EnvPrinter\n\t\tVsphereEnv   env.EnvPrinter\n\t\tDockerEnv    env.EnvPrinter\n\t\tKubeEnv      env.EnvPrinter\n\t\tTalosEnv     env.EnvPrinter\n\t\tTerraformEnv env.EnvPrinter\n\t\tWindsorEnv   env.EnvPrinter\n\t}\n\n\t// ToolsManager manages tool installation and configuration\n\tToolsManager tools.ToolsManager\n\n\t// TerraformProvider provides Terraform-specific operations\n\tTerraformProvider terraform.TerraformProvider\n\n\t// Shims holds the system calls that tests replace\n\tShims *Shims\n\t// contains filtered or unexported fields\n}\n```\nRuntime 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.\n\n```go\nfunc NewRuntime(opts ...*Runtime) *Runtime\n```\nNewRuntime 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.\n\n```go\nfunc (rt *Runtime) ApplyConfigDefaults(flagOverrides ...map[string]any) error\n```\nApplyConfigDefaults 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.\n\n```go\nfunc (rt *Runtime) Base() string\n```\nBase returns the base directory of the project. It is ProjectRoot when the runtime has no BasePath, or when BasePath is outside ProjectRoot.\n\n```go\nfunc (rt *Runtime) BaseRel() string\n```\nBaseRel returns the base directory relative to ProjectRoot, with forward slashes. It is empty when the base is ProjectRoot.\n\n```go\nfunc (rt *Runtime) CheckTools() error\n```\nCheckTools 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.\n\n```go\nfunc (rt *Runtime) CheckToolsFor(reqs tools.Requirements) error\n```\nCheckToolsFor 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.\n\n```go\nfunc (rt *Runtime) GenerateBuildID() (string, error)\n```\nGenerateBuildID makes a new build ID and writes it to .windsor/.build-id, over any existing value. It returns the new build ID.\n\n```go\nfunc (rt *Runtime) GetAliases() map[string]string\n```\nGetAliases returns a copy of the collected aliases.\n\n```go\nfunc (rt *Runtime) GetBuildID() (string, error)\n```\nGetBuildID 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.\n\n```go\nfunc (rt *Runtime) GetEnvVars() map[string]string\n```\nGetEnvVars returns a copy of the collected environment variables.\n\n```go\nfunc (rt *Runtime) HandleSessionReset(quiet ...bool) error\n```\nHandleSessionReset 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.\n\n```go\nfunc (rt *Runtime) InitializeComponents() error\n```\nInitializeComponents initializes all environment-related components required after setup. Initializes TerraformProvider if terraform is enabled. Returns an error if initialization fails.\n\n```go\nfunc (rt *Runtime) LoadEnvironment(decrypt bool) error\n```\nLoadEnvironment 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.\n\n```go\nfunc (rt *Runtime) ManagedNames() (envs, aliases []string)\n```\nManagedNames 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.\n\n```go\nfunc (rt *Runtime) PrepareTools() error\n```\nPrepareTools 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.\n\n```go\nfunc (rt *Runtime) PrepareToolsFor(reqs tools.Requirements) error\n```\nPrepareToolsFor 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.\n\n```go\nfunc (rt *Runtime) ResolveConfig(flagOverrides map[string]any) error\n```\nResolveConfig runs the config pipeline one time for a command. The steps are:\n\n  - Set the pre-load defaults, load the config from disk, and set the post-load defaults.\n  - Fail when the context sets both registries and docker.registries. Warn when it sets only docker.registries.\n  - Set the flag overrides. A legacy \"provider\" override sets the platform.\n  - Set the DNS defaults of a workstation, and in dev mode change a colima and incus vm.runtime to platform incus.\n\n```go\nfunc (rt *Runtime) SaveConfig(overwrite ...bool) error\n```\nSaveConfig saves the config through the config handler. The handler writes the workstation keys to .windsor/contexts/\\\u003ccontext\u003e/workstation.yaml and not to values.yaml.\n\n```go\ntype Shims struct {\n\tshims.Shims\n\tOpenRoot func(name string) (*os.Root, error)\n}\n```\nShims holds the shared system call primitives and the runtime-specific shims.\n\n```go\nfunc NewShims() *Shims\n```\nNewShims returns a Shims with every field set to its real implementation.\n\n","path":"github.com/windsorcli/cli/pkg/runtime","name":"runtime","synopsis":"","isRedistributable":true}
