Use native pipeline discovery and independent secrets bootstrap
This commit is contained in:
@@ -18,12 +18,14 @@ type secretsBootstrap struct {
|
||||
called bool
|
||||
}
|
||||
|
||||
func (b *secretsBootstrap) load(pipelinePath string, loader func(string) (*configkit.SecretsReport, error), diagnostics io.Writer) error {
|
||||
var conventionalSecretsDirectory = "/usr/local/etc/narratio/secrets"
|
||||
|
||||
func (b *secretsBootstrap) load(loader func(string) (*configkit.SecretsReport, error), diagnostics io.Writer) error {
|
||||
if b == nil || b.called {
|
||||
return nil
|
||||
}
|
||||
b.called = true
|
||||
directory, required, err := selectedSecretsDirectory(pipelinePath, b.selection)
|
||||
directory, required, err := selectedSecretsDirectory(b.selection)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -53,7 +55,7 @@ func (b *secretsBootstrap) load(pipelinePath string, loader func(string) (*confi
|
||||
return fmt.Errorf("bootstrap secrets directory: %w", loadErr)
|
||||
}
|
||||
|
||||
func selectedSecretsDirectory(pipelinePath string, selection *string) (string, bool, error) {
|
||||
func selectedSecretsDirectory(selection *string) (string, bool, error) {
|
||||
if selection != nil {
|
||||
if strings.TrimSpace(*selection) == "" {
|
||||
return "", true, fmt.Errorf("--secrets-dir requires a non-empty path")
|
||||
@@ -64,9 +66,5 @@ func selectedSecretsDirectory(pipelinePath string, selection *string) (string, b
|
||||
}
|
||||
return filepath.Clean(path), true, nil
|
||||
}
|
||||
root, err := filepath.Abs(pipelinePath)
|
||||
if err != nil {
|
||||
return "", false, fmt.Errorf("resolve pipeline path for secrets discovery: %w", err)
|
||||
}
|
||||
return filepath.Join(filepath.Dir(root), "secrets"), false, nil
|
||||
return conventionalSecretsDirectory, false, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user