env

package
v0.53.2 Latest Latest
Warning

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

Go to latest
Published: Dec 11, 2025 License: MIT Imports: 58 Imported by: 1

Documentation

Index

Constants

View Source
const (
	DefaultAccessKeyID     = "gosoline"
	DefaultSecretAccessKey = "gosoline"
	DefaultToken           = ""
)
View Source
const (
	RunnerTypeLocal  = "local"
	RunnerTypeRemote = "remote"
)
View Source
const (
	ComponentLocalstack = "localstack"
)
View Source
const RunnerTypeExternal = "external"

Variables

This section is empty.

Functions

func GetDefaultAwsSdkConfig

func GetDefaultAwsSdkConfig() (aws.Config, error)

func GetDefaultStaticCredentials

func GetDefaultStaticCredentials() credentials.StaticCredentialsProvider

func UnmarshalSettings added in v0.15.4

func UnmarshalSettings(config cfg.Config, settings any, typ string, name string) error

Types

type AutoDetectSettings

type AutoDetectSettings struct {
	Enabled        bool     `cfg:"enabled" default:"true"`
	SkipComponents []string `cfg:"skip_components"`
}

type ChannelRecords added in v0.26.1

type ChannelRecords []LogRecord

func (ChannelRecords) Filter added in v0.26.1

func (logs ChannelRecords) Filter(condition func(LogRecord) bool) ChannelRecords

type Component

type Component interface {
	SetT(t *testing.T)
}

type ComponentAddressAware

type ComponentAddressAware interface {
	Address() string
}

type ComponentBaseSettings

type ComponentBaseSettings struct {
	Name string `cfg:"name" default:"default"`
	Type string `cfg:"type" validate:"required"`
}

func (*ComponentBaseSettings) GetName

func (c *ComponentBaseSettings) GetName() string

func (*ComponentBaseSettings) GetType

func (c *ComponentBaseSettings) GetType() string

func (*ComponentBaseSettings) SetName

func (c *ComponentBaseSettings) SetName(name string)

func (*ComponentBaseSettings) SetType

func (c *ComponentBaseSettings) SetType(typ string)

type ComponentBaseSettingsAware

type ComponentBaseSettingsAware interface {
	GetName() string
	GetType() string
	SetName(name string)
	SetType(typ string)
}

type ComponentCfgOptionAware

type ComponentCfgOptionAware interface {
	CfgOptions() []cfg.Option
}

type ComponentContainerDescription added in v0.52.0

type ComponentContainerDescription struct {
	ContainerConfig  *ContainerConfig
	HealthCheck      ComponentHealthCheck
	ShutdownCallback ComponentShutdownCallback
}

type ComponentContainerDescriptions added in v0.52.0

type ComponentContainerDescriptions map[string]*ComponentContainerDescription

type ComponentContainerSettings

type ComponentContainerSettings struct {
	Image ContainerImageSettings `cfg:"image"`
	Tmpfs []TmpfsSettings        `cfg:"tmpfs"`
}

type ComponentHealthCheck

type ComponentHealthCheck func(container *Container) error

type ComponentOption

type ComponentOption func(componentConfigManger *ComponentsConfigManager) error

type ComponentShutdownCallback

type ComponentShutdownCallback func(container *Container) func() error

type ComponentsConfigManager

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

func NewComponentsConfigManager

func NewComponentsConfigManager(config cfg.GosoConf) (*ComponentsConfigManager, error)

func (*ComponentsConfigManager) Add

func (m *ComponentsConfigManager) Add(settings any) error

func (*ComponentsConfigManager) GetAllSettings

func (m *ComponentsConfigManager) GetAllSettings() ([]ComponentBaseSettingsAware, error)

func (*ComponentsConfigManager) Has

func (m *ComponentsConfigManager) Has(typ string, name string) (bool, error)

func (*ComponentsConfigManager) HasType

func (m *ComponentsConfigManager) HasType(typ string) (bool, error)

func (*ComponentsConfigManager) List

func (m *ComponentsConfigManager) List() (map[string]map[string]any, error)

func (*ComponentsConfigManager) ShouldAutoDetect

func (m *ComponentsConfigManager) ShouldAutoDetect(typ string) bool

