config

package
v3.16.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultNetworkAlias = "real-db"

DefaultNetworkAlias is the container network alias used when no containerNaming.network_alias is set in .linespec.yml. Exported so the runner can reference the same value.

Variables

This section is empty.

Functions

func SanitizeContainerName

func SanitizeContainerName(s string) string

SanitizeContainerName replaces spaces with hyphens and strips characters that Docker container names do not allow ([a-zA-Z0-9][a-zA-Z0-9_.-]*). Exported so runner and other packages can sanitize spec names before constructing hardcoded container name strings.

Types

type ContainerNameParams

type ContainerNameParams struct {
	ServiceName string
	SpecName    string
	Type        string // "db", "http", "kafka", etc.
}

ContainerNameParams holds parameters for container name template substitution

type ContainerNaming

type ContainerNaming struct {
	DatabaseContainer string `yaml:"database_container"`  // Template for DB container name
	NetworkAlias      string `yaml:"network_alias"`       // Network alias for database (e.g., "real-db")
	KafkaContainer    string `yaml:"kafka_container"`     // Template for Kafka container name
	ProxyContainer    string `yaml:"proxy_container"`     // Template for proxy container name
	AppContainer      string `yaml:"app_container"`       // Template for app container name
	NetworkName       string `yaml:"network_name"`        // Template for network name
	MigrateContainer  string `yaml:"migrate_container"`   // Template for migration container name
	ProjectMountPath  string `yaml:"project_mount_path"`  // Mount path for project (default: /app/project)
	RegistryMountPath string `yaml:"registry_mount_path"` // Mount path for registry (default: /app/registry)
}

ContainerNaming defines configurable container and network naming Supports template variables: {{ .ServiceName }}, {{ .SpecName }}, {{ .Type }}

func (*ContainerNaming) GetAppContainer

func (c *ContainerNaming) GetAppContainer(params ContainerNameParams) string

GetAppContainer returns the app container name with template substitution

func (*ContainerNaming) GetDatabaseContainer

func (c *ContainerNaming) GetDatabaseContainer(params ContainerNameParams) string

GetDatabaseContainer returns the database container name with template substitution

func (*ContainerNaming) GetKafkaContainer

func (c *ContainerNaming) GetKafkaContainer(params ContainerNameParams) string

GetKafkaContainer returns the Kafka container name with template substitution

func (*ContainerNaming) GetMigrateContainer

func (c *ContainerNaming) GetMigrateContainer(params ContainerNameParams) string

GetMigrateContainer returns the migration container name with template substitution

func (*ContainerNaming) GetNetworkName

func (c *ContainerNaming) GetNetworkName(params ContainerNameParams) string

GetNetworkName returns the network name with template substitution

func (*ContainerNaming) GetProjectMountPath

func (c *ContainerNaming) GetProjectMountPath() string

GetProjectMountPath returns the project mount path

func (*ContainerNaming) GetProxyContainer

func (c *ContainerNaming) GetProxyContainer(params ContainerNameParams) string

GetProxyContainer returns the proxy container name with template substitution

func (*ContainerNaming) GetRegistryMountPath

func (c *ContainerNaming) GetRegistryMountPath() string

GetRegistryMountPath returns the registry mount path

type DatabaseConfig

type DatabaseConfig struct {
	Name       string `yaml:"name"` // Logical name used to identify this database (required when using databases: list)
	Type       string `yaml:"type"` // mysql, postgresql
	Image      string `yaml:"image"`
	Port       int    `yaml:"port"`
	Container  string `yaml:"container"` // service name in docker-compose
	InitScript string `yaml:"init_script"`
	Database   string `yaml:"database"`
	Username   string `yaml:"username"`
	Password   string `yaml:"password"`
	Host       string `yaml:"host"`            // Host alias the app uses to connect (proxy occupies this alias on the Docker network)
	Proxy      *bool  `yaml:"proxy,omitempty"` // Whether to use a proxy for this database (enables interception)
}

DatabaseConfig defines database requirements

type DependencyConfig

type DependencyConfig struct {
	Name              string            `yaml:"name"`
	Type              string            `yaml:"type"` // http, grpc, database
	Host              string            `yaml:"host"`
	Port              int               `yaml:"port"`
	Proxy             bool              `yaml:"proxy"`
	HostAlias         string            `yaml:"host_alias"`
	Headers           map[string]string `yaml:"headers,omitempty"`
	GRPCDescriptorSet string            `yaml:"grpc_descriptor_set,omitempty"`
}

DependencyConfig defines external service dependencies

type EmbeddingConfig

type EmbeddingConfig struct {
	Provider            string  `yaml:"provider"`             // voyage, openai, etc.
	IndexModel          string  `yaml:"index_model"`          // e.g., voyage-4-large (for indexing documents at 2048 dims)
	QueryModel          string  `yaml:"query_model"`          // e.g., voyage-4-lite (for queries at 2048 dims)
	APIKey              string  `yaml:"api_key"`              // Can be "${ENV_VAR_NAME}" or literal
	SimilarityThreshold float64 `yaml:"similarity_threshold"` // default: 0.50
	IndexOnComplete     bool    `yaml:"index_on_complete"`    // default: true
}

