config

package
v0.8.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = v1alpha1.Context{
	Provider:  ptrString("none"),
	Terraform: commonTerraformConfig.Copy(),
	Cluster:   commonClusterConfig_Minimal.Copy(),
}

DefaultConfig returns the default configuration for non-dev contexts Uses minimal config since non-dev contexts default to provider "none" Includes cluster.enabled=true for provider-specific contexts (aws, azure)

View Source
var DefaultConfig_Full = v1alpha1.Context{
	Provider:    ptrString("generic"),
	Environment: map[string]string{},
	Docker:      commonDockerConfig.Copy(),
	Git:         commonGitConfig.Copy(),
	Terraform:   commonTerraformConfig.Copy(),
	Cluster:     commonClusterConfig_NoHostPorts.Copy(),
	Network: &network.NetworkConfig{
		CIDRBlock: ptrString(constants.DefaultNetworkCIDR),
		LoadBalancerIPs: &struct {
			Start *string `yaml:"start,omitempty"`
			End   *string `yaml:"end,omitempty"`
		}{
			Start: ptrString("10.5.1.1"),
			End:   ptrString("10.5.1.10"),
		},
	},
	DNS: &dns.DNSConfig{
		Enabled: ptrBool(true),
		Domain:  ptrString("test"),
		Forward: []string{
			"10.5.1.1",
		},
	},
}
View Source
var DefaultConfig_Localhost = v1alpha1.Context{
	Provider:    ptrString("generic"),
	Environment: map[string]string{},
	Docker:      commonDockerConfig.Copy(),
	Git:         commonGitConfig.Copy(),
	Terraform:   commonTerraformConfig.Copy(),
	Cluster:     commonClusterConfig_WithHostPorts.Copy(),
	Network: &network.NetworkConfig{
		CIDRBlock: ptrString(constants.DefaultNetworkCIDR),
	},
	DNS: &dns.DNSConfig{
		Enabled: ptrBool(true),
		Domain:  ptrString("test"),
		Forward: []string{
			"10.5.0.1:8053",
		},
	},
}

Functions

This section is empty.

Types

type ConfigHandler

type ConfigHandler interface {
	LoadConfig() error
	LoadConfigString(content string) error
	GetString(key string, defaultValue ...string) string
	GetInt(key string, defaultValue ...int) int
	GetBool(key string, defaultValue ...bool) bool
	GetStringSlice(key string, defaultValue ...[]string) []string
	GetStringMap(key string, defaultValue ...map[string]string) map[string]string
	Set(key string, value any) error
	Get(key string) any
	SaveConfig(overwrite ...bool) error
	SetDefault(context v1alpha1.Context) error
	GetConfig() *v1alpha1.Context
	GetContext() string
	IsDevMode(contextName string) bool
	SetContext(context string) error
	GetConfigRoot() (string, error)
	GetWindsorScratchPath() (string, error)
	Clean() error
	IsLoaded() bool
	GenerateContextID() error
	LoadSchema(schemaPath string) error
	LoadSchemaFromBytes(schemaContent []byte) error
	GetContextValues() (map[string]any, error)
}

func NewConfigHandler

func NewConfigHandler(shell shell.Shell) ConfigHandler

NewConfigHandler creates a new ConfigHandler instance with default context configuration.

type MockConfigHandler

type MockConfigHandler struct {
	LoadConfigFunc            func() error
	LoadConfigStringFunc      func(content string) error
	IsLoadedFunc              func() bool
	GetStringFunc             func(key string, defaultValue ...string) string
	GetIntFunc                func(key string, defaultValue ...int) int
	GetBoolFunc               func(key string, defaultValue ...bool) bool
	GetStringSliceFunc        func(key string, defaultValue ...[]string) []string
	GetStringMapFunc          func(key string, defaultValue ...map[string]string) map[string]string
	SetFunc                   func(key string, value any) error
	SaveConfigFunc            func(overwrite ...bool) error
	GetFunc                   func(key string) any
	SetDefaultFunc            func(context v1alpha1.Context) error
	GetConfigFunc             func() *v1alpha1.Context
	GetContextFunc            func() string
	IsDevModeFunc             func(contextName string) bool
	SetContextFunc            func(context string) error
	GetConfigRootFunc         func() (string, error)
	GetWindsorScratchPathFunc func() (string, error)
	CleanFunc                 func() error
	GenerateContextIDFunc     func() error
	LoadSchemaFunc            func(schemaPath string) error
	LoadSchemaFromBytesFunc   func(schemaContent []byte) error
	GetContextValuesFunc      func() (map[string]any, error)
}