type ComponentsContainer

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

func NewComponentsContainer

func NewComponentsContainer() *ComponentsContainer

func (*ComponentsContainer) Add

func (c *ComponentsContainer) Add(typ string, name string, component Component)

func (*ComponentsContainer) Get

func (c *ComponentsContainer) Get(componentType string, name string) (Component, error)

func (*ComponentsContainer) GetAll

func (c *ComponentsContainer) GetAll() []Component

func (*ComponentsContainer) GetCfgOptions

func (c *ComponentsContainer) GetCfgOptions() []cfg.Option

type ConfigOption

type ConfigOption func(config cfg.GosoConf) error

type Container added in v0.52.0

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

type ContainerBinding added in v0.52.0

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

type ContainerBindingSettings

type ContainerBindingSettings struct {
	Host string `cfg:"host" default:"127.0.0.1"`
	Port int    `cfg:"port" default:"0"`
}

type ContainerConfig added in v0.52.0

type ContainerConfig struct {
	RunnerType   string
	Hostname     string
	ExternalHost string // Host address for external containers (used by external runner)
	Auth         authSettings
	Repository   string
	Tmpfs        []TmpfsSettings
	Tag          string
	Env          map[string]string
	Cmd          []string
	PortBindings PortBindings
	ExposedPorts []string
}

func (ContainerConfig) String added in v0.52.0

func (c ContainerConfig) String() string

type ContainerImageSettings added in v0.15.4

type ContainerImageSettings struct {
	Auth       authSettings `cfg:"auth"`
	Repository string       `cfg:"repository"`
	Tag        string       `cfg:"tag"`
}

type ContainerManager added in v0.52.0

type ContainerManager interface {
	RunContainers(ctx context.Context, skeletons []*componentSkeleton) error
	Stop(ctx context.Context) error
}

func NewContainerManager added in v0.52.0

func NewContainerManager(config cfg.Config, logger log.Logger, testName string) (ContainerManager, error)

type ContainerManagerSettings added in v0.52.0

type ContainerManagerSettings struct {
	RunnerType  string              `cfg:"runner_type"  default:"local"`
	NamePrefix  string              `cfg:"name_prefix"  default:"goso"`
	HealthCheck HealthCheckSettings `cfg:"health_check"`
	ExpireAfter time.Duration       `cfg:"expire_after" default:"5m"`
}

type ContainerRefreshInput added in v0.52.0

type ContainerRefreshInput struct {
	PoolId   string        `json:"pool_id"`
	TestId   string        `json:"test_id"`
	Duration time.Duration `json:"duration"`
}

type ContainerRequest added in v0.52.0

type ContainerRequest struct {
	TestName             string
	ComponentType        string
	ComponentName        string
	ContainerName        string
	ContainerDescription *ComponentContainerDescription
	ExpireAfter          time.Duration
}

type ContainerRunner added in v0.52.0

type ContainerRunner interface {
	RunContainer(ctx context.Context, request ContainerRequest) (*Container, error)
	Stop(ctx context.Context) error
}

func NewContainerRunnerExternal added in v0.53.2

func NewContainerRunnerExternal(_ cfg.Config, logger log.Logger, _ *ContainerManagerSettings) (ContainerRunner, error)

NewContainerRunnerExternal creates a runner that connects to external (pre-existing) containers rather than starting new ones. This is useful for CI environments where containers are provided as external services.

func NewContainerRunnerLocal added in v0.52.0

func NewContainerRunnerLocal(config cfg.Config, logger log.Logger, managerSettings *ContainerManagerSettings) (ContainerRunner, error)

func NewContainerRunnerRemote added in v0.52.0

func NewContainerRunnerRemote(config cfg.Config, logger log.Logger, managerSettings *ContainerManagerSettings) (ContainerRunner, error)

type ContainerRunnerLocalSettings added in v0.52.0

type ContainerRunnerLocalSettings struct {
	Endpoint string       `cfg:"endpoint"`
	Auth     authSettings `cfg:"auth"`
}

type ContainerRunnerRemoteHttpClientSettings added in v0.52.0

