Documentation
¶
Overview ¶
The 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.
Index ¶
- Variables
- type AwsEnvPrinter
- type AzureEnvPrinter
- type BaseEnvPrinter
- func (e *BaseEnvPrinter) GetAlias() (map[string]string, error)
- func (e *BaseEnvPrinter) GetEnvVars() (map[string]string, error)
- func (e *BaseEnvPrinter) GetManagedAlias() []string
- func (e *BaseEnvPrinter) GetManagedEnv() []string
- func (e *BaseEnvPrinter) PostEnvHook(directory ...string) error
- func (e *BaseEnvPrinter) Reset()
- func (e *BaseEnvPrinter) SetManagedEnv(env string)
- func (e *BaseEnvPrinter) ShouldSetManagedValue(key string) bool
- type DotEnvEnvPrinter
- type EnvPrinter
- type GcpEnvPrinter
- type KubeEnvPrinter
- type MockEnvPrinter
- func (m *MockEnvPrinter) GetAlias() (map[string]string, error)
- func (m *MockEnvPrinter) GetEnvVars() (map[string]string, error)
- func (m *MockEnvPrinter) GetManagedAlias() []string
- func (m *MockEnvPrinter) GetManagedEnv() []string
- func (m *MockEnvPrinter) PostEnvHook(directory ...string) error
- func (m *MockEnvPrinter) Print() error
- func (m *MockEnvPrinter) PrintAlias() error
- func (m *MockEnvPrinter) Reset()
- type Shims
- type TalosEnvPrinter
- type TerraformArgs
- type TerraformEnvPrinter
- type VirtEnvPrinter
- type VsphereEnvPrinter
- type WindsorEnvPrinter
Constants ¶
This section is empty.
Variables ¶
var WindsorPrefixedVars = []string{
"WINDSOR_CONTEXT",
"WINDSOR_CONTEXT_ID",
"BUILD_ID",
"WINDSOR_PROJECT_ROOT",
"WINDSOR_SESSION_TOKEN",
"WINDSOR_MANAGED_ENV",
"WINDSOR_MANAGED_ALIAS",
}
WindsorPrefixedVars are the environment variables that are managed by Windsor.
Functions ¶
This section is empty.
Types ¶
type AwsEnvPrinter ¶
type AwsEnvPrinter struct {
BaseEnvPrinter
// contains filtered or unexported fields
}
AwsEnvPrinter is a struct that implements AWS environment configuration
func NewAwsEnvPrinter ¶
func NewAwsEnvPrinter(shell shell.Shell, configHandler config.ConfigHandler) *AwsEnvPrinter
NewAwsEnvPrinter creates a new AwsEnvPrinter instance
func (*AwsEnvPrinter) GetEnvVars ¶
func (e *AwsEnvPrinter) GetEnvVars() (map[string]string, error)
GetEnvVars 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.
type AzureEnvPrinter ¶
type AzureEnvPrinter struct {
BaseEnvPrinter
}
AzureEnvPrinter is a struct that implements Azure environment configuration
func NewAzureEnvPrinter ¶
func NewAzureEnvPrinter(shell shell.Shell, configHandler config.ConfigHandler) *AzureEnvPrinter
NewAzureEnvPrinter creates a new AzureEnvPrinter instance
func (*AzureEnvPrinter) GetEnvVars ¶
func (e *AzureEnvPrinter) GetEnvVars() (map[string]string, error)
GetEnvVars 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.
type BaseEnvPrinter ¶
type BaseEnvPrinter struct {
EnvPrinter
// contains filtered or unexported fields
}
BaseEnvPrinter is a base implementation of the EnvPrinter interface
func NewBaseEnvPrinter ¶
func NewBaseEnvPrinter(shell shell.Shell, configHandler config.ConfigHandler) *BaseEnvPrinter
NewBaseEnvPrinter creates a new BaseEnvPrinter instance
func (*BaseEnvPrinter) GetAlias ¶
func (e *BaseEnvPrinter) GetAlias() (map[string]string, error)
GetAlias is a placeholder for creating an alias for a command.
func (*BaseEnvPrinter) GetEnvVars ¶
func (e *BaseEnvPrinter) GetEnvVars() (map[string]string, error)
GetEnvVars is a placeholder for retrieving environment variables.
func (*BaseEnvPrinter) GetManagedAlias ¶
func (e *BaseEnvPrinter) GetManagedAlias() []string
GetManagedAlias returns the shell aliases that are managed by Windsor.
func (*BaseEnvPrinter) GetManagedEnv ¶
func (e *BaseEnvPrinter) GetManagedEnv() []string
GetManagedEnv returns the environment variables that are managed by Windsor.
func (*BaseEnvPrinter) PostEnvHook ¶
func (e *BaseEnvPrinter) PostEnvHook(directory ...string) error
PostEnvHook simulates running any necessary commands after the environment variables have been set.
func (*BaseEnvPrinter) Reset ¶
func (e *BaseEnvPrinter) Reset()
Reset removes all managed environment variables and aliases. It delegates to the shell's Reset method to handle the reset logic.
func (*BaseEnvPrinter) SetManagedEnv ¶
func (e *BaseEnvPrinter) SetManagedEnv(env string)
SetManagedEnv sets the environment variables that are managed by Windsor.
func (*BaseEnvPrinter) ShouldSetManagedValue ¶ added in v0.9.1
func (e *BaseEnvPrinter) ShouldSetManagedValue(key string) bool
ShouldSetManagedValue 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.
type DotEnvEnvPrinter ¶ added in v0.9.0
type DotEnvEnvPrinter struct {
BaseEnvPrinter
// contains filtered or unexported fields
}
DotEnvEnvPrinter is a struct that implements per-context .env environment configuration
func NewDotEnvEnvPrinter ¶ added in v0.9.0
func NewDotEnvEnvPrinter(shell shell.Shell, configHandler config.ConfigHandler, eval evaluator.ExpressionEvaluator) *DotEnvEnvPrinter
NewDotEnvEnvPrinter creates a new DotEnvEnvPrinter instance
func (*DotEnvEnvPrinter) GetEnvVars ¶ added in v0.9.0
func (e *DotEnvEnvPrinter) GetEnvVars() (map[string]string, error)
GetEnvVars loads contexts/<context>/.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.
type EnvPrinter ¶
type EnvPrinter interface {
GetEnvVars() (map[string]string, error)
GetAlias() (map[string]string, error)
PostEnvHook(directory ...string) error
GetManagedEnv() []string
GetManagedAlias() []string
SetManagedEnv(env string)
Reset()
}
EnvPrinter 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.
type GcpEnvPrinter ¶ added in v0.9.0
type GcpEnvPrinter struct {
BaseEnvPrinter
}
GcpEnvPrinter is a struct that implements GCP environment configuration
func NewGcpEnvPrinter ¶ added in v0.9.0
func NewGcpEnvPrinter(shell shell.Shell, configHandler config.ConfigHandler) *GcpEnvPrinter
NewGcpEnvPrinter creates a new GcpEnvPrinter instance
func (*GcpEnvPrinter) GetEnvVars ¶ added in v0.9.0
func (e *GcpEnvPrinter) GetEnvVars() (map[string]string, error)
GetEnvVars 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.
type KubeEnvPrinter ¶
type KubeEnvPrinter struct {
BaseEnvPrinter
}
KubeEnvPrinter is a struct that implements Kubernetes environment configuration
func NewKubeEnvPrinter ¶
func NewKubeEnvPrinter(shell shell.Shell, configHandler config.ConfigHandler) *KubeEnvPrinter
NewKubeEnvPrinter creates a new KubeEnvPrinter instance
func (*KubeEnvPrinter) GetEnvVars ¶
func (e *KubeEnvPrinter) GetEnvVars() (map[string]string, error)
GetEnvVars 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.
type MockEnvPrinter ¶
type MockEnvPrinter struct {
BaseEnvPrinter
PrintFunc func() error
PrintAliasFunc func() error
PostEnvHookFunc func(directory ...string) error
GetEnvVarsFunc func() (map[string]string, error)
GetAliasFunc func() (map[string]string, error)
GetManagedEnvFunc func() []string
GetManagedAliasFunc func() []string
ResetFunc func()
}
MockEnvPrinter is a struct that implements mock environment configuration
func NewMockEnvPrinter ¶
func NewMockEnvPrinter() *MockEnvPrinter
NewMockEnvPrinter creates a new MockEnvPrinter instance
func (*MockEnvPrinter) GetAlias ¶
func (m *MockEnvPrinter) GetAlias() (map[string]string, error)
GetAlias simulates retrieving the shell alias. If a custom GetAliasFunc is provided, it will use that function instead.
func (*MockEnvPrinter) GetEnvVars ¶
func (m *MockEnvPrinter) GetEnvVars() (map[string]string, error)
GetEnvVars simulates retrieving environment variables. If a custom GetEnvVarsFunc is provided, it will use that function instead.
func (*MockEnvPrinter) GetManagedAlias ¶
func (m *MockEnvPrinter) GetManagedAlias() []string
GetManagedAlias returns the managed aliases. If a custom GetManagedAliasFunc is provided, it will use that function instead.
func (*MockEnvPrinter) GetManagedEnv ¶
func (m *MockEnvPrinter) GetManagedEnv() []string
GetManagedEnv returns the managed environment variables. If a custom GetManagedEnvFunc is provided, it will use that function instead.
func (*MockEnvPrinter) PostEnvHook ¶
func (m *MockEnvPrinter) PostEnvHook(directory ...string) error
PostEnvHook simulates running any necessary commands after the environment variables have been set. If a custom PostEnvHookFunc is provided, it will use that function instead.
func (*MockEnvPrinter) Print ¶
func (m *MockEnvPrinter) Print() error
Print simulates printing the provided environment variables. If a custom PrintFunc is provided, it will use that function instead.
func (*MockEnvPrinter) PrintAlias ¶
func (m *MockEnvPrinter) PrintAlias() error
PrintAlias simulates printing the shell aliases. If a custom PrintAliasFunc is provided, it will use that function instead.
func (*MockEnvPrinter) Reset ¶
func (m *MockEnvPrinter) Reset()
Reset simulates resetting environment variables. If a custom ResetFunc is provided, it will use that function instead.
type TalosEnvPrinter ¶
type TalosEnvPrinter struct {
BaseEnvPrinter
}
TalosEnvPrinter manages Talos environment configuration, providing Talos-specific environment variable management and configuration for CLI integration and environment setup.
func NewTalosEnvPrinter ¶
func NewTalosEnvPrinter(shell shell.Shell, configHandler config.ConfigHandler) *TalosEnvPrinter
NewTalosEnvPrinter creates and returns a new TalosEnvPrinter instance.
func (*TalosEnvPrinter) GetEnvVars ¶
func (e *TalosEnvPrinter) GetEnvVars() (map[string]string, error)
GetEnvVars 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.
type TerraformArgs ¶
type TerraformArgs = terraform.TerraformArgs
TerraformArgs is an alias for terraform.TerraformArgs to maintain backward compatibility
type TerraformEnvPrinter ¶
type TerraformEnvPrinter struct {
BaseEnvPrinter
// contains filtered or unexported fields
}
TerraformEnvPrinter is a struct that implements Terraform environment configuration
func NewTerraformEnvPrinter ¶
func NewTerraformEnvPrinter(shell shell.Shell, configHandler config.ConfigHandler, toolsManager tools.ToolsManager, terraformProvider terraform.TerraformProvider) *TerraformEnvPrinter
NewTerraformEnvPrinter creates a new TerraformEnvPrinter instance
func (*TerraformEnvPrinter) GetEnvVars ¶
func (e *TerraformEnvPrinter) GetEnvVars() (map[string]string, error)
GetEnvVars returns the Terraform environment variables of the current project directory. It merges the contexts/<context>/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.
func (*TerraformEnvPrinter) PostEnvHook ¶
func (e *TerraformEnvPrinter) PostEnvHook(directory ...string) error
PostEnvHook 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.
type VirtEnvPrinter ¶ added in v0.9.0
type VirtEnvPrinter struct {
BaseEnvPrinter
}
VirtEnvPrinter is a struct that implements virtual machine and container runtime environment configuration
func NewVirtEnvPrinter ¶ added in v0.9.0
func NewVirtEnvPrinter(shell shell.Shell, configHandler config.ConfigHandler) *VirtEnvPrinter
NewVirtEnvPrinter creates a new VirtEnvPrinter instance
func (*VirtEnvPrinter) GetAlias ¶ added in v0.9.0
func (e *VirtEnvPrinter) GetAlias() (map[string]string, error)
GetAlias 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.
func (*VirtEnvPrinter) GetEnvVars ¶ added in v0.9.0
func (e *VirtEnvPrinter) GetEnvVars() (map[string]string, error)
GetEnvVars 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.
type VsphereEnvPrinter ¶ added in v0.9.0
type VsphereEnvPrinter struct {
BaseEnvPrinter
}
VsphereEnvPrinter is a struct that implements vSphere environment configuration
func NewVsphereEnvPrinter ¶ added in v0.9.0
func NewVsphereEnvPrinter(shell shell.Shell, configHandler config.ConfigHandler) *VsphereEnvPrinter
NewVsphereEnvPrinter creates a new VsphereEnvPrinter instance
func (*VsphereEnvPrinter) GetEnvVars ¶ added in v0.9.0
func (e *VsphereEnvPrinter) GetEnvVars() (map[string]string, error)
GetEnvVars 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.
type WindsorEnvPrinter ¶
type WindsorEnvPrinter struct {
BaseEnvPrinter
// contains filtered or unexported fields
}
WindsorEnvPrinter is a struct that implements Windsor environment configuration
func NewWindsorEnvPrinter ¶
func NewWindsorEnvPrinter(shell shell.Shell, configHandler config.ConfigHandler, eval evaluator.ExpressionEvaluator, allEnvPrinters []EnvPrinter) *WindsorEnvPrinter
NewWindsorEnvPrinter creates a new WindsorEnvPrinter instance
func (*WindsorEnvPrinter) GetEnvVars ¶
func (e *WindsorEnvPrinter) GetEnvVars() (map[string]string, error)
GetEnvVars 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.