MockConfigHandler is a mock implementation of the ConfigHandler interface

func NewMockConfigHandler

func NewMockConfigHandler() *MockConfigHandler

NewMockConfigHandler is a constructor for MockConfigHandler

func (*MockConfigHandler) Clean

func (m *MockConfigHandler) Clean() error

Clean calls the mock CleanFunc if set, otherwise returns nil

func (*MockConfigHandler) GenerateContextID

func (m *MockConfigHandler) GenerateContextID() error

GenerateContextID calls the mock GenerateContextIDFunc if set, otherwise returns nil

func (*MockConfigHandler) Get

func (m *MockConfigHandler) Get(key string) any

Get calls the mock GetFunc if set, otherwise returns a reasonable default value

func (*MockConfigHandler) GetBool

func (m *MockConfigHandler) GetBool(key string, defaultValue ...bool) bool

GetBool calls the mock GetBoolFunc if set, otherwise returns a reasonable default bool

func (*MockConfigHandler) GetConfig

func (m *MockConfigHandler) GetConfig() *v1alpha1.Context

GetConfig calls the mock GetConfigFunc if set, otherwise returns a reasonable default Context

func (*MockConfigHandler) GetConfigRoot

func (m *MockConfigHandler) GetConfigRoot() (string, error)

GetConfigRoot calls the mock GetConfigRootFunc if set, otherwise returns a reasonable default string

func (*MockConfigHandler) GetContext

func (m *MockConfigHandler) GetContext() string

GetContext calls the mock GetContextFunc if set, otherwise returns a reasonable default string

func (*MockConfigHandler) GetContextValues

func (m *MockConfigHandler) GetContextValues() (map[string]any, error)

GetContextValues calls the mock GetContextValuesFunc if set, otherwise returns an error

func (*MockConfigHandler) GetInt

func (m *MockConfigHandler) GetInt(key string, defaultValue ...int) int

GetInt calls the mock GetIntFunc if set, otherwise returns a reasonable default int

func (*MockConfigHandler) GetString

func (m *MockConfigHandler) GetString(key string, defaultValue ...string) string

GetString calls the mock GetStringFunc if set, otherwise returns a reasonable default string

func (*MockConfigHandler) GetStringMap

func (m *MockConfigHandler) GetStringMap(key string, defaultValue ...map[string]string) map[string]string

GetStringMap calls the mock GetStringMapFunc if set, otherwise returns a reasonable default map of strings

func (*MockConfigHandler) GetStringSlice

func (m *MockConfigHandler) GetStringSlice(key string, defaultValue ...[]string) []string

GetStringSlice calls the mock GetStringSliceFunc if set, otherwise returns a reasonable default slice of strings

func (*MockConfigHandler) GetWindsorScratchPath

func (m *MockConfigHandler) GetWindsorScratchPath() (string, error)

GetWindsorScratchPath calls the mock GetWindsorScratchPathFunc if set, otherwise returns a reasonable default string

func (*MockConfigHandler) IsDevMode

func (m *MockConfigHandler) IsDevMode(contextName string) bool

IsDevMode calls the mock IsDevModeFunc if set, otherwise returns default dev mode logic

func (*MockConfigHandler) IsLoaded

func (m *MockConfigHandler) IsLoaded() bool

IsLoaded calls the mock IsLoadedFunc if set, otherwise returns false

