Files
config/provider/vault/provider_example_test.go
andrey 80b0244b52
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/pr Build is passing
add provider vault
2024-01-25 23:07:50 +03:00

48 lines
708 B
Go

package vault_test
import (
"context"
"fmt"
"log"
"gitoa.ru/go-4devs/config"
"gitoa.ru/go-4devs/config/provider/vault"
)
func ExampleClient_Value() {
const (
namespace = "fdevs"
appName = "config"
)
ctx := context.Background()
// configure vault client
vaultClient, err := NewVault()
if err != nil {
log.Print(err)
return
}
config, err := config.New(
vault.New(namespace, appName, vaultClient),
)
if err != nil {
log.Print(err)
return
}
dsn, err := config.Value(ctx, "example", "dsn")
if err != nil {
log.Print("example:dsn ", err)
return
}
fmt.Printf("dsn from vault: %s\n", dsn.String())
// Output:
// dsn from vault: pgsql://user@pass:127.0.0.1:5432
}