workstation

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 23, 2026 License: MPL-2.0 Imports: 15 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PreflightConfigureNetwork added in v0.9.0

func PreflightConfigureNetwork() error

PreflightConfigureNetwork gates 'windsor configure network' on platforms that need the process itself to be elevated. On unix the privileged steps each invoke per-op sudo (cached after the first prompt), so the process can start unprivileged and this returns nil.

func SetCanElevateNonInteractivelyForTest added in v0.9.0

func SetCanElevateNonInteractivelyForTest(fn func(shell.Shell) bool) func()

SetCanElevateNonInteractivelyForTest replaces the elevation probe with fn and returns a function that restores it. Tests on each OS use it to simulate either answer.

Types

type DeferredWorkItem added in v0.9.0

type DeferredWorkItem struct {
	Required bool
	Outcome  string
	Command  string
}

DeferredWorkItem is a step that Windsor skipped because it needs elevation that Windsor does not request. The end-of-run summary of cmd/up shows each item to the operator. A required item stopped the apply, so the operator runs the command and then 'windsor up' again. An optional item is work that the operator can do later without a new 'windsor up'.

type NetworkChange added in v0.9.0

type NetworkChange struct {
	Kind   string
	Detail string
}

NetworkChange is one host change from PendingNetworkChanges. Kind is host-route, vm-forward, or dns-resolver. Detail is the value, for example "192.168.5.0/24 via 192.168.5.10". Callers show the changes as aligned columns.

type Workstation

type Workstation struct {
	NetworkManager   network.NetworkManager
	VirtualMachine   virt.VirtualMachine
	ContainerRuntime virt.ContainerRuntime

	// DeferHostGuestSetup makes Up skip the guest, host route, and DNS setup. PrepareForUp sets it.
	DeferHostGuestSetup bool
	// contains filtered or unexported fields
}

Workstation manages workstation virtualization, networking, and SSH operations.

func NewWorkstation

func NewWorkstation(rt *runtime.Runtime, opts ...*Workstation) *Workstation

NewWorkstation returns a Workstation for rt. It uses the network manager, the VM, and the container runtime from opts when they are set. Prepare creates the ones that are not set. It panics when rt, its config handler, its shell, or its evaluator is nil.

func (*Workstation) ConfigureNetwork added in v0.9.0

func (w *Workstation) ConfigureNetwork(ctx context.Context, dnsAddressOverride string, showStatus bool) error

ConfigureNetwork configures the guest and the host route on colima, and then the DNS. It reads the addresses from the config, which windsor up saves to workstation.yaml. A dnsAddressOverride that is not empty replaces workstation.dns.address. It configures the DNS only when dns.domain and the DNS address are both set. When showStatus is true, it sends one status message for each step to the presenter. It does nothing when NetworkManager is nil.

func (*Workstation) DeferredWork added in v0.9.0

func (w *Workstation) DeferredWork() []DeferredWorkItem

DeferredWork returns the deferred work of the last Up, Down, or apply hook, or nil when there is none. Up and Down clear it when they start.

func (*Workstation) Down

func (w *Workstation) Down(ctx context.Context) error

Down removes the installed host network configuration, and then stops the container runtime and the VM. The revert runs first, so RevertGuest can reach the running VM. A revert failure is a warning. When Windsor cannot elevate without a prompt, it skips the revert and adds a DeferredWorkItem. Down keeps the workstation state, so 'windsor up' can start again.

func (*Workstation) FlushDNS added in v0.9.0

func (w *Workstation) FlushDNS(ctx context.Context) error

FlushDNS flushes the DNS cache when DNS is fully configured. It is a no-op when the network manager is absent or DNS domain/address are not set.

func (*Workstation) IsProvisioned added in v0.9.0

func (w *Workstation) IsProvisioned() (bool, error)

IsProvisioned reports whether 'windsor up' applied the workstation Terraform component of the context. It checks for <projectRoot>/.windsor/contexts/<context>/workstation.yaml. WriteState writes this file only after MakeApplyHook saves the Terraform outputs of the component. 'windsor configure network' uses it as a precondition. It returns false and no error when the file does not exist. It returns an error when it cannot get the project root or check the file.

func (*Workstation) MakeApplyHook added in v0.9.0

func (w *Workstation) MakeApplyHook() func(ctx context.Context, componentID string) (bool, error)

MakeApplyHook returns the onApply callback of the provisioner, or nil when DeferHostGuestSetup is false. After the workstation component, the callback saves its DNS address output and the workstation state. When the cluster needs a host route, it adds a required DeferredWorkItem and returns true to stop the stack. When the DNS resolver needs a change, it adds an optional DeferredWorkItem and the stack continues. The callback never prompts for sudo.

func (*Workstation) MakePostApplyHook added in v0.9.0

func (w *Workstation) MakePostApplyHook() func(ctx context.Context, componentID string) error

MakePostApplyHook returns the postApply callback of the provisioner, or nil when DeferHostGuestSetup is false. After the workstation component, the callback flushes the DNS cache when the DNS changed.

func (*Workstation) PendingNetworkChanges added in v0.9.0

func (w *Workstation) PendingNetworkChanges() []NetworkChange

PendingNetworkChanges returns the host changes that 'windsor configure network' would make for the context. It returns nil when nothing is pending or when NetworkManager is nil.

func (*Workstation) Prepare

func (w *Workstation) Prepare() error

Prepare creates the network manager, the VM, and the container runtime that the context needs and that are not set. Call it after the configuration is loaded.

func (*Workstation) PrepareForUp added in v0.9.0

func (w *Workstation) PrepareForUp(blueprint *blueprintv1alpha1.Blueprint)

PrepareForUp sets DeferHostGuestSetup to defer host/guest and DNS setup until after the "workstation" Terraform component is applied (via provisioner hook) when present and terraform.enabled is true. Call before Up() when Up will run Terraform with this blueprint.

func (*Workstation) RestoreClusterRoute added in v0.10.0

func (w *Workstation) RestoreClusterRoute(ctx context.Context) (bool, error)

RestoreClusterRoute makes sure that the host can reach a cluster that holds the Terraform state. It does nothing when DeferHostGuestSetup is false, when the backend is not kubernetes, or when the route is present. When Windsor can elevate without a prompt, it configures the guest and the host route and returns true. Otherwise it adds a required DeferredWorkItem and returns false, so the caller stops before Terraform runs. It never prompts for sudo.

func (*Workstation) RevertNetwork added in v0.9.0

func (w *Workstation) RevertNetwork(ctx context.Context, showStatus bool) error

RevertNetwork removes the host configuration that ConfigureNetwork installed. On colima it removes the guest forwarding and the host route. It always removes the DNS resolver entry. Each NetworkManager revert does nothing when its state is absent, so a partial configuration is safe to revert. When showStatus is true, it sends one status message for each step to the presenter. It does nothing when NetworkManager is nil.

func (*Workstation) Up

func (w *Workstation) Up(ctx context.Context) error

Up sets NO_CACHE, starts the VM and the container runtime, and configures the network. It configures the guest, the host route, and the DNS only when DeferHostGuestSetup is false. Otherwise MakeApplyHook and 'windsor configure network' do that work. Call Prepare before Up.

func (*Workstation) WriteState added in v0.9.0

func (w *Workstation) WriteState() error

WriteState saves the workstation keys of the config to .windsor/contexts/<context>/workstation.yaml.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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