tools

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Aug 4, 2026 License: MPL-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseToolsManager

type BaseToolsManager struct {
	// contains filtered or unexported fields
}

BaseToolsManager is the base implementation of the ToolsManager interface.

func NewToolsManager

func NewToolsManager(configHandler config.ConfigHandler, shell shell.Shell) *BaseToolsManager

NewToolsManager creates a new ToolsManager instance with the given config handler and shell.

func (*BaseToolsManager) Check

func (t *BaseToolsManager) Check() error

Check verifies every tool that may be required for any windsor codepath. Equivalent to CheckRequirements(AllRequirements()) and exists for backward compatibility with the explicit "check everything" command (`windsor check`) and any caller that has not been migrated to declare per-command requirements.

func (*BaseToolsManager) CheckAuth added in v0.9.0

func (t *BaseToolsManager) CheckAuth() error

CheckAuth verifies the operator has the cloud CLIs for in-use platforms and that their credentials resolve. Called from terraform-touching command paths (bootstrap/up/apply/ plan/destroy) and `windsor check` — never from `init` or `env`.

func (*BaseToolsManager) CheckRequirements added in v0.9.0

func (t *BaseToolsManager) CheckRequirements(reqs Requirements) error

CheckRequirements runs only the checks the caller has opted into via reqs, AND that the configHandler still gates on. The two-layer test (command-level need × project-level config) means an over-broad request from the command side is harmless — `windsor up` can safely request Terraform=true even on a context where terraform.enabled is false, because the config gate skips the actual binary check. Under-requesting is the failure mode worth guarding against: a missed Requirements field lets a stale tool reach the actual run.

AWS tool verification lives on CheckAuth, not here. CheckRequirements fires from many command paths including `windsor init` / `windsor env` — at those points the operator has no obligation to have the aws CLI installed OR to be authed. Both cloud-CLI presence and credential resolution belong to CheckAuth, which runs from bootstrap and from `windsor check`.

func (*BaseToolsManager) CheckTerraform added in v0.9.0

func (t *BaseToolsManager) CheckTerraform() error

CheckTerraform ensures Terraform or OpenTofu is available in the system's PATH using execLookPath. It checks for the configured driver command in the system's PATH and verifies its version. Returns nil if found and meets the minimum version requirement, else an error indicating it is not available or outdated. Exported (unlike the other check* methods) so callers that need Terraform unconditionally — e.g. the composer's standard module resolver, which shells out to `terraform init` to resolve git/registry-sourced modules regardless of terraform.enabled — can get the same missingToolError/outdatedToolError messages as CheckRequirements without going through its config-gated Terraform field.

func (*BaseToolsManager) GetTerraformCommand added in v0.9.0

func (t *BaseToolsManager) GetTerraformCommand() string

GetTerraformCommand returns the terraform command to use (terraform or tofu) based on configuration. Defaults to "terraform" if not specified in the root-level terraform config. Accepts case-insensitive driver values and "tofu" as an alias for "opentofu".

func (*BaseToolsManager) Install

func (t *BaseToolsManager) Install() error

Install installs the tools required by the project.

func (*BaseToolsManager) WriteManifest

func (t *BaseToolsManager) WriteManifest() error

WriteManifest writes the tools manifest to the project root. It should not overwrite existing manifest files, but update them appropriately.

type MockToolsManager

type MockToolsManager struct {
	WriteManifestFunc       func() error
	InstallFunc             func() error
	CheckFunc               func() error
	CheckRequirementsFunc   func(reqs Requirements) error
	CheckAuthFunc           func() error
	CheckTerraformFunc      func() error
	GetTerraformCommandFunc func() string
}

MockToolsManager is a mock implementation of the ToolsManager interface for testing purposes.

func NewMockToolsManager

func NewMockToolsManager() *MockToolsManager

NewMockToolsManager creates a new instance of MockToolsManager.

func (*MockToolsManager) Check

func (m *MockToolsManager) Check() error

Check calls the mock CheckFunc if set, otherwise returns nil.

func (*MockToolsManager) CheckAuth added in v0.9.0

func (m *MockToolsManager) CheckAuth() error

CheckAuth calls the mock CheckAuthFunc if set, otherwise returns nil.

func (*MockToolsManager) CheckRequirements added in v0.9.0

func (m *MockToolsManager) CheckRequirements(reqs Requirements) error

CheckRequirements calls the mock CheckRequirementsFunc when set, falls back to CheckFunc when only the legacy hook is configured (so existing tests keep working without rewrites), and otherwise returns nil. This mirrors the production aliasing where Check() routes through CheckRequirements(AllRequirements()).

func (*MockToolsManager) CheckTerraform added in v0.9.0

func (m *MockToolsManager) CheckTerraform() error

CheckTerraform calls the mock CheckTerraformFunc if set, otherwise returns nil.

func (*MockToolsManager) GetTerraformCommand added in v0.9.0

func (m *MockToolsManager) GetTerraformCommand() string

GetTerraformCommand calls the mock GetTerraformCommandFunc if set, otherwise returns "terraform"

func (*MockToolsManager) Install

func (m *MockToolsManager) Install() error

InstallTools calls the mock InstallToolsFunc if set, otherwise returns nil.

func (*MockToolsManager) WriteManifest

func (m *MockToolsManager) WriteManifest() error

WriteManifest calls the mock WriteManifestFunc if set, otherwise returns nil.

type Requirements added in v0.9.0

type Requirements struct {
	Docker    bool
	Colima    bool
	Terraform bool
	Secrets   bool
	Kubelogin bool
}

Requirements is the set of tool families a single command's codepath will actually exercise. Each field is opt-in: a command requests only what it will run, and the corresponding check still respects the configHandler gates (e.g. Docker=true only triggers a docker check when docker.enabled is set or workstation.runtime is a docker-family driver). Over-requesting is safe — checks no-op when the underlying config gate is off; under-requesting is the bug to avoid because it lets a stale tool slip through to the actual command.

func AllRequirements added in v0.9.0

func AllRequirements() Requirements

AllRequirements returns a Requirements with every field true. Used by `windsor check` (the explicit "verify my whole setup" command) and as the default for code paths that must preserve historical Check() behavior.

type ToolsManager

type ToolsManager interface {
	WriteManifest() error
	Install() error
	Check() error
	CheckRequirements(reqs Requirements) error
	CheckAuth() error
	CheckTerraform() error
	GetTerraformCommand() string
}

Jump to

Keyboard shortcuts

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