Documentation
¶
Index ¶
- Constants
- func EffectiveNoSteps(cliNoSteps []string, cfg *LoadedConfig) []string
- func EffectiveSQL(cliSQL string, cfg *LoadedConfig) string
- func EffectiveScript(cliScript string, cfg *LoadedConfig) string
- func EffectiveSteps(cliSteps []string, cfg *LoadedConfig) []string
- func LogConfigFile(loaded *LoadedConfig)
- func MergePostgresConfig(dst, src *config.PostgresConfig) *config.PostgresConfig
- func MergeSQLConfig(dst, src *config.SQLConfig) *config.SQLConfig
- func UnmarshalStrict(data []byte, v any) error
- type DriverCLIConfig
- type DriverCLIConfigs
- type DriverOverride
- type DriverPreset
- type LoadedConfig
Constants ¶
const DefaultConfigFile = "stroppy-config.json"
DefaultConfigFile is the file auto-discovered in the current directory.
Variables ¶
This section is empty.
Functions ¶
func EffectiveNoSteps ¶
func EffectiveNoSteps(cliNoSteps []string, cfg *LoadedConfig) []string
EffectiveNoSteps returns the step blocklist. CLI --no-steps fully overrides config file no_steps.
func EffectiveSQL ¶
func EffectiveSQL(cliSQL string, cfg *LoadedConfig) string
EffectiveSQL returns the SQL arg to use. CLI positional arg takes precedence over config file.
func EffectiveScript ¶
func EffectiveScript(cliScript string, cfg *LoadedConfig) string
EffectiveScript returns the script to use. CLI positional arg takes precedence over config file.
func EffectiveSteps ¶
func EffectiveSteps(cliSteps []string, cfg *LoadedConfig) []string
EffectiveSteps returns the step allowlist. CLI --steps fully overrides config file steps.
func LogConfigFile ¶
func LogConfigFile(loaded *LoadedConfig)
LogConfigFile emits config-file diagnostics after logger initialization.
func MergePostgresConfig ¶
func MergePostgresConfig(dst, src *config.PostgresConfig) *config.PostgresConfig
MergePostgresConfig merges src into dst and returns the result. Every field is optional (a pointer), so a non-nil src field overrides the dst field while a nil src field leaves dst unchanged.
func MergeSQLConfig ¶
MergeSQLConfig merges src into dst with the same non-nil-overrides semantics as MergePostgresConfig, for the generic database/sql pool block.
func UnmarshalStrict ¶
UnmarshalStrict validates the full JSON token stream before decoding it.
Types ¶
type DriverCLIConfig ¶
type DriverCLIConfig struct {
// Base fields from preset (overridable via -D).
DriverType string `json:"driverType,omitempty"`
URL string `json:"url,omitempty"`
DefaultInsertMethod string `json:"defaultInsertMethod,omitempty"`
// Extra fields from config-file drivers that don't map to known fields.
Extra map[string]any `json:"-"`
// Overrides retains -D occurrences for strict, order-preserving decoding.
Overrides []DriverOverride `json:"-"`
// contains filtered or unexported fields
}
DriverCLIConfig is one mutable driver configuration assembled from -d/-D inputs before conversion to the runtime config.
func NewDriverCLIConfigFromJSON ¶
func NewDriverCLIConfigFromJSON(raw string) (DriverCLIConfig, error)
NewDriverCLIConfigFromJSON strictly validates a raw -d JSON object before separating its base fields from the nested driver extras.
func NewDriverCLIConfigFromPreset ¶
func NewDriverCLIConfigFromPreset(p DriverPreset) DriverCLIConfig
NewDriverCLIConfigFromPreset creates a DriverCLIConfig from a preset.
func (*DriverCLIConfig) ApplyOverride ¶
func (d *DriverCLIConfig) ApplyOverride(key, value string) error
ApplyOverride retains a driver override for strict decoding at runtime.
func (*DriverCLIConfig) DecodeOverrides ¶
func (d *DriverCLIConfig) DecodeOverrides() (*config.DriverRunConfig, error)
DecodeOverrides validates retained -D input with the shared config decoder.
func (*DriverCLIConfig) HasDefaultInsertMethod ¶
func (d *DriverCLIConfig) HasDefaultInsertMethod() bool
HasDefaultInsertMethod reports whether a default was explicitly provided.
func (DriverCLIConfig) MarshalJSON ¶
func (d DriverCLIConfig) MarshalJSON() ([]byte, error)
MarshalJSON produces a flat JSON object merging known fields and extras.
type DriverCLIConfigs ¶
type DriverCLIConfigs map[string]*DriverCLIConfig
DriverCLIConfigs holds parsed driver configurations by declaration name.
func DriverCLIConfigsFromFile ¶
func DriverCLIConfigsFromFile(fileDrivers map[string]*config.DriverRunConfig) (DriverCLIConfigs, error)
DriverCLIConfigsFromFile converts config-file drivers into mutable CLI configs.
type DriverOverride ¶
DriverOverride is one -D key=value occurrence.
type DriverPreset ¶
type DriverPreset struct {
DriverType string `json:"driverType"`
URL string `json:"url"`
DefaultInsertMethod string `json:"defaultInsertMethod,omitempty"`
PoolKind string `json:"-"` // "postgres" or "sql" — determines which pool config block to use
}
DriverPreset contains default configuration for a known database driver. These are used when the user specifies --driver / -d on the CLI.
func LookupDriverPreset ¶
func LookupDriverPreset(name string) (DriverPreset, error)
LookupDriverPreset returns a preset by short name, or an error if not found.
type LoadedConfig ¶
type LoadedConfig struct {
Path string
RunConfig *config.RunConfig
Run map[string]json.RawMessage
Params map[string]json.RawMessage
}
LoadedConfig keeps the run config separate from typed parameter scopes.
func LoadRunConfig ¶
func LoadRunConfig(path string) (*LoadedConfig, bool, error)
LoadRunConfig loads a RunConfig from a JSON file.
- If path is non-empty: load from that path; return error if not found.
- If path is empty: try DefaultConfigFile in cwd; return (nil, false, nil) if absent.
Returns (config, loaded, error).