type ContainerRunnerRemoteHttpClientSettings struct {
	Timeout       time.Duration `cfg:"timeout"     default:"30s"`
	RetryCount    int           `cfg:"retry_count" default:"32"`
	RetryWaitTime time.Duration `cfg:"retry_wait"  default:"3s"`
}

type ContainerRunnerRemoteSettings added in v0.52.0

type ContainerRunnerRemoteSettings struct {
	Endpoint   string                                  `cfg:"endpoint"    default:"http://localhost:8890"`
	PoolId     string                                  `cfg:"pool_id"`
	HttpClient ContainerRunnerRemoteHttpClientSettings `cfg:"http_client"`
}

type ContainerSpec added in v0.52.0

type ContainerSpec struct {
	Repository   string            `json:"repository"`
	Tag          string            `json:"tag"`
	Env          map[string]string `json:"env"`
	Cmd          []string          `json:"cmd"`
	PortBindings PortBindings      `json:"port_bindings"`
}

type ContainerStartInput added in v0.52.0

type ContainerStartInput struct {
	PoolId        string        `json:"pool_id"`
	TestId        string        `json:"test_id"`
	TestName      string        `json:"test_name"`
	ComponentType string        `json:"component_type"`
	ComponentName string        `json:"component_name"`
	ContainerName string        `json:"container_name"`
	Spec          ContainerSpec `json:"spec"`
	ExpireAfter   time.Duration `json:"expire_after"`
}

type ContainerStopInput added in v0.52.0

type ContainerStopInput struct {
	PoolId string `json:"pool_id"`
	TestId string `json:"test_id"`
}

type Environment

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

func NewEnvironment

func NewEnvironment(t *testing.T, options ...Option) (*Environment, error)

func (*Environment) Clock

func (e *Environment) Clock() clock.Clock

func (*Environment) Component

func (e *Environment) Component(typ string, name string) Component

func (*Environment) Config

func (e *Environment) Config() cfg.GosoConf

func (*Environment) Context

func (e *Environment) Context() context.Context

func (*Environment) Filesystem

func (e *Environment) Filesystem() *filesystem

func (*Environment) Kafka added in v0.51.0

func (e *Environment) Kafka(name string) *KafkaComponent

func (*Environment) LifeCyleCreate added in v0.37.0

func (e *Environment) LifeCyleCreate() error

func (*Environment) LoadFixtureSet added in v0.36.0

func (e *Environment) LoadFixtureSet(factory fixtures.FixtureSetsFactory, postProcessorFactories ...fixtures.PostProcessorFactory) error

func (*Environment) LoadFixtureSets added in v0.24.0

func (e *Environment) LoadFixtureSets(factories []fixtures.FixtureSetsFactory, postProcessorFactories ...fixtures.PostProcessorFactory) error

func (*Environment) Localstack

func (e *Environment) Localstack(name string) *localstackComponent

func (*Environment) Logger

func (e *Environment) Logger() log.GosoLogger

func (*Environment) Logs added in v0.18.1

func (e *Environment) Logs() LogRecords

func (*Environment) Mailpit added in v0.40.7

func (e *Environment) Mailpit(name string) *mailpitComponent

func (*Environment) MySql

func (e *Environment) MySql(name string) *mysqlComponent

func (*Environment) Redis

func (e *Environment) Redis(name string) *RedisComponent

func (*Environment) ResetLogs added in v0.21.4

func (e *Environment) ResetLogs()

func (*Environment) Stop

func (e *Environment) Stop() error

func (*Environment) StreamInput

func (e *Environment) StreamInput(name string) *StreamInputComponent

func (*Environment) StreamOutput

func (e *Environment) StreamOutput(name string) *streamOutputComponent

func (*Environment) Wiremock

func (e *Environment) Wiremock(name string) *wiremockComponent

type HealthCheckSettings added in v0.52.0

type HealthCheckSettings struct {
	InitialInterval time.Duration `cfg:"initial_interval" default:"1s"`
	MaxInterval     time.Duration `cfg:"max_interval"     default:"3s"`
	MaxElapsedTime  time.Duration `cfg:"max_elapsed_time" default:"1m"`
}

type KafkaComponent added in v0.51.0

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

func (KafkaComponent) AdminClient added in v0.51.0

func (c KafkaComponent) AdminClient() admin.Client

