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

fix(flags): add empty defaults to Vault SuperFlag #7598

Merged
merged 3 commits into from
Mar 17, 2021
Merged
Changes from 1 commit
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
42 changes: 25 additions & 17 deletions ee/vault/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
package vault

import (
"fmt"

"github.com/dgraph-io/ristretto/z"
"github.com/spf13/pflag"
)
Expand All @@ -31,25 +33,31 @@ const (
flagAclFormat = "acl-format"
flagEncField = "enc-field"
flagEncFormat = "enc-format"

defaultConfig = "addr=http://localhost:8200; " +
"path=secret/data/dgraph; " +
"acl-format=base64; " +
"enc-format=base64;"
)

var helpText = z.NewSuperFlagHelp(defaultConfig).
Head("Vault options").
Flag(flagAddr, "Vault server address (format: http://ip:port).").
Flag(flagRoleIdFile, "Vault RoleID file, used for AppRole authentication.").
Flag(flagSecretIdFile, "Vault SecretID file, used for AppRole authentication.").
Flag(flagPath,
"Vault KV store path (e.g. 'secret/data/dgraph' for KV V2, 'kv/dgraph' for KV V1).").
Flag(flagAclField, "Vault field containing ACL key.").
Flag(flagAclFormat, "ACL key format, can be 'raw' or 'base64'.").
Flag(flagEncField, "Vault field containing encryption key.").
Flag(flagEncFormat, "Encryption key format, can be 'raw' or 'base64'.").
String()
var (
defaultConfig = fmt.Sprintf("%s=%s; %s=%s; %s=%s; %s=%s; %s=%s; %s=%s; %s=%s; %s=%s",
flagAddr, "http://localhost:8200",
flagRoleIdFile, "",
flagSecretIdFile, "",
flagPath, "secret/data/dgraph",
flagAclField, "",
flagAclFormat, "base64",
flagEncField, "",
flagEncFormat, "base64")

helpText = z.NewSuperFlagHelp(defaultConfig).
Head("Vault options").
Flag(flagAddr, "Vault server address (format: http://ip:port).").
Flag(flagRoleIdFile, "Vault RoleID file, used for AppRole authentication.").
Flag(flagSecretIdFile, "Vault SecretID file, used for AppRole authentication.").
Flag(flagPath, "Vault KV store path (e.g. 'secret/data/dgraph' for KV V2, 'kv/dgraph' for KV V1).").
Flag(flagAclField, "Vault field containing ACL key.").
Flag(flagAclFormat, "ACL key format, can be 'raw' or 'base64'.").
Flag(flagEncField, "Vault field containing encryption key.").
Flag(flagEncFormat, "Encryption key format, can be 'raw' or 'base64'.").
String()
)

func RegisterFlags(flag *pflag.FlagSet) {
flag.String(flagVault, defaultConfig, helpText)
Expand Down