EmbeddingConfig defines the embedding API configuration

type FrameworkConfig

type FrameworkConfig interface {
	GetStartCommand(port string) []string
	GetMigrationCommand() []string
	NeedsWarmup() bool
	GetWarmupEndpoint() string
	GetWarmupDelay() time.Duration
}

FrameworkConfig defines the interface for framework-specific configuration

func GetFrameworkConfig

func GetFrameworkConfig(framework string, customStartCmd, customMigrationCmd string, needsWarmup *bool, warmupEndpoint string, warmupDelayMs int) FrameworkConfig

GetFrameworkConfig returns a FrameworkConfig for the given framework name. Known framework names (rails, fastapi, django, express) provide sensible defaults that can be overridden by the non-zero override parameters from .linespec.yml.

type GenericFrameworkConfig

type GenericFrameworkConfig struct {
	CustomStartCommand  string
	CustomMigrationCmd  string
	NeedsWarmupFlag     bool
	WarmupEndpointValue string
	WarmupDelayMs       int
}

GenericFrameworkConfig implements FrameworkConfig for custom/unknown frameworks

func (*GenericFrameworkConfig) GetMigrationCommand

func (g *GenericFrameworkConfig) GetMigrationCommand() []string

func (*GenericFrameworkConfig) GetStartCommand

func (g *GenericFrameworkConfig) GetStartCommand(port string) []string

func (*GenericFrameworkConfig) GetWarmupDelay

func (g *GenericFrameworkConfig) GetWarmupDelay() time.Duration

func (*GenericFrameworkConfig) GetWarmupEndpoint

func (g *GenericFrameworkConfig) GetWarmupEndpoint() string

func (*GenericFrameworkConfig) NeedsWarmup

func (g *GenericFrameworkConfig) NeedsWarmup() bool

type InfrastructureConfig

type InfrastructureConfig struct {
	Kafka      bool   `yaml:"kafka"`
	Database   bool   `yaml:"database"`
	Redis      bool   `yaml:"redis"`
	GRPC       bool   `yaml:"grpc"`
	ExternalDB bool   `yaml:"external_db"` // Don't manage DB, service has its own
	ProxyImage string `yaml:"proxy_image"` // Docker image for protocol proxies (default: linespec:latest)
}

InfrastructureConfig defines required infrastructure

type JobBackendConfig

type JobBackendConfig struct {
	Type  string `yaml:"type"`            // redis | kafka | scheduled
	Queue string `yaml:"queue,omitempty"` // Redis queue key (e.g. "queue:default") or Kafka topic
}

JobBackendConfig configures the backing store used to deliver jobs to the worker under test. Type values: "redis" (seed via BRPOP/LPOP), "kafka" (seed via topic), "scheduled" (observe-only).

type LineSpecConfig

type LineSpecConfig struct {
	Service            ServiceConfig          `yaml:"service"`
	Database           *DatabaseConfig        `yaml:"database,omitempty"`  // Single-database form (backward compat). Normalised into Databases by applyDefaults.
	Databases          []DatabaseConfig       `yaml:"databases,omitempty"` // Multi-database form. Takes precedence over Database when both are set.
	Infrastructure     InfrastructureConfig   `yaml:"infrastructure"`
	Dependencies       []DependencyConfig     `yaml:"dependencies,omitempty"`
	Provenance         *ProvenanceConfig      `yaml:"provenance,omitempty"`
	ContainerNaming    *ContainerNaming       `yaml:"container_naming,omitempty"`
	PortConfig         *PortConfig            `yaml:"ports,omitempty"`
	SchemaDiscovery    *SchemaDiscoveryConfig `yaml:"schema_discovery,omitempty"`
	Payload            *PayloadConfig         `yaml:"payload,omitempty"`
	JobBackend         *JobBackendConfig      `yaml:"job_backend,omitempty"`
	TestTimeoutSeconds int                    `yaml:"timeout_seconds,omitempty"`
	StrictPassthrough  bool                   `yaml:"strict_passthrough,omitempty"`
	GRPCDescriptorSet  string                 `yaml:"grpc_descriptor_set,omitempty"`
	Created            time.Time              `yaml:"-"`
	BaseDir            string                 `yaml:"-"`
}

LineSpecConfig is the root configuration structure

func DefaultConfig

func DefaultConfig(framework string) *LineSpecConfig

DefaultConfig returns baseline config defaults for a given framework name. Health endpoints are derived from frameworkDefaults. Rails also gets database defaults since it conventionally requires a relational database.

func LoadConfig

func LoadConfig(startDir string) (*LineSpecConfig, error)

LoadConfig searches for .linespec.yml starting from the given directory and walking up to parent directories. Supports LINESPEC_CONFIG env var override.

func LoadConfigFile

func LoadConfigFile(path string) (*LineSpecConfig, error)

LoadConfigFile loads a specific .linespec.yml file

