controller

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2025 License: MPL-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseController

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

BaseController implements the Controller interface with default component management It provides concrete implementations of all Controller methods and manages component lifecycle

func NewController

func NewController(injector di.Injector) *BaseController

NewController creates a new BaseController instance with the provided dependency injector It initializes the controller with default component constructors

func (*BaseController) CreateComponents added in v0.5.7

func (c *BaseController) CreateComponents() error

CreateComponents initializes all required components based on current requirements It creates components in a specific order to ensure proper dependency resolution

func (*BaseController) InitializeComponents

func (c *BaseController) InitializeComponents() error

InitializeComponents performs initialization of all created components It initializes each component in the correct order to maintain dependencies

func (*BaseController) InitializeWithRequirements added in v0.5.7

func (c *BaseController) InitializeWithRequirements(req Requirements) error

InitializeWithRequirements sets requirements and initializes components in one step It provides a standard initialization sequence used by commands

func (*BaseController) ResolveAllEnvPrinters

func (c *BaseController) ResolveAllEnvPrinters() []env.EnvPrinter

ResolveAllEnvPrinters returns all configured environment printers It retrieves all environment printers from the dependency injection container

func (*BaseController) ResolveAllGenerators

func (c *BaseController) ResolveAllGenerators() []generators.Generator

ResolveAllGenerators returns all configured code generators It retrieves all generators from the dependency injection container

func (*BaseController) ResolveAllSecretsProviders added in v0.5.0

func (c *BaseController) ResolveAllSecretsProviders() []secrets.SecretsProvider

ResolveAllSecretsProviders returns all configured secrets providers It retrieves all secrets providers from the dependency injection container

func (*BaseController) ResolveAllServices

func (c *BaseController) ResolveAllServices() []services.Service

ResolveAllServices returns all configured services It retrieves all services from the dependency injection container

func (*BaseController) ResolveBlueprintHandler

func (c *BaseController) ResolveBlueprintHandler() blueprint.BlueprintHandler

ResolveBlueprintHandler returns the blueprint management component It retrieves the blueprint handler from the dependency injection container

func (*BaseController) ResolveConfigHandler

func (c *BaseController) ResolveConfigHandler() config.ConfigHandler

ResolveConfigHandler returns the configuration management component It retrieves the config handler from the dependency injection container

func (*BaseController) ResolveContainerRuntime

func (c *BaseController) ResolveContainerRuntime() virt.ContainerRuntime

ResolveContainerRuntime returns the container runtime component It retrieves the container runtime from the dependency injection container

func (*BaseController) ResolveEnvPrinter

func (c *BaseController) ResolveEnvPrinter(name string) env.EnvPrinter

ResolveEnvPrinter returns a specific environment printer by name It retrieves the requested environment printer from the dependency injection container

func (*BaseController) ResolveInjector

func (c *BaseController) ResolveInjector() di.Injector

ResolveInjector returns the dependency injection container It provides access to the injector for component resolution

func (*BaseController) ResolveNetworkManager

func (c *BaseController) ResolveNetworkManager() network.NetworkManager

ResolveNetworkManager returns the network management component It retrieves the network manager from the dependency injection container

func (*BaseController) ResolveSecureShell

func (c *BaseController) ResolveSecureShell() sh.Shell

ResolveSecureShell returns the secure shell component It retrieves the secure shell from the dependency injection container

func (*BaseController) ResolveService

func (c *BaseController) ResolveService(name string) services.Service

ResolveService returns a specific service by name It retrieves the requested service from the dependency injection container

func (*BaseController) ResolveShell

func (c *BaseController) ResolveShell() sh.Shell

ResolveShell returns the default shell component It retrieves the shell from the dependency injection container

func (*BaseController) ResolveStack

func (c *BaseController) ResolveStack() stack.Stack

ResolveStack returns the stack management component It retrieves the stack from the dependency injection container

func (*BaseController) ResolveToolsManager added in v0.3.0

func (c *BaseController) ResolveToolsManager() tools.ToolsManager

ResolveToolsManager returns the tools management component It retrieves the tools manager from the dependency injection container

func (*BaseController) ResolveVirtualMachine

func (c *BaseController) ResolveVirtualMachine() virt.VirtualMachine

ResolveVirtualMachine returns the virtual machine component It retrieves the virtual machine from the dependency injection container

func (*BaseController) SetEnvironmentVariables added in v0.5.4

func (c *BaseController) SetEnvironmentVariables() error

SetEnvironmentVariables configures the environment for all components It sets environment variables from all configured environment printers

func (*BaseController) SetRequirements added in v0.5.7

func (c *BaseController) SetRequirements(req Requirements)

SetRequirements configures the controller with specific operational requirements It stores the requirements for use during component creation and initialization

func (*BaseController) WriteConfigurationFiles

func (c *BaseController) WriteConfigurationFiles() error

WriteConfigurationFiles writes all component configurations to disk It handles configuration for tools, blueprints, services, and infrastructure components

type ComponentConstructors added in v0.5.7

