config

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// InfraspecCloudTokenEnvVar is the environment variable name for the InfraSpec Cloud token
	InfraspecCloudTokenEnvVar = "INFRASPEC_CLOUD_TOKEN"
	// UseInfraspecVirtualCloudEnvVar enables InfraSpec Cloud virtual cloud mode when set to a truthy value.
	UseInfraspecVirtualCloudEnvVar = "USE_INFRASPEC_VIRTUAL_CLOUD"
	// ConfigFileName is the name of the user config file
	ConfigFileName = "config.yaml"
)

Variables

View Source
var (

	// Logging is the public interface to logging
	Logging = &logging{
		AtomicLogLevel:  zap.NewAtomicLevel(),
		DefaultLogLevel: zap.InfoLevel,
	}
)

Functions

func GetInfraspecCloudToken added in v0.1.0

func GetInfraspecCloudToken() (string, error)

GetInfraspecCloudToken returns the InfraSpec Cloud token from config or environment variable Environment variable takes precedence over config file

func GetUserConfigPath added in v0.1.0

func GetUserConfigPath() (string, error)

GetUserConfigPath returns the path to the user config file

func SaveUserConfig added in v0.1.0

func SaveUserConfig(userConfig *UserConfig) error

SaveUserConfig saves the user configuration to the config file

func UseInfraspecVirtualCloud added in v0.1.0

func UseInfraspecVirtualCloud() bool

UseInfraspecVirtualCloud returns true if InfraSpec Virtual Cloud is enabled.

Types

type CleanupConfig

type CleanupConfig struct {
	Automatic bool        `yaml:"automatic"`
	Timeout   int         `yaml:"timeout"`
	Strategy  string      `yaml:"strategy"` // eager or deferred
	Retries   RetryConfig `yaml:"retries"`
}

CleanupConfig defines cleanup behavior

type Config

type Config struct {
	Version         string           `yaml:"version"`
	Provider        string           `yaml:"provider"`
	StepDefinitions []StepDefinition `yaml:"step_definitions"`
	Functions       Functions        `yaml:"functions"`
	Cleanup         CleanupConfig    `yaml:"cleanup"`
	Retries         RetryConfig      `yaml:"retries"`
	Verbose         bool             `yaml:"verbose"` // Enable verbose mode
	Debug           bool             `yaml:"debug"`   // Enable debug mode
	Telemetry       TelemetryConfig  `yaml:"telemetry"`
	VirtualCloud    bool             `yaml:"virtual_cloud"`
	ParallelMode    bool             `yaml:"-"` // Runtime flag for parallel execution, not persisted
}

Config represents the main configuration structure

func Current added in v0.1.0

func Current() *Config

Current returns the most recently loaded configuration.

func Load

func Load(path string) (*Config, error)

Load reads and parses the configuration file

func LoadConfig added in v0.1.0

func LoadConfig(path string, virtualCloudFlag bool) (*Config, error)

LoadConfig loads configuration from disk, applying default values and overrides from environment variables and the virtual cloud CLI flag. If the config file is missing, only the defaults are used.

func (*Config) Validate

func (c *Config) Validate() error

Validate checks if the configuration is valid

type Functions

type Functions struct {
	RandomString RandomStringConfig `yaml:"random_string"`
}

Functions contains configuration for various utility functions

type RandomStringConfig

type RandomStringConfig struct {
	Length  int    `yaml:"length"`
	Charset string `yaml:"charset"`
}

RandomStringConfig configures random string generation

type RetryConfig

type RetryConfig struct {
	MaxAttempts     int           `yaml:"max_attempts"`
	Delay           time.Duration `yaml:"delay"`
	MaxDelay        time.Duration `yaml:"max_delay"`
	BackoffFactor   float64       `yaml:"backoff_factor"`
	RetryableErrors []string      `yaml:"retryable_errors"`
}

RetryConfig defines retry behavior

type StepDefinition

type StepDefinition struct {
	Pattern    string            `yaml:"pattern"`
	StoreAs    string            `yaml:"store_as,omitempty"`
	DataTable  bool              `yaml:"data_table,omitempty"`
	Parameters map[string]string `yaml:"parameters,omitempty"`
}

StepDefinition defines a mapping between Gherkin steps and actions

type TelemetryConfig

type TelemetryConfig struct {
	Enabled bool   `yaml:"enabled" json:"enabled"`
	UserID  string `yaml:"user_id" json:"user_id"`
}

TelemetryConfig holds telemetry-related configuration

func LoadTelemetryConfig

func LoadTelemetryConfig() TelemetryConfig

LoadTelemetryConfig loads telemetry configuration from environment and config

type UserConfig added in v0.1.0

type UserConfig struct {
	InfraspecCloudToken string `yaml:"infraspec_cloud_token,omitempty"`
}

UserConfig represents user-specific configuration

func LoadUserConfig added in v0.1.0

func LoadUserConfig() (*UserConfig, error)

LoadUserConfig loads the user configuration from the config file

Jump to

Keyboard shortcuts

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