Bootstrap secrets for shared configuration acquisition
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
package appconfig
|
||||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"gitea.maximumdirect.net/eric/audita/v4/internal/core/config"
|
||||
@@ -58,10 +60,21 @@ func Definition() ck.Definition[Config] {
|
||||
}
|
||||
|
||||
// Load composes built-in resources and optional companions with the selected input.
|
||||
func Load(input ck.Input, overlay string, overrides ...ck.Override) (*ck.Result[Config], error) {
|
||||
func Load(ctx context.Context, input ck.Input, overlay string, overrides ...ck.Override) (*ck.Result[Config], *ck.SecretsReport, error) {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
report, prepared, err := ck.LoadSecretsIntoEnvironmentFromConfig(input.Source, ck.SecretsFromConfigOptions{Filesystem: input.Filesystem})
|
||||
if canceled := ctx.Err(); canceled != nil {
|
||||
return nil, report, errors.Join(err, canceled)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, report, err
|
||||
}
|
||||
input.Source = prepared
|
||||
embedded, err := pk.FilesystemInputs("Audita embedded prompts", prompts.Filesystem(), prompts.AssetRoot)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("discover embedded prompts: %w", err)
|
||||
return nil, report, fmt.Errorf("discover embedded prompts: %w", err)
|
||||
}
|
||||
for i := range embedded {
|
||||
embedded[i].Destination = ck.Keys("promptkit")
|
||||
@@ -73,7 +86,7 @@ func Load(input ck.Input, overlay string, overrides ...ck.Override) (*ck.Result[
|
||||
Filesystem: &ck.FilesystemContext{FS: &schemas, Root: ".", BaseDir: "."},
|
||||
})
|
||||
input.Imports = true
|
||||
return ck.LoadLayered(input, ck.LayeredOptions[Config]{
|
||||
result, err := ck.LoadLayered(input, ck.LayeredOptions[Config]{
|
||||
Definition: Definition(),
|
||||
Overlay: overlay,
|
||||
Overrides: overrides,
|
||||
@@ -86,4 +99,8 @@ func Load(input ck.Input, overlay string, overrides ...ck.Override) (*ck.Result[
|
||||
}},
|
||||
},
|
||||
})
|
||||
if canceled := ctx.Err(); canceled != nil {
|
||||
return nil, report, errors.Join(err, canceled)
|
||||
}
|
||||
return result, report, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user