type ComponentConstructors struct {
	NewConfigHandler func(di.Injector) config.ConfigHandler
	NewShell         func(di.Injector) sh.Shell
	NewSecureShell   func(di.Injector) sh.Shell

	NewGitGenerator       func(di.Injector) generators.Generator
	NewBlueprintHandler   func(di.Injector) blueprint.BlueprintHandler
	NewTerraformGenerator func(di.Injector) generators.Generator
	NewKustomizeGenerator func(di.Injector) generators.Generator
	NewToolsManager       func(di.Injector) tools.ToolsManager

	NewAwsEnvPrinter       func(di.Injector) env.EnvPrinter
	NewAzureEnvPrinter     func(di.Injector) env.EnvPrinter
	NewDockerEnvPrinter    func(di.Injector) env.EnvPrinter
	NewKubeEnvPrinter      func(di.Injector) env.EnvPrinter
	NewOmniEnvPrinter      func(di.Injector) env.EnvPrinter
	NewTalosEnvPrinter     func(di.Injector) env.EnvPrinter
	NewTerraformEnvPrinter func(di.Injector) env.EnvPrinter
	NewWindsorEnvPrinter   func(di.Injector) env.EnvPrinter

	NewDNSService           func(di.Injector) services.Service
	NewGitLivereloadService func(di.Injector) services.Service
	NewLocalstackService    func(di.Injector) services.Service
	NewRegistryService      func(di.Injector) services.Service
	NewTalosService         func(di.Injector, string) services.Service

	NewSSHClient                func() *ssh.SSHClient
	NewColimaVirt               func(di.Injector) virt.VirtualMachine
	NewColimaNetworkManager     func(di.Injector) network.NetworkManager
	NewBaseNetworkManager       func(di.Injector) network.NetworkManager
	NewDockerVirt               func(di.Injector) virt.ContainerRuntime
	NewNetworkInterfaceProvider func() network.NetworkInterfaceProvider

	NewSopsSecretsProvider           func(string, di.Injector) secrets.SecretsProvider
	NewOnePasswordSDKSecretsProvider func(secretsConfigType.OnePasswordVault, di.Injector) secrets.SecretsProvider
	NewOnePasswordCLISecretsProvider func(secretsConfigType.OnePasswordVault, di.Injector) secrets.SecretsProvider

	NewWindsorStack func(di.Injector) stack.Stack
}

ComponentConstructors contains factory functions for creating all Windsor CLI components Each field represents a constructor function for a specific component type

func NewDefaultConstructors added in v0.5.7

func NewDefaultConstructors() ComponentConstructors

NewDefaultConstructors creates a ComponentConstructors instance with default implementations It provides factory functions for all Windsor CLI components

func NewMockConstructors added in v0.5.7

func NewMockConstructors() ComponentConstructors

NewMockConstructors returns a ComponentConstructors with all factory functions set to return mocks useful for testing

type Controller

type Controller interface {
	SetRequirements(req Requirements)
	CreateComponents() error
	InitializeComponents() error
	InitializeWithRequirements(req Requirements) error
	ResolveInjector() di.Injector
	ResolveConfigHandler() config.ConfigHandler
	ResolveAllSecretsProviders() []secrets.SecretsProvider
	ResolveEnvPrinter(name string) env.EnvPrinter
	ResolveAllEnvPrinters() []env.EnvPrinter
	ResolveShell() sh.Shell
	ResolveSecureShell() sh.Shell
	ResolveNetworkManager() network.NetworkManager
	ResolveToolsManager() tools.ToolsManager
	ResolveBlueprintHandler() blueprint.BlueprintHandler
	ResolveService(name string) services.Service
	ResolveAllServices() []services.Service
	ResolveVirtualMachine() virt.VirtualMachine
	ResolveContainerRuntime() virt.ContainerRuntime
	ResolveStack() stack.Stack
	ResolveAllGenerators() []generators.Generator
	WriteConfigurationFiles() error
	SetEnvironmentVariables() error
}

Controller defines the interface for managing Windsor CLI components and operations. It provides methods for component initialization, dependency resolution, and environment management.

type MockController

type MockController struct {
	BaseController
	SetRequirementsFunc            func(Requirements)
	InitializeComponentsFunc       func() error
	CreateComponentsFunc           func() error
	InitializeWithRequirementsFunc func(Requirements) error
	ResolveInjectorFunc            func() di.Injector
	ResolveConfigHandlerFunc       func() config.ConfigHandler
	ResolveEnvPrinterFunc          func(name string) env.EnvPrinter
	ResolveAllEnvPrintersFunc      func() []env.EnvPrinter
	ResolveShellFunc               func() shell.Shell
	ResolveSecureShellFunc         func() shell.Shell
	ResolveToolsManagerFunc        func() tools.ToolsManager
	ResolveNetworkManagerFunc      func() network.NetworkManager
	ResolveServiceFunc             func(name string) services.Service
	ResolveAllServicesFunc         func() []services.Service
	ResolveVirtualMachineFunc      func() virt.VirtualMachine
	ResolveContainerRuntimeFunc    func() virt.ContainerRuntime
	ResolveAllGeneratorsFunc       func() []generators.Generator
	ResolveStackFunc               func() stack.Stack
	ResolveBlueprintHandlerFunc    func() blueprint.BlueprintHandler
	ResolveAllSecretsProvidersFunc func() []secrets.SecretsProvider
	WriteConfigurationFilesFunc    func() error
	SetEnvironmentVariablesFunc    func() error
}