func (*MockConfigHandler) LoadConfig

func (m *MockConfigHandler) LoadConfig() error

LoadConfig calls the mock LoadConfigFunc if set, otherwise returns nil

func (*MockConfigHandler) LoadConfigString

func (m *MockConfigHandler) LoadConfigString(content string) error

LoadConfigString calls the mock LoadConfigStringFunc if set, otherwise returns nil

func (*MockConfigHandler) LoadSchema

func (m *MockConfigHandler) LoadSchema(schemaPath string) error

LoadSchema calls the mock LoadSchemaFunc if set, otherwise returns an error

func (*MockConfigHandler) LoadSchemaFromBytes

func (m *MockConfigHandler) LoadSchemaFromBytes(schemaContent []byte) error

LoadSchemaFromBytes calls the mock LoadSchemaFromBytesFunc if set, otherwise returns an error

func (*MockConfigHandler) SaveConfig

func (m *MockConfigHandler) SaveConfig(overwrite ...bool) error

SaveConfig calls the SaveConfigFunc if set, otherwise returns nil

func (*MockConfigHandler) Set

func (m *MockConfigHandler) Set(key string, value any) error

Set calls the mock SetFunc if set, otherwise returns nil

func (*MockConfigHandler) SetContext

func (m *MockConfigHandler) SetContext(context string) error

SetContext calls the mock SetContextFunc if set, otherwise returns nil

func (*MockConfigHandler) SetDefault

func (m *MockConfigHandler) SetDefault(context v1alpha1.Context) error

SetDefault calls the mock SetDefaultFunc if set, otherwise does nothing

type SchemaValidationResult

type SchemaValidationResult struct {
	Valid    bool           `json:"valid"`
	Errors   []string       `json:"errors,omitempty"`
	Defaults map[string]any `json:"defaults,omitempty"`
}

SchemaValidationResult contains validation results and extracted defaults

type SchemaValidator

type SchemaValidator struct {
	Shims  *Shims
	Schema map[string]any
	// contains filtered or unexported fields
}

SchemaValidator handles Windsor blueprint schema validation

func NewSchemaValidator

func NewSchemaValidator(shell shell.Shell) *SchemaValidator

NewSchemaValidator creates a new schema validator instance

func (*SchemaValidator) GetSchemaDefaults

func (sv *SchemaValidator) GetSchemaDefaults() (map[string]any, error)

GetSchemaDefaults extracts default values from the loaded schema Returns defaults as a map suitable for merging with user values

func (*SchemaValidator) LoadSchema

func (sv *SchemaValidator) LoadSchema(schemaPath string) error

LoadSchema loads the schema.yaml file from the specified directory Returns error if schema file doesn't exist or is invalid

func (*SchemaValidator) LoadSchemaFromBytes

func (sv *SchemaValidator) LoadSchemaFromBytes(schemaContent []byte) error

LoadSchemaFromBytes loads schema directly from byte content Returns error if schema content is invalid

func (*SchemaValidator) Validate

func (sv *SchemaValidator) Validate(values map[string]any) (*SchemaValidationResult, error)

Validate validates user values against the loaded schema Returns validation result with errors and defaults

type Shims

type Shims struct {
	ReadFile          func(string) ([]byte, error)
	WriteFile         func(string, []byte, os.FileMode) error
	RemoveAll         func(string) error
	Getenv            func(string) string
	Setenv            func(string, string) error
	Stat              func(string) (os.FileInfo, error)
	MkdirAll          func(string, os.FileMode) error
	YamlMarshal       func(any) ([]byte, error)
	YamlUnmarshal     func([]byte, any) error
	CryptoRandRead    func([]byte) (int, error)
	RegexpMatchString func(pattern, s string) (bool, error)
}

Shims provides mockable wrappers around system and runtime functions

func NewShims

func NewShims() *Shims

NewShims creates a new Shims instance with default implementations

Jump to

Keyboard shortcuts

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