{"modulePath":"github.com/windsorcli/cli","version":"v0.10.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package env\n\nThe VirtEnvPrinter is a specialized component that manages virtual machine and container runtime environment configuration. It provides environment variable management for Docker and Incus runtimes, handling Docker host, context, registry configuration, and Incus socket paths. The VirtEnvPrinter ensures proper CLI integration and environment setup for container operations across different virtualization backends.\n\n## Variables\n\n```go\nvar WindsorPrefixedVars = []string{\n\t\"WINDSOR_CONTEXT\",\n\t\"WINDSOR_CONTEXT_ID\",\n\t\"BUILD_ID\",\n\t\"WINDSOR_PROJECT_ROOT\",\n\t\"WINDSOR_SESSION_TOKEN\",\n\t\"WINDSOR_MANAGED_ENV\",\n\t\"WINDSOR_MANAGED_ALIAS\",\n}\n```\nWindsorPrefixedVars are the environment variables that are managed by Windsor.\n\n## Types\n\n```go\ntype AwsEnvPrinter struct {\n\tBaseEnvPrinter\n\t// contains filtered or unexported fields\n}\n```\nAwsEnvPrinter is a struct that implements AWS environment configuration\n\n```go\nfunc NewAwsEnvPrinter(shell shell.Shell, configHandler config.ConfigHandler) *AwsEnvPrinter\n```\nNewAwsEnvPrinter creates a new AwsEnvPrinter instance\n\n```go\nfunc (e *AwsEnvPrinter) GetEnvVars() (map[string]string, error)\n```\nGetEnvVars returns the AWS environment variables of the current context. In project mode, AWS\\_CONFIG\\_FILE and AWS\\_SHARED\\_CREDENTIALS\\_FILE point at the .aws/ of the context. It sets AWS\\_PROFILE only when the AWS config defines the profile, so the SDK credential chain can run. In project mode, WarnOnProfileMismatch warns when a different profile exists. Global mode never warns. It registers each key as managed, so WindsorEnvPrinter unsets the key when this printer stops emitting it.\n\n```go\ntype AzureEnvPrinter struct {\n\tBaseEnvPrinter\n}\n```\nAzureEnvPrinter is a struct that implements Azure environment configuration\n\n```go\nfunc NewAzureEnvPrinter(shell shell.Shell, configHandler config.ConfigHandler) *AzureEnvPrinter\n```\nNewAzureEnvPrinter creates a new AzureEnvPrinter instance\n\n```go\nfunc (e *AzureEnvPrinter) GetEnvVars() (map[string]string, error)\n```\nGetEnvVars returns the Azure environment variables of the current context. In project mode, AZURE\\_CONFIG\\_DIR points at the .azure dir of the context, so az login stays scoped. Both modes set ARM\\_SUBSCRIPTION\\_ID, ARM\\_TENANT\\_ID, ARM\\_ENVIRONMENT, and TF\\_VAR\\_kubelogin\\_mode. It sets TF\\_VAR\\_region only when azure.region is set, so modules use their own defaults. It registers each key as managed, so WindsorEnvPrinter unsets the key when this printer stops emitting it.\n\n```go\ntype BaseEnvPrinter struct {\n\tEnvPrinter\n\t// contains filtered or unexported fields\n}\n```\nBaseEnvPrinter is a base implementation of the EnvPrinter interface\n\n```go\nfunc NewBaseEnvPrinter(shell shell.Shell, configHandler config.ConfigHandler) *BaseEnvPrinter\n```\nNewBaseEnvPrinter creates a new BaseEnvPrinter instance\n\n```go\nfunc (e *BaseEnvPrinter) GetAlias() (map[string]string, error)\n```\nGetAlias is a placeholder for creating an alias for a command.\n\n```go\nfunc (e *BaseEnvPrinter) GetEnvVars() (map[string]string, error)\n```\nGetEnvVars is a placeholder for retrieving environment variables.\n\n```go\nfunc (e *BaseEnvPrinter) GetManagedAlias() []string\n```\nGetManagedAlias returns the shell aliases that are managed by Windsor.\n\n```go\nfunc (e *BaseEnvPrinter) GetManagedEnv() []string\n```\nGetManagedEnv returns the environment variables that are managed by Windsor.\n\n```go\nfunc (e *BaseEnvPrinter) PostEnvHook(directory ...string) error\n```\nPostEnvHook simulates running any necessary commands after the environment variables have been set.\n\n```go\nfunc (e *BaseEnvPrinter) Reset()\n```\nReset removes all managed environment variables and aliases. It delegates to the shell's Reset method to handle the reset logic.\n\n```go\nfunc (e *BaseEnvPrinter) SetManagedEnv(env string)\n```\nSetManagedEnv sets the environment variables that are managed by Windsor.\n\n```go\nfunc (e *BaseEnvPrinter) ShouldSetManagedValue(key string) bool\n```\nShouldSetManagedValue reports whether a printer may set key. It returns true when key has no value in the environment yet, or when the previous round's WINDSOR\\_MANAGED\\_ENV already lists key as Windsor's own. It returns false when an operator's own value occupies key, so that value is left untouched.\n\n```go\ntype DotEnvEnvPrinter struct {\n\tBaseEnvPrinter\n\t// contains filtered or unexported fields\n}\n```\nDotEnvEnvPrinter is a struct that implements per-context .env environment configuration\n\n```go\nfunc NewDotEnvEnvPrinter(shell shell.Shell, configHandler config.ConfigHandler, eval evaluator.ExpressionEvaluator) *DotEnvEnvPrinter\n```\nNewDotEnvEnvPrinter creates a new DotEnvEnvPrinter instance\n\n```go\nfunc (e *DotEnvEnvPrinter) GetEnvVars() (map[string]string, error)\n```\nGetEnvVars loads contexts/\\\u003ccontext\u003e/.env, evaluating secret(...) expressions and registering every value with the shell for output scrubbing. A key already cached in the shell is omitted rather than re-evaluated. Returns an empty map when the file is absent, and warns (without failing) when the file has group- or world-readable permissions.\n\n```go\ntype EnvPrinter interface {\n\tGetEnvVars() (map[string]string, error)\n\tGetAlias() (map[string]string, error)\n\tPostEnvHook(directory ...string) error\n\tGetManagedEnv() []string\n\tGetManagedAlias() []string\n\tSetManagedEnv(env string)\n\tReset()\n}\n```\nEnvPrinter defines the method for printing environment variables. Secret-scrubbing contract: only values resolved through the evaluator's secret() expression are scrub-protected (the resolver in pkg/runtime/secrets calls shell.RegisterSecret automatically at resolve time). A printer setting literal credential material directly, not via secret(), must call shell.RegisterSecret itself; none of the provider printers do today, since none currently emit raw credentials — only identifiers, paths, and config, with the actual secret left to secrets.\n\n```go\ntype GcpEnvPrinter struct {\n\tBaseEnvPrinter\n}\n```\nGcpEnvPrinter is a struct that implements GCP environment configuration\n\n```go\nfunc NewGcpEnvPrinter(shell shell.Shell, configHandler config.ConfigHandler) *GcpEnvPrinter\n```\nNewGcpEnvPrinter creates a new GcpEnvPrinter instance\n\n```go\nfunc (e *GcpEnvPrinter) GetEnvVars() (map[string]string, error)\n```\nGetEnvVars returns the GCP environment variables of the current context. Project mode always sets CLOUDSDK\\_CONFIG. Google client libraries read GOOGLE\\_APPLICATION\\_CREDENTIALS. Windsor sets it from gcp.credentials\\_path, the service-account file, or the gcloud ADC file, in that order. Windsor stat-checks the two fallback files and never guesses a path. It recomputes the value unless the operator set one. GOOGLE\\_CLOUD\\_PROJECT, GCLOUD\\_PROJECT, and GOOGLE\\_CLOUD\\_QUOTA\\_PROJECT need a gcp: field.\n\n```go\ntype KubeEnvPrinter struct {\n\tBaseEnvPrinter\n}\n```\nKubeEnvPrinter is a struct that implements Kubernetes environment configuration\n\n```go\nfunc NewKubeEnvPrinter(shell shell.Shell, configHandler config.ConfigHandler) *KubeEnvPrinter\n```\nNewKubeEnvPrinter creates a new KubeEnvPrinter instance\n\n```go\nfunc (e *KubeEnvPrinter) GetEnvVars() (map[string]string, error)\n```\nGetEnvVars returns KUBECONFIG, KUBE\\_CONFIG\\_PATH, and the PV\\_ variables of the pvc-\\* volume directories. When a volume directory has no variable, it queries the Kubernetes API for the matching PVCs. When the API is not available, it returns the basic variables and no error.\n\n```go\ntype MockEnvPrinter struct {\n\tBaseEnvPrinter\n\tPrintFunc           func() error\n\tPrintAliasFunc      func() error\n\tPostEnvHookFunc     func(directory ...string) error\n\tGetEnvVarsFunc      func() (map[string]string, error)\n\tGetAliasFunc        func() (map[string]string, error)\n\tGetManagedEnvFunc   func() []string\n\tGetManagedAliasFunc func() []string\n\tResetFunc           func()\n}\n```\nMockEnvPrinter is a struct that implements mock environment configuration\n\n```go\nfunc NewMockEnvPrinter() *MockEnvPrinter\n```\nNewMockEnvPrinter creates a new MockEnvPrinter instance\n\n```go\nfunc (m *MockEnvPrinter) GetAlias() (map[string]string, error)\n```\nGetAlias simulates retrieving the shell alias. If a custom GetAliasFunc is provided, it will use that function instead.\n\n```go\nfunc (m *MockEnvPrinter) GetEnvVars() (map[string]string, error)\n```\nGetEnvVars simulates retrieving environment variables. If a custom GetEnvVarsFunc is provided, it will use that function instead.\n\n```go\nfunc (m *MockEnvPrinter) GetManagedAlias() []string\n```\nGetManagedAlias returns the managed aliases. If a custom GetManagedAliasFunc is provided, it will use that function instead.\n\n```go\nfunc (m *MockEnvPrinter) GetManagedEnv() []string\n```\nGetManagedEnv returns the managed environment variables. If a custom GetManagedEnvFunc is provided, it will use that function instead.\n\n```go\nfunc (m *MockEnvPrinter) PostEnvHook(directory ...string) error\n```\nPostEnvHook simulates running any necessary commands after the environment variables have been set. If a custom PostEnvHookFunc is provided, it will use that function instead.\n\n```go\nfunc (m *MockEnvPrinter) Print() error\n```\nPrint simulates printing the provided environment variables. If a custom PrintFunc is provided, it will use that function instead.\n\n```go\nfunc (m *MockEnvPrinter) PrintAlias() error\n```\nPrintAlias simulates printing the shell aliases. If a custom PrintAliasFunc is provided, it will use that function instead.\n\n```go\nfunc (m *MockEnvPrinter) Reset()\n```\nReset simulates resetting environment variables. If a custom ResetFunc is provided, it will use that function instead.\n\n```go\ntype Shims struct {\n\tshims.Shims\n\tLookPath func(string) (string, error)\n\tEnviron  func() []string\n}\n```\nShims holds the shared system call primitives and the env-specific process shims.\n\n```go\nfunc NewShims() *Shims\n```\nNewShims returns a Shims with every field set to its standard library implementation.\n\n```go\ntype TalosEnvPrinter struct {\n\tBaseEnvPrinter\n}\n```\nTalosEnvPrinter manages Talos environment configuration, providing Talos-specific environment variable management and configuration for CLI integration and environment setup.\n\n```go\nfunc NewTalosEnvPrinter(shell shell.Shell, configHandler config.ConfigHandler) *TalosEnvPrinter\n```\nNewTalosEnvPrinter creates and returns a new TalosEnvPrinter instance.\n\n```go\nfunc (e *TalosEnvPrinter) GetEnvVars() (map[string]string, error)\n```\nGetEnvVars returns a map of environment variables for the Talos and Omni environments. It sets TALOSCONFIG only when cluster.driver is \"talos\" and sets OMNICONFIG only when platform is \"omni\". Returns an error if the configuration root cannot be determined.\n\n```go\ntype TerraformArgs = terraform.TerraformArgs\n```\nTerraformArgs is an alias for terraform.TerraformArgs to maintain backward compatibility\n\n```go\ntype TerraformEnvPrinter struct {\n\tBaseEnvPrinter\n\t// contains filtered or unexported fields\n}\n```\nTerraformEnvPrinter is a struct that implements Terraform environment configuration\n\n```go\nfunc NewTerraformEnvPrinter(shell shell.Shell, configHandler config.ConfigHandler, toolsManager tools.ToolsManager, terraformProvider terraform.TerraformProvider) *TerraformEnvPrinter\n```\nNewTerraformEnvPrinter creates a new TerraformEnvPrinter instance\n\n```go\nfunc (e *TerraformEnvPrinter) GetEnvVars() (map[string]string, error)\n```\nGetEnvVars returns the Terraform environment variables of the current project directory. It merges the contexts/\\\u003ccontext\u003e/terraform/.env content into the generated arguments. Outside a Terraform project, it unsets the managed variables. It records the emitted keys in WINDSOR\\_MANAGED\\_TERRAFORM\\_ENV, so a later run can unset them after a change.\n\n```go\nfunc (e *TerraformEnvPrinter) PostEnvHook(directory ...string) error\n```\nPostEnvHook executes operations after setting the environment variables. It writes backend\\_override.tf only when the directory resolves to a component of the active context's blueprint (see GetTerraformComponentForPath) — terraform module directories are shared on disk across contexts, so a bare \\*.tf-file check is not enough to confirm directory belongs here.\n\n```go\ntype VirtEnvPrinter struct {\n\tBaseEnvPrinter\n}\n```\nVirtEnvPrinter is a struct that implements virtual machine and container runtime environment configuration\n\n```go\nfunc NewVirtEnvPrinter(shell shell.Shell, configHandler config.ConfigHandler) *VirtEnvPrinter\n```\nNewVirtEnvPrinter creates a new VirtEnvPrinter instance\n\n```go\nfunc (e *VirtEnvPrinter) GetAlias() (map[string]string, error)\n```\nGetAlias creates an alias for a command and returns it in a map. In this case, it looks for docker-cli-plugin-docker-compose and creates an alias for docker-compose.\n\n```go\nfunc (e *VirtEnvPrinter) GetEnvVars() (map[string]string, error)\n```\nGetEnvVars sets environment variables for virtual machine and container runtimes. When workstation.runtime is configured, it writes a Docker config file and sets DOCKER\\_CONFIG. DOCKER\\_HOST is set from the runtime when it does not yet exist or was previously managed by Windsor (present in WINDSOR\\_MANAGED\\_ENV); if DOCKER\\_HOST was set by the user it is left untouched. Handles \"colima\", \"docker-desktop\", and \"docker\" workstation runtimes. Also sets REGISTRY\\_URL from docker registry config, and INCUS\\_SOCKET for colima-incus setups.\n\n```go\ntype VsphereEnvPrinter struct {\n\tBaseEnvPrinter\n}\n```\nVsphereEnvPrinter is a struct that implements vSphere environment configuration\n\n```go\nfunc NewVsphereEnvPrinter(shell shell.Shell, configHandler config.ConfigHandler) *VsphereEnvPrinter\n```\nNewVsphereEnvPrinter creates a new VsphereEnvPrinter instance\n\n```go\nfunc (e *VsphereEnvPrinter) GetEnvVars() (map[string]string, error)\n```\nGetEnvVars returns the vSphere environment variables of the current context. In project mode, the VSPHERE\\_\\*\\_SESSION\\* variables keep the provider session cache in .vsphere/ of the context. Global mode omits them, so the provider uses its ambient defaults. It sets VSPHERE\\_SERVER, VSPHERE\\_USER, and VSPHERE\\_ALLOW\\_UNVERIFIED\\_SSL from config. VSPHERE\\_PASSWORD comes from secrets or the environment. It registers each key as managed.\n\n```go\ntype WindsorEnvPrinter struct {\n\tBaseEnvPrinter\n\t// contains filtered or unexported fields\n}\n```\nWindsorEnvPrinter is a struct that implements Windsor environment configuration\n\n```go\nfunc NewWindsorEnvPrinter(shell shell.Shell, configHandler config.ConfigHandler, eval evaluator.ExpressionEvaluator, allEnvPrinters []EnvPrinter) *WindsorEnvPrinter\n```\nNewWindsorEnvPrinter creates a new WindsorEnvPrinter instance\n\n```go\nfunc (e *WindsorEnvPrinter) GetEnvVars() (map[string]string, error)\n```\nGetEnvVars sets WINDSOR\\_CONTEXT, WINDSOR\\_CONTEXT\\_ID, WINDSOR\\_PROJECT\\_ROOT, WINDSOR\\_SESSION\\_TOKEN, and BUILD\\_ID. It evaluates secret expressions in the context's custom environment variables and caches the resolved values. It merges GetManagedEnv and GetManagedAlias from every printer into WINDSOR\\_MANAGED\\_ENV and WINDSOR\\_MANAGED\\_ALIAS. This printer runs last among all env printers. It then unsets any key the previous WINDSOR\\_MANAGED\\_ENV listed that no printer manages this round.\n\n","path":"github.com/windsorcli/cli/pkg/runtime/env","name":"env","synopsis":"The VirtEnvPrinter is a specialized component that manages virtual machine and container runtime environment configuration.","isRedistributable":true}