MockController is a mock implementation of the Controller interface

func NewMockController

func NewMockController(injector ...di.Injector) *MockController

NewMockController creates a new MockController with an optional injector

func (*MockController) CreateComponents added in v0.5.7

func (m *MockController) CreateComponents() error

CreateComponents implements the Controller interface

func (*MockController) InitializeComponents

func (m *MockController) InitializeComponents() error

InitializeComponents implements the Controller interface

func (*MockController) InitializeWithRequirements added in v0.5.7

func (m *MockController) InitializeWithRequirements(req Requirements) error

InitializeWithRequirements implements the Controller interface

func (*MockController) ResolveAllEnvPrinters

func (m *MockController) ResolveAllEnvPrinters() []env.EnvPrinter

ResolveAllEnvPrinters implements the Controller interface

func (*MockController) ResolveAllGenerators

func (m *MockController) ResolveAllGenerators() []generators.Generator

ResolveAllGenerators implements the Controller interface

func (*MockController) ResolveAllSecretsProviders added in v0.5.0

func (m *MockController) ResolveAllSecretsProviders() []secrets.SecretsProvider

ResolveAllSecretsProviders implements the Controller interface

func (*MockController) ResolveAllServices

func (m *MockController) ResolveAllServices() []services.Service

ResolveAllServices implements the Controller interface

func (*MockController) ResolveBlueprintHandler added in v0.3.0

func (m *MockController) ResolveBlueprintHandler() blueprint.BlueprintHandler

ResolveBlueprintHandler implements the Controller interface

func (*MockController) ResolveConfigHandler

func (m *MockController) ResolveConfigHandler() config.ConfigHandler

ResolveConfigHandler implements the Controller interface

func (*MockController) ResolveContainerRuntime

func (m *MockController) ResolveContainerRuntime() virt.ContainerRuntime

ResolveContainerRuntime implements the Controller interface

func (*MockController) ResolveEnvPrinter

func (m *MockController) ResolveEnvPrinter(name string) env.EnvPrinter

ResolveEnvPrinter implements the Controller interface

func (*MockController) ResolveInjector

func (m *MockController) ResolveInjector() di.Injector

ResolveInjector implements the Controller interface

func (*MockController) ResolveNetworkManager

func (m *MockController) ResolveNetworkManager() network.NetworkManager

ResolveNetworkManager implements the Controller interface

func (*MockController) ResolveSecureShell

func (m *MockController) ResolveSecureShell() shell.Shell

ResolveSecureShell implements the Controller interface

func (*MockController) ResolveService

func (m *MockController) ResolveService(name string) services.Service

ResolveService implements the Controller interface

func (*MockController) ResolveShell

func (m *MockController) ResolveShell() shell.Shell

ResolveShell implements the Controller interface

func (*MockController) ResolveStack

func (m *MockController) ResolveStack() stack.Stack

ResolveStack implements the Controller interface

func (*MockController) ResolveToolsManager added in v0.3.0

func (m *MockController) ResolveToolsManager() tools.ToolsManager

ResolveToolsManager implements the Controller interface

func (*MockController) ResolveVirtualMachine

func (m *MockController) ResolveVirtualMachine() virt.VirtualMachine

ResolveVirtualMachine implements the Controller interface

func (*MockController) SetEnvironmentVariables added in v0.5.4

func (m *MockController) SetEnvironmentVariables() error

SetEnvironmentVariables implements the Controller interface

func (*MockController) SetRequirements added in v0.5.7

func (m *MockController) SetRequirements(req Requirements)

func (*MockController) WriteConfigurationFiles

func (m *MockController) WriteConfigurationFiles() error

WriteConfigurationFiles implements the Controller interface

type Requirements added in v0.5.7

type Requirements struct {
	// Core requirements (most commands need these)
	Trust        bool // Requires being in a trusted directory
	ConfigLoaded bool // Requires config to be loaded

	// Environment requirements
	Env bool // Needs access to environment variables

	// Security requirements
	Secrets bool // Needs to decrypt/access secrets

	// Infrastructure requirements
	VM         bool // Needs virtual machine capabilities
	Containers bool // Needs container runtime capabilities
	Network    bool // Needs network management

	// Service requirements
	Services bool // Needs service management

	// Project requirements
	Tools      bool // Needs git, terraform, etc.
	Blueprint  bool // Needs blueprint handling
	Generators bool // Needs code generation
	Stack      bool // Needs stack components

	// Command info for context-specific decisions
	CommandName string          // Name of the command
	Flags       map[string]bool // Important flags that affect initialization
	Reset       bool            // Whether to reset/overwrite existing files
}

Requirements defines the operational requirements for the controller It specifies which components and capabilities are needed for a given operation

Jump to

Keyboard shortcuts

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