Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ability to interpolate generate path #34

Merged
merged 1 commit into from
Jul 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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