Skip to content

Commit

Permalink
add ability to variables in generate path (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
adikari committed Jul 9, 2024
1 parent 2f5304c commit 8500b00
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
14 changes: 13 additions & 1 deletion config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ func Load(param LoadConfigInput) (*Config, error) {
Service: rc.Service,
Stage: param.Stage,
Provider: rc.Provider,
Generate: rc.Generate,
}

if c.Provider == "" {
Expand Down Expand Up @@ -122,6 +121,19 @@ func Load(param LoadConfigInput) (*Config, error) {
})
}

for _, value := range rc.Generate {
path, err := Interpolate(value.Path, variables)

if err != nil {
return nil, errors.Wrap(err, fmt.Sprintf("failed to interpolate generate: type: %s, path: %s", value.Type, value.Path))
}

c.Generate = append(c.Generate, Generate{
Type: value.Type,
Path: path,
})
}

for key, value := range rc.Config["shared"] {
val, err := Interpolate(value, variables)

Expand Down
6 changes: 5 additions & 1 deletion example/minimal.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
service: safebox
provider: ssm

generate:
- type: types-node
path: types/env.d.ts
- type: json
path: env.json
- type: dotenv
path: .env.{{.stage}}
- type: dotenv
path: .env

config:
defaults:
Expand Down
2 changes: 1 addition & 1 deletion npm/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@adikari/safebox",
"version": "1.3.12",
"version": "1.3.13",
"description": "A Fast and Flexible secret manager built with love by adikari in Go",
"main": "index.js",
"bin": "./run.js",
Expand Down

0 comments on commit 8500b00

Please sign in to comment.