Migrate application configuration to the new ConfigKit API

This commit is contained in:
2026-11-17 20:42:25 +00:00
parent ae0e410875
commit 6da4d070e5
19 changed files with 88 additions and 29 deletions

View File

@@ -4,8 +4,8 @@ import (
"fmt"
"io"
configkit "gitea.maximumdirect.net/eric/ConfigKit"
"gitea.maximumdirect.net/eric/notarius/internal/framework/pipeline"
configkit "go.maximumdirect.net/configkit"
)
// LoadedConfig keeps the finalized runtime configuration together with the
@@ -59,6 +59,28 @@ func Load(path string, options LoadOptions) (*LoadedConfig, error) {
return loadConfig(path, options)
}
// LoadSource loads a selected source, including its imports, into an owned configuration.
func LoadSource(source configkit.Source, options LoadOptions) (*LoadedConfig, error) {
result, err := loadDocumentWithSource(source, options, true)
if err != nil {
return nil, err
}
return newLoadedConfig(result)
}
// MainSourcePath returns the selected main file's recorded path, if any.
func (loaded *LoadedConfig) MainSourcePath() string {
if loaded == nil || loaded.result == nil {
return ""
}
for _, source := range loaded.result.Sources() {
if source.Layer == configkit.LayerMain && source.Kind == configkit.SourceKindFile && source.ImportedFrom == nil {
return source.Path
}
}
return ""
}
func loadConfigSource(source configkit.Source, options LoadOptions) (*LoadedConfig, error) {
result, err := loadDocumentSource(source, options)
if err != nil {