2026-07-03 16:51:41 +00:00
|
|
|
package config
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
type Config struct {
|
2026-11-21 22:49:41 +00:00
|
|
|
Pipelines map[string]pipeline.PipelineProfile `json:"pipelines"`
|
|
|
|
|
Concurrency ConcurrencyConfig `json:"concurrency"`
|
|
|
|
|
Output OutputConfig `json:"output"`
|
|
|
|
|
CacheDirectory string `json:"cache_directory"`
|
|
|
|
|
Debug DebugConfig `json:"debug"`
|
2026-07-03 16:51:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type ConcurrencyConfig struct {
|
2026-11-21 22:49:41 +00:00
|
|
|
Workers int `json:"workers"`
|
2026-07-03 16:51:41 +00:00
|
|
|
}
|
|
|
|
|
|
2026-11-22 01:45:31 +00:00
|
|
|
const defaultWorkers = pipeline.DefaultWorkers
|
2026-08-03 19:12:19 +00:00
|
|
|
|
2026-07-18 12:42:10 +00:00
|
|
|
type OutputConfig struct {
|
|
|
|
|
Directory string `json:"directory"`
|
2026-07-03 16:51:41 +00:00
|
|
|
}
|
|
|
|
|
|
2026-07-18 12:42:10 +00:00
|
|
|
type DebugConfig struct {
|
|
|
|
|
Directory string `json:"directory"`
|
2026-07-08 02:18:59 +00:00
|
|
|
}
|
|
|
|
|
|
2026-07-03 16:51:41 +00:00
|
|
|
func Default() Config {
|
|
|
|
|
return Config{
|
2026-11-21 22:49:41 +00:00
|
|
|
Pipelines: map[string]pipeline.PipelineProfile{},
|
|
|
|
|
Concurrency: ConcurrencyConfig{Workers: defaultWorkers},
|
|
|
|
|
Output: OutputConfig{Directory: "./notarius-output"},
|
|
|
|
|
Debug: DebugConfig{Directory: "/tmp/notarius-debug"},
|
2026-07-03 16:51:41 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func cloneConfig(in Config) Config {
|
|
|
|
|
out := in
|
|
|
|
|
out.Pipelines = make(map[string]pipeline.PipelineProfile, len(in.Pipelines))
|
|
|
|
|
for key, profile := range in.Pipelines {
|
2026-11-26 02:29:52 +00:00
|
|
|
out.Pipelines[key] = pipeline.ClonePipelineProfile(profile)
|
2026-07-03 16:51:41 +00:00
|
|
|
}
|
|
|
|
|
return out
|
|
|
|
|
}
|
|
|
|
|
|
2026-07-05 14:21:36 +00:00
|
|
|
func cloneStringMap(in map[string]string) map[string]string {
|
|
|
|
|
if len(in) == 0 {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
out := make(map[string]string, len(in))
|
|
|
|
|
for key, value := range in {
|
|
|
|
|
out[key] = value
|
|
|
|
|
}
|
|
|
|
|
return out
|
|
|
|
|
}
|
|
|
|
|
|
2026-11-21 22:49:41 +00:00
|
|
|
func cloneValue[T any](value *T) *T {
|
|
|
|
|
if value == nil {
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
copy := *value
|
|
|
|
|
return ©
|
|
|
|
|
}
|