Migrate application configuration to the new ConfigKit API
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user