Browse Source

add envs prefix

master 0.2
Vladimir Smagin 2 weeks ago
parent
commit
6844bf417f
2 changed files with 8 additions and 4 deletions
  1. +6
    -3
      README.md
  2. +2
    -1
      main.go

+ 6
- 3
README.md View File

@ -5,6 +5,8 @@ Retrieve Vault KV storage path as env variables.
```
>$ ./vault-envs -h
Usage of ./vault-envs:
-envs-prefix string
Set ENVs prefix if same named secrets already exported
-timeout string
Set timeout to connect in seconds (default "10s")
-token string
@ -17,18 +19,19 @@ Usage of ./vault-envs:
## How to use
Create sample KV secret `/databases/test` with two named values and run:
Create sample KV secret `/databases/test` with two named values and run (**prefix used**):
```
>$ ./vault-envs -token s.UYzqUtrBpL5MX3YP7GzXapZR \
-vault-url https://vault.blindage.org \
-vault-path /databases/test
-envs-prefix="JOPA_"
```
Output:
```
VAULT_RETRIEVER=vault-envs
env1=value1
env2=value2
JOPA_env1=value1
JOPA_env2=value2
```
Ok, you got your values in ENV variables format, additional mark of vault-envs added. Now export variables to current session:
```


+ 2
- 1
main.go View File

@ -13,6 +13,7 @@ var (
token = flag.String("token", "", "Set token to authorize API requests")
vaultURL = flag.String("vault-url", "", "Set Vault URL, like https://vault.myproject.ru:8000")
vaultPath = flag.String("vault-path", "", "Set KV secrets path, like /databases/postgres-main")
envsPrefix = flag.String("envs-prefix", "", "Set ENVs prefix if same named secrets already exported")
vaultTimeoutFlag = flag.String("timeout", "10s", "Set timeout to connect in seconds")
vaultTimeout = time.Duration(0 * time.Second)
)
@ -62,7 +63,7 @@ func main() {
}
for varname, value := range vaultData.Data {
fmt.Printf("%v=%v\n", varname, value)
fmt.Printf("%v%v=%v\n", *envsPrefix, varname, value)
}
}

Loading…
Cancel
Save