config

package
v1.5.0-beta Latest Latest
Warning

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

Go to latest
Published: Apr 15, 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

This section is empty.

Types

type ContainerNameParams added in v1.4.0

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

ContainerNameParams holds parameters for container name template substitution

type ContainerNaming added in v1.4.0

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 added in v1.4.0

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

GetAppContainer returns the app container name with template substitution

func (*ContainerNaming) GetDatabaseContainer added in v1.4.0

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

GetDatabaseContainer returns the database container name with template substitution

func (*ContainerNaming) GetKafkaContainer added in v1.4.0

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

GetKafkaContainer returns the Kafka container name with template substitution

func (*ContainerNaming) GetMigrateContainer added in v1.4.0

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

GetMigrateContainer returns the migration container name with template substitution

func (*ContainerNaming) GetNetworkName added in v1.4.0

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

GetNetworkName returns the network name with template substitution

func (*ContainerNaming) GetProjectMountPath added in v1.4.0

func (c *ContainerNaming) GetProjectMountPath() string

GetProjectMountPath returns the project mount path

func (*ContainerNaming) GetProxyContainer added in v1.4.0

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

GetProxyContainer returns the proxy container name with template substitution

func (*ContainerNaming) GetRegistryMountPath added in v1.4.0

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, database
	Host      string            `yaml:"host"`
	Port      int               `yaml:"port"`
	Proxy     bool              `yaml:"proxy"`      // Whether to mock this dependency
	HostAlias string            `yaml:"host_alias"` // Custom hostname alias for the service
	Headers   map[string]string `yaml:"headers,omitempty"`
}

DependencyConfig defines external service dependencies

type EmbeddingConfig added in v1.3.0

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 added in v1.4.0

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 added in v1.4.0

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 added in v1.4.0

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

GenericFrameworkConfig implements FrameworkConfig for custom/unknown frameworks

func (*GenericFrameworkConfig) GetMigrationCommand added in v1.4.0

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

func (*GenericFrameworkConfig) GetStartCommand added in v1.4.0

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

func (*GenericFrameworkConfig) GetWarmupDelay added in v1.4.0

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

func (*GenericFrameworkConfig) GetWarmupEndpoint added in v1.4.0

func (g *GenericFrameworkConfig) GetWarmupEndpoint() string

func (*GenericFrameworkConfig) NeedsWarmup added in v1.4.0

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 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"`
	TestTimeoutSeconds int                    `yaml:"timeout_seconds,omitempty"`
	StrictPassthrough  bool                   `yaml:"strict_passthrough,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 added in v1.4.0

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 added in v1.4.0

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
	SharedRepos       []string         `yaml:"shared_repos"`        // paths or URLs to shared provenance repositories
	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
	Embedding         *EmbeddingConfig `yaml:"embedding,omitempty"` // embedding API configuration
}

ProvenanceConfig defines provenance record settings

type SchemaDiscoveryConfig added in v1.4.0

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"`
}

Jump to

Keyboard shortcuts

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