func (*LineSpecConfig) GetDockerComposePath

func (c *LineSpecConfig) GetDockerComposePath() string

GetDockerComposePath returns the absolute path to docker-compose.yml

func (*LineSpecConfig) GetHealthURL

func (c *LineSpecConfig) GetHealthURL(hostPort string) string

GetHealthURL returns the full health check URL

type PayloadConfig

type PayloadConfig struct {
	Directory        string            `yaml:"directory"`         // payload directory name (default: payloads)
	StatusField      string            `yaml:"status_field"`      // field path for HTTP status code (default: "status")
	AuthExtraction   map[string]string `yaml:"auth_extraction"`   // custom auth extraction rules
	SupportedFormats []string          `yaml:"supported_formats"` // list of supported formats
}

PayloadConfig defines payload loading and parsing configuration

type PortConfig

type PortConfig struct {
	MinPort        int  `yaml:"min_port"`         // Minimum port number for dynamic allocation
	MaxPort        int  `yaml:"max_port"`         // Maximum port number for dynamic allocation
	DynamicPorts   bool `yaml:"dynamic_ports"`    // Enable dynamic port allocation (default: true)
	FixedProxyPort int  `yaml:"fixed_proxy_port"` // Fixed port for proxy verification (0 = dynamic)
}

PortConfig defines dynamic port allocation settings

type ProvenanceConfig

type ProvenanceConfig struct {
	Enforcement                  string             `yaml:"enforcement"`                      // none | warn | strict
	Dir                          string             `yaml:"dir"`                              // relative to repo root
	ExcludePaths                 []string           `yaml:"exclude_paths"`                    // glob/regex/path patterns for files exempt from provenance rules
	SharedRepos                  []SharedRepoConfig `yaml:"shared_repos"`                     // named remote repositories for cross-repo resolution
	CacheTTLMinutes              int                `yaml:"cache_ttl_minutes"`                // cache freshness TTL in minutes; defaults to 60
	CommitTagRequired            bool               `yaml:"commit_tag_required"`              // whether commits must reference a prov ID
	AutoAffectedScope            bool               `yaml:"auto_affected_scope"`              // whether to auto-populate affected_scope from git diffs
	RunAssociatedSpecsOnComplete bool               `yaml:"run_associated_specs_on_complete"` // whether to run associated_specs before committing a completion transition
	OverlapSpecsOnComplete       string             `yaml:"overlap_specs_on_complete"`        // severity of the cross-record overlap teeth at completion: block (default) | warn | off
	CommitOnStatusChange         bool               `yaml:"commit_on_status_change"`          // whether to auto-commit after open, complete, or deprecate transitions
	Embedding                    *EmbeddingConfig   `yaml:"embedding,omitempty"`              // embedding API configuration
	ManifestURL                  string             `yaml:"manifest_url,omitempty"`           // source manifest URL set by linespec clone
}

ProvenanceConfig defines provenance record settings

type SchemaDiscoveryConfig

type SchemaDiscoveryConfig struct {
	Mode          string   `yaml:"mode"`           // auto, static, none
	Tables        []string `yaml:"tables"`         // explicit list when mode is static
	ExcludeTables []string `yaml:"exclude_tables"` // tables to ignore in auto mode
	CacheFile     string   `yaml:"cache_file"`     // path to cache discovered schema
}

SchemaDiscoveryConfig defines schema discovery settings

type ServiceConfig

type ServiceConfig struct {
	Name             string            `yaml:"name"`
	ServiceDir       string            `yaml:"service_dir"` // Directory containing service code (e.g., "user-service")
	Type             string            `yaml:"type"`        // web, worker, consumer
	Framework        string            `yaml:"framework"`
	Port             int               `yaml:"port"`
	HealthEndpoint   string            `yaml:"health_endpoint"`
	DockerCompose    string            `yaml:"docker_compose"`
	BuildContext     string            `yaml:"build_context"`
	StartCommand     string            `yaml:"start_command"`
	MigrationCommand string            `yaml:"migration_command"`      // Custom migration command (overrides framework default)
	WarmupEndpoint   string            `yaml:"warmup_endpoint"`        // Custom warmup endpoint (overrides framework default)
	WarmupDelayMs    int               `yaml:"warmup_delay_ms"`        // Custom warmup delay in milliseconds
	NeedsWarmup      *bool             `yaml:"needs_warmup,omitempty"` // Whether framework needs warmup (overrides framework default)
	Environment      map[string]string `yaml:"environment"`
}

type SharedRepoConfig

type SharedRepoConfig struct {
	Name string `yaml:"name"` // short alias used in log output and disambiguation
	URL  string `yaml:"url"`  // git-cloneable remote URL
	Ref  string `yaml:"ref"`  // branch or tag to fetch from; defaults to "main"
	Dir  string `yaml:"dir"`  // subdirectory containing provenance records; defaults to "provenance"
}

SharedRepoConfig defines a named remote repository for cross-repo provenance resolution

Jump to

Keyboard shortcuts

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