func (KafkaComponent) BrokerAddress added in v0.51.0

func (c KafkaComponent) BrokerAddress() string

func (KafkaComponent) CfgOptions added in v0.51.0

func (c KafkaComponent) CfgOptions() []cfg.Option

func (KafkaComponent) SchemaRegistryAddress added in v0.51.0

func (c KafkaComponent) SchemaRegistryAddress() string

func (KafkaComponent) SchemaRegistryClient added in v0.51.0

func (c KafkaComponent) SchemaRegistryClient() schemaRegistry.Client

func (*KafkaComponent) SetT added in v0.51.0

func (c *KafkaComponent) SetT(t *testing.T)

type LogRecord added in v0.18.1

type LogRecord struct {
	Timestamp    time.Time
	Level        int
	Msg          string
	Args         []any
	Err          error
	Data         log.Data
	FormattedMsg string
}

type LogRecords added in v0.18.1

type LogRecords map[string]ChannelRecords

func (LogRecords) Channel added in v0.26.1

func (logs LogRecords) Channel(channel string) ChannelRecords

func (LogRecords) Filter added in v0.18.1

func (logs LogRecords) Filter(condition func(LogRecord) bool) LogRecords

type LoggerOption

type LoggerOption func(settings *LoggerSettings) error

type LoggerSettings

type LoggerSettings struct {
	Level      string
	RecordLogs bool
}

type Option

type Option func(env *Environment)

func WithComponent

func WithComponent(settings ComponentBaseSettingsAware) Option

func WithConfigEnvKeyReplacer

func WithConfigEnvKeyReplacer(replacer *strings.Replacer) Option

func WithConfigFile

func WithConfigFile(file string) Option

func WithConfigMap

func WithConfigMap(settings map[string]any) Option

func WithConfigSetting

func WithConfigSetting(key string, settings any) Option

func WithContainerExpireAfter

func WithContainerExpireAfter(expireAfter time.Duration) Option

func WithLogRecording added in v0.18.1

func WithLogRecording() Option

func WithLoggerLevel

func WithLoggerLevel(level string) Option

func WithoutAutoDetectedComponents

func WithoutAutoDetectedComponents(components ...string) Option

type PortBinding added in v0.52.0

type PortBinding struct {
	ContainerPort int    `json:"container_port"`
	HostPort      int    `json:"host_port"`
	Protocol      string `json:"protocol"`
}

func (PortBinding) DockerPort added in v0.52.0

func (b PortBinding) DockerPort() string

type PortBindings added in v0.52.0

type PortBindings map[string]PortBinding

type RecordingLogger added in v0.18.1

type RecordingLogger interface {
	log.GosoLogger
	Records() LogRecords
	Reset()
}

func NewRecordingConsoleLogger added in v0.18.1

func NewRecordingConsoleLogger(t *testing.T, config cfg.Config, options ...LoggerOption) (RecordingLogger, error)

type RedisComponent

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

func (*RedisComponent) Address

func (c *RedisComponent) Address() string

func (*RedisComponent) CfgOptions

func (c *RedisComponent) CfgOptions() []cfg.Option

func (*RedisComponent) Client

func (c *RedisComponent) Client() *redis.Client

func (*RedisComponent) SetT

func (c *RedisComponent) SetT(t *testing.T)

type StreamInputComponent

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

func (*StreamInputComponent) CfgOptions

func (s *StreamInputComponent) CfgOptions() []cfg.Option

func (*StreamInputComponent) Publish

func (s *StreamInputComponent) Publish(body any, attributes map[string]string)

func (*StreamInputComponent) PublishAndStop

func (s *StreamInputComponent) PublishAndStop(body any, attributes map[string]string)

func (*StreamInputComponent) PublishFromJsonFile

func (s *StreamInputComponent) PublishFromJsonFile(fileName string)

func (*StreamInputComponent) SetT

func (c *StreamInputComponent) SetT(t *testing.T)

func (*StreamInputComponent) Stop

func (s *StreamInputComponent) Stop()

type TmpfsSettings

type TmpfsSettings struct {
	Path string `cfg:"path"`
	Size string `cfg:"size"`
	Mode string `cfg:"mode"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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