Move meta into its own package

This commit is contained in:
Jeff Mitchell
2016-04-01 13:16:05 -04:00
parent da00982529
commit 33326b30c3
79 changed files with 326 additions and 233 deletions

View File

@@ -27,19 +27,19 @@ import (
"github.com/hashicorp/vault/audit" "github.com/hashicorp/vault/audit"
"github.com/hashicorp/vault/command" "github.com/hashicorp/vault/command"
"github.com/hashicorp/vault/logical" "github.com/hashicorp/vault/logical"
"github.com/hashicorp/vault/meta"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
) )
// Commands returns the mapping of CLI commands for Vault. The meta // Commands returns the mapping of CLI commands for Vault. The meta
// parameter lets you set meta options for all commands. // parameter lets you set meta options for all commands.
func Commands(metaPtr *command.Meta) map[string]cli.CommandFactory { func Commands(metaPtr *meta.Meta) map[string]cli.CommandFactory {
if metaPtr == nil { if metaPtr == nil {
metaPtr = new(command.Meta) metaPtr = new(meta.Meta)
} }
meta := *metaPtr if metaPtr.Ui == nil {
if meta.Ui == nil { metaPtr.Ui = &cli.BasicUi{
meta.Ui = &cli.BasicUi{
Writer: os.Stdout, Writer: os.Stdout,
ErrorWriter: os.Stderr, ErrorWriter: os.Stderr,
} }
@@ -48,13 +48,13 @@ func Commands(metaPtr *command.Meta) map[string]cli.CommandFactory {
return map[string]cli.CommandFactory{ return map[string]cli.CommandFactory{
"init": func() (cli.Command, error) { "init": func() (cli.Command, error) {
return &command.InitCommand{ return &command.InitCommand{
Meta: meta, Meta: *metaPtr,
}, nil }, nil
}, },
"server": func() (cli.Command, error) { "server": func() (cli.Command, error) {
return &command.ServerCommand{ return &command.ServerCommand{
Meta: meta, Meta: *metaPtr,
AuditBackends: map[string]audit.Factory{ AuditBackends: map[string]audit.Factory{
"file": auditFile.Factory, "file": auditFile.Factory,
"syslog": auditSyslog.Factory, "syslog": auditSyslog.Factory,
@@ -85,19 +85,19 @@ func Commands(metaPtr *command.Meta) map[string]cli.CommandFactory {
"ssh": func() (cli.Command, error) { "ssh": func() (cli.Command, error) {
return &command.SSHCommand{ return &command.SSHCommand{
Meta: meta, Meta: *metaPtr,
}, nil }, nil
}, },
"path-help": func() (cli.Command, error) { "path-help": func() (cli.Command, error) {
return &command.PathHelpCommand{ return &command.PathHelpCommand{
Meta: meta, Meta: *metaPtr,
}, nil }, nil
}, },
"auth": func() (cli.Command, error) { "auth": func() (cli.Command, error) {
return &command.AuthCommand{ return &command.AuthCommand{
Meta: meta, Meta: *metaPtr,
Handlers: map[string]command.AuthHandler{ Handlers: map[string]command.AuthHandler{
"github": &credGitHub.CLIHandler{}, "github": &credGitHub.CLIHandler{},
"userpass": &credUserpass.CLIHandler{}, "userpass": &credUserpass.CLIHandler{},
@@ -109,193 +109,193 @@ func Commands(metaPtr *command.Meta) map[string]cli.CommandFactory {
"auth-enable": func() (cli.Command, error) { "auth-enable": func() (cli.Command, error) {
return &command.AuthEnableCommand{ return &command.AuthEnableCommand{
Meta: meta, Meta: *metaPtr,
}, nil }, nil
}, },
"auth-disable": func() (cli.Command, error) { "auth-disable": func() (cli.Command, error) {
return &command.AuthDisableCommand{ return &command.AuthDisableCommand{
Meta: meta, Meta: *metaPtr,
}, nil }, nil
}, },
"audit-list": func() (cli.Command, error) { "audit-list": func() (cli.Command, error) {
return &command.AuditListCommand{ return &command.AuditListCommand{
Meta: meta, Meta: *metaPtr,
}, nil }, nil
}, },
"audit-disable": func() (cli.Command, error) { "audit-disable": func() (cli.Command, error) {
return &command.AuditDisableCommand{ return &command.AuditDisableCommand{
Meta: meta, Meta: *metaPtr,
}, nil }, nil
}, },
"audit-enable": func() (cli.Command, error) { "audit-enable": func() (cli.Command, error) {
return &command.AuditEnableCommand{ return &command.AuditEnableCommand{
Meta: meta, Meta: *metaPtr,
}, nil }, nil
}, },
"key-status": func() (cli.Command, error) { "key-status": func() (cli.Command, error) {
return &command.KeyStatusCommand{ return &command.KeyStatusCommand{
Meta: meta, Meta: *metaPtr,
}, nil }, nil
}, },
"policies": func() (cli.Command, error) { "policies": func() (cli.Command, error) {
return &command.PolicyListCommand{ return &command.PolicyListCommand{
Meta: meta, Meta: *metaPtr,
}, nil }, nil
}, },
"policy-delete": func() (cli.Command, error) { "policy-delete": func() (cli.Command, error) {
return &command.PolicyDeleteCommand{ return &command.PolicyDeleteCommand{
Meta: meta, Meta: *metaPtr,
}, nil }, nil
}, },
"policy-write": func() (cli.Command, error) { "policy-write": func() (cli.Command, error) {
return &command.PolicyWriteCommand{ return &command.PolicyWriteCommand{
Meta: meta, Meta: *metaPtr,
}, nil }, nil
}, },
"read": func() (cli.Command, error) { "read": func() (cli.Command, error) {
return &command.ReadCommand{ return &command.ReadCommand{
Meta: meta, Meta: *metaPtr,
}, nil }, nil
}, },
"list": func() (cli.Command, error) { "list": func() (cli.Command, error) {
return &command.ListCommand{ return &command.ListCommand{
Meta: meta, Meta: *metaPtr,
}, nil }, nil
}, },
"write": func() (cli.Command, error) { "write": func() (cli.Command, error) {
return &command.WriteCommand{ return &command.WriteCommand{
Meta: meta, Meta: *metaPtr,
}, nil }, nil
}, },
"delete": func() (cli.Command, error) { "delete": func() (cli.Command, error) {
return &command.DeleteCommand{ return &command.DeleteCommand{
Meta: meta, Meta: *metaPtr,
}, nil }, nil
}, },
"rekey": func() (cli.Command, error) { "rekey": func() (cli.Command, error) {
return &command.RekeyCommand{ return &command.RekeyCommand{
Meta: meta, Meta: *metaPtr,
}, nil }, nil
}, },
"generate-root": func() (cli.Command, error) { "generate-root": func() (cli.Command, error) {
return &command.GenerateRootCommand{ return &command.GenerateRootCommand{
Meta: meta, Meta: *metaPtr,
}, nil }, nil
}, },
"renew": func() (cli.Command, error) { "renew": func() (cli.Command, error) {
return &command.RenewCommand{ return &command.RenewCommand{
Meta: meta, Meta: *metaPtr,
}, nil }, nil
}, },
"revoke": func() (cli.Command, error) { "revoke": func() (cli.Command, error) {
return &command.RevokeCommand{ return &command.RevokeCommand{
Meta: meta, Meta: *metaPtr,
}, nil }, nil
}, },
"seal": func() (cli.Command, error) { "seal": func() (cli.Command, error) {
return &command.SealCommand{ return &command.SealCommand{
Meta: meta, Meta: *metaPtr,
}, nil }, nil
}, },
"status": func() (cli.Command, error) { "status": func() (cli.Command, error) {
return &command.StatusCommand{ return &command.StatusCommand{
Meta: meta, Meta: *metaPtr,
}, nil }, nil
}, },
"unseal": func() (cli.Command, error) { "unseal": func() (cli.Command, error) {
return &command.UnsealCommand{ return &command.UnsealCommand{
Meta: meta, Meta: *metaPtr,
}, nil }, nil
}, },
"step-down": func() (cli.Command, error) { "step-down": func() (cli.Command, error) {
return &command.StepDownCommand{ return &command.StepDownCommand{
Meta: meta, Meta: *metaPtr,
}, nil }, nil
}, },
"mount": func() (cli.Command, error) { "mount": func() (cli.Command, error) {
return &command.MountCommand{ return &command.MountCommand{
Meta: meta, Meta: *metaPtr,
}, nil }, nil
}, },
"mounts": func() (cli.Command, error) { "mounts": func() (cli.Command, error) {
return &command.MountsCommand{ return &command.MountsCommand{
Meta: meta, Meta: *metaPtr,
}, nil }, nil
}, },
"mount-tune": func() (cli.Command, error) { "mount-tune": func() (cli.Command, error) {
return &command.MountTuneCommand{ return &command.MountTuneCommand{
Meta: meta, Meta: *metaPtr,
}, nil }, nil
}, },
"remount": func() (cli.Command, error) { "remount": func() (cli.Command, error) {
return &command.RemountCommand{ return &command.RemountCommand{
Meta: meta, Meta: *metaPtr,
}, nil }, nil
}, },
"rotate": func() (cli.Command, error) { "rotate": func() (cli.Command, error) {
return &command.RotateCommand{ return &command.RotateCommand{
Meta: meta, Meta: *metaPtr,
}, nil }, nil
}, },
"unmount": func() (cli.Command, error) { "unmount": func() (cli.Command, error) {
return &command.UnmountCommand{ return &command.UnmountCommand{
Meta: meta, Meta: *metaPtr,
}, nil }, nil
}, },
"token-create": func() (cli.Command, error) { "token-create": func() (cli.Command, error) {
return &command.TokenCreateCommand{ return &command.TokenCreateCommand{
Meta: meta, Meta: *metaPtr,
}, nil }, nil
}, },
"token-lookup": func() (cli.Command, error) { "token-lookup": func() (cli.Command, error) {
return &command.TokenLookupCommand{ return &command.TokenLookupCommand{
Meta: meta, Meta: *metaPtr,
}, nil }, nil
}, },
"token-renew": func() (cli.Command, error) { "token-renew": func() (cli.Command, error) {
return &command.TokenRenewCommand{ return &command.TokenRenewCommand{
Meta: meta, Meta: *metaPtr,
}, nil }, nil
}, },
"token-revoke": func() (cli.Command, error) { "token-revoke": func() (cli.Command, error) {
return &command.TokenRevokeCommand{ return &command.TokenRevokeCommand{
Meta: meta, Meta: *metaPtr,
}, nil }, nil
}, },
"capabilities": func() (cli.Command, error) { "capabilities": func() (cli.Command, error) {
return &command.CapabilitiesCommand{ return &command.CapabilitiesCommand{
Meta: meta, Meta: *metaPtr,
}, nil }, nil
}, },
@@ -304,7 +304,7 @@ func Commands(metaPtr *command.Meta) map[string]cli.CommandFactory {
return &command.VersionCommand{ return &command.VersionCommand{
VersionInfo: versionInfo, VersionInfo: versionInfo,
Ui: meta.Ui, Ui: metaPtr.Ui,
}, nil }, nil
}, },
} }

View File

@@ -3,15 +3,17 @@ package command
import ( import (
"fmt" "fmt"
"strings" "strings"
"github.com/hashicorp/vault/meta"
) )
// AuditDisableCommand is a Command that mounts a new mount. // AuditDisableCommand is a Command that mounts a new mount.
type AuditDisableCommand struct { type AuditDisableCommand struct {
Meta meta.Meta
} }
func (c *AuditDisableCommand) Run(args []string) int { func (c *AuditDisableCommand) Run(args []string) int {
flags := c.Meta.FlagSet("mount", FlagSetDefault) flags := c.Meta.FlagSet("mount", meta.FlagSetDefault)
flags.Usage = func() { c.Ui.Error(c.Help()) } flags.Usage = func() { c.Ui.Error(c.Help()) }
if err := flags.Parse(args); err != nil { if err := flags.Parse(args); err != nil {
return 1 return 1
@@ -64,6 +66,6 @@ Usage: vault audit-disable [options] id
General Options: General Options:
` + generalOptionsUsage() ` + meta.GeneralOptionsUsage()
return strings.TrimSpace(helpText) return strings.TrimSpace(helpText)
} }

View File

@@ -4,6 +4,7 @@ import (
"testing" "testing"
"github.com/hashicorp/vault/http" "github.com/hashicorp/vault/http"
"github.com/hashicorp/vault/meta"
"github.com/hashicorp/vault/vault" "github.com/hashicorp/vault/vault"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
) )
@@ -15,7 +16,7 @@ func TestAuditDisable(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &AuditDisableCommand{ c := &AuditDisableCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },

View File

@@ -7,12 +7,13 @@ import (
"strings" "strings"
"github.com/hashicorp/vault/helper/kv-builder" "github.com/hashicorp/vault/helper/kv-builder"
"github.com/hashicorp/vault/meta"
"github.com/mitchellh/mapstructure" "github.com/mitchellh/mapstructure"
) )
// AuditEnableCommand is a Command that mounts a new mount. // AuditEnableCommand is a Command that mounts a new mount.
type AuditEnableCommand struct { type AuditEnableCommand struct {
Meta meta.Meta
// A test stdin that can be used for tests // A test stdin that can be used for tests
testStdin io.Reader testStdin io.Reader
@@ -20,7 +21,7 @@ type AuditEnableCommand struct {
func (c *AuditEnableCommand) Run(args []string) int { func (c *AuditEnableCommand) Run(args []string) int {
var desc, path string var desc, path string
flags := c.Meta.FlagSet("audit-enable", FlagSetDefault) flags := c.Meta.FlagSet("audit-enable", meta.FlagSetDefault)
flags.StringVar(&desc, "description", "", "") flags.StringVar(&desc, "description", "", "")
flags.StringVar(&path, "path", "", "") flags.StringVar(&path, "path", "", "")
flags.Usage = func() { c.Ui.Error(c.Help()) } flags.Usage = func() { c.Ui.Error(c.Help()) }
@@ -96,7 +97,7 @@ Usage: vault audit-enable [options] type [config...]
General Options: General Options:
` + generalOptionsUsage() + ` ` + meta.GeneralOptionsUsage() + `
Audit Enable Options: Audit Enable Options:

View File

@@ -5,6 +5,7 @@ import (
"testing" "testing"
"github.com/hashicorp/vault/http" "github.com/hashicorp/vault/http"
"github.com/hashicorp/vault/meta"
"github.com/hashicorp/vault/vault" "github.com/hashicorp/vault/vault"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
) )
@@ -16,7 +17,7 @@ func TestAuditEnable(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &AuditEnableCommand{ c := &AuditEnableCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },

View File

@@ -5,16 +5,17 @@ import (
"sort" "sort"
"strings" "strings"
"github.com/hashicorp/vault/meta"
"github.com/ryanuber/columnize" "github.com/ryanuber/columnize"
) )
// AuditListCommand is a Command that lists the enabled audits. // AuditListCommand is a Command that lists the enabled audits.
type AuditListCommand struct { type AuditListCommand struct {
Meta meta.Meta
} }
func (c *AuditListCommand) Run(args []string) int { func (c *AuditListCommand) Run(args []string) int {
flags := c.Meta.FlagSet("audit-list", FlagSetDefault) flags := c.Meta.FlagSet("audit-list", meta.FlagSetDefault)
flags.Usage = func() { c.Ui.Error(c.Help()) } flags.Usage = func() { c.Ui.Error(c.Help()) }
if err := flags.Parse(args); err != nil { if err := flags.Parse(args); err != nil {
return 1 return 1
@@ -79,6 +80,6 @@ Usage: vault audit-list [options]
General Options: General Options:
` + generalOptionsUsage() ` + meta.GeneralOptionsUsage()
return strings.TrimSpace(helpText) return strings.TrimSpace(helpText)
} }

View File

@@ -4,6 +4,7 @@ import (
"testing" "testing"
"github.com/hashicorp/vault/http" "github.com/hashicorp/vault/http"
"github.com/hashicorp/vault/meta"
"github.com/hashicorp/vault/vault" "github.com/hashicorp/vault/vault"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
) )
@@ -15,7 +16,7 @@ func TestAuditList(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &AuditListCommand{ c := &AuditListCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },

View File

@@ -11,6 +11,7 @@ import (
"github.com/hashicorp/vault/api" "github.com/hashicorp/vault/api"
"github.com/hashicorp/vault/helper/kv-builder" "github.com/hashicorp/vault/helper/kv-builder"
"github.com/hashicorp/vault/helper/password" "github.com/hashicorp/vault/helper/password"
"github.com/hashicorp/vault/meta"
"github.com/mitchellh/mapstructure" "github.com/mitchellh/mapstructure"
"github.com/ryanuber/columnize" "github.com/ryanuber/columnize"
) )
@@ -24,7 +25,7 @@ type AuthHandler interface {
// AuthCommand is a Command that handles authentication. // AuthCommand is a Command that handles authentication.
type AuthCommand struct { type AuthCommand struct {
Meta meta.Meta
Handlers map[string]AuthHandler Handlers map[string]AuthHandler
@@ -35,7 +36,7 @@ type AuthCommand struct {
func (c *AuthCommand) Run(args []string) int { func (c *AuthCommand) Run(args []string) int {
var method string var method string
var methods, methodHelp, noVerify bool var methods, methodHelp, noVerify bool
flags := c.Meta.FlagSet("auth", FlagSetDefault) flags := c.Meta.FlagSet("auth", meta.FlagSetDefault)
flags.BoolVar(&methods, "methods", false, "") flags.BoolVar(&methods, "methods", false, "")
flags.BoolVar(&methodHelp, "method-help", false, "") flags.BoolVar(&methodHelp, "method-help", false, "")
flags.BoolVar(&noVerify, "no-verify", false, "") flags.BoolVar(&noVerify, "no-verify", false, "")
@@ -299,7 +300,7 @@ Usage: vault auth [options] [token or config...]
General Options: General Options:
` + generalOptionsUsage() + ` ` + meta.GeneralOptionsUsage() + `
Auth Options: Auth Options:

View File

@@ -3,15 +3,17 @@ package command
import ( import (
"fmt" "fmt"
"strings" "strings"
"github.com/hashicorp/vault/meta"
) )
// AuthDisableCommand is a Command that enables a new endpoint. // AuthDisableCommand is a Command that enables a new endpoint.
type AuthDisableCommand struct { type AuthDisableCommand struct {
Meta meta.Meta
} }
func (c *AuthDisableCommand) Run(args []string) int { func (c *AuthDisableCommand) Run(args []string) int {
flags := c.Meta.FlagSet("auth-disable", FlagSetDefault) flags := c.Meta.FlagSet("auth-disable", meta.FlagSetDefault)
flags.Usage = func() { c.Ui.Error(c.Help()) } flags.Usage = func() { c.Ui.Error(c.Help()) }
if err := flags.Parse(args); err != nil { if err := flags.Parse(args); err != nil {
return 1 return 1
@@ -63,6 +65,6 @@ Usage: vault auth-disable [options] path
General Options: General Options:
` + generalOptionsUsage() ` + meta.GeneralOptionsUsage()
return strings.TrimSpace(helpText) return strings.TrimSpace(helpText)
} }

View File

@@ -4,6 +4,7 @@ import (
"testing" "testing"
"github.com/hashicorp/vault/http" "github.com/hashicorp/vault/http"
"github.com/hashicorp/vault/meta"
"github.com/hashicorp/vault/vault" "github.com/hashicorp/vault/vault"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
) )
@@ -15,7 +16,7 @@ func TestAuthDisable(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &AuthDisableCommand{ c := &AuthDisableCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },

View File

@@ -3,16 +3,18 @@ package command
import ( import (
"fmt" "fmt"
"strings" "strings"
"github.com/hashicorp/vault/meta"
) )
// AuthEnableCommand is a Command that enables a new endpoint. // AuthEnableCommand is a Command that enables a new endpoint.
type AuthEnableCommand struct { type AuthEnableCommand struct {
Meta meta.Meta
} }
func (c *AuthEnableCommand) Run(args []string) int { func (c *AuthEnableCommand) Run(args []string) int {
var description, path string var description, path string
flags := c.Meta.FlagSet("auth-enable", FlagSetDefault) flags := c.Meta.FlagSet("auth-enable", meta.FlagSetDefault)
flags.StringVar(&description, "description", "", "") flags.StringVar(&description, "description", "", "")
flags.StringVar(&path, "path", "", "") flags.StringVar(&path, "path", "", "")
flags.Usage = func() { c.Ui.Error(c.Help()) } flags.Usage = func() { c.Ui.Error(c.Help()) }
@@ -71,7 +73,7 @@ Usage: vault auth-enable [options] type
General Options: General Options:
` + generalOptionsUsage() + ` ` + meta.GeneralOptionsUsage() + `
Auth Enable Options: Auth Enable Options:

View File

@@ -4,6 +4,7 @@ import (
"testing" "testing"
"github.com/hashicorp/vault/http" "github.com/hashicorp/vault/http"
"github.com/hashicorp/vault/meta"
"github.com/hashicorp/vault/vault" "github.com/hashicorp/vault/vault"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
) )
@@ -15,7 +16,7 @@ func TestAuthEnable(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &AuthEnableCommand{ c := &AuthEnableCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },

View File

@@ -11,6 +11,7 @@ import (
"github.com/hashicorp/vault/api" "github.com/hashicorp/vault/api"
"github.com/hashicorp/vault/http" "github.com/hashicorp/vault/http"
"github.com/hashicorp/vault/meta"
"github.com/hashicorp/vault/vault" "github.com/hashicorp/vault/vault"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
) )
@@ -24,7 +25,7 @@ func TestAuth_methods(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &AuthCommand{ c := &AuthCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },
@@ -53,7 +54,7 @@ func TestAuth_token(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &AuthCommand{ c := &AuthCommand{
Meta: Meta{ Meta: meta.Meta{
Ui: ui, Ui: ui,
}, },
} }
@@ -91,7 +92,7 @@ func TestAuth_stdin(t *testing.T) {
stdinR, stdinW := io.Pipe() stdinR, stdinW := io.Pipe()
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &AuthCommand{ c := &AuthCommand{
Meta: Meta{ Meta: meta.Meta{
Ui: ui, Ui: ui,
}, },
testStdin: stdinR, testStdin: stdinR,
@@ -120,7 +121,7 @@ func TestAuth_badToken(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &AuthCommand{ c := &AuthCommand{
Meta: Meta{ Meta: meta.Meta{
Ui: ui, Ui: ui,
}, },
} }
@@ -146,7 +147,7 @@ func TestAuth_method(t *testing.T) {
Handlers: map[string]AuthHandler{ Handlers: map[string]AuthHandler{
"test": &testAuthHandler{}, "test": &testAuthHandler{},
}, },
Meta: Meta{ Meta: meta.Meta{
Ui: ui, Ui: ui,
}, },
} }

View File

@@ -3,15 +3,17 @@ package command
import ( import (
"fmt" "fmt"
"strings" "strings"
"github.com/hashicorp/vault/meta"
) )
// CapabilitiesCommand is a Command that enables a new endpoint. // CapabilitiesCommand is a Command that enables a new endpoint.
type CapabilitiesCommand struct { type CapabilitiesCommand struct {
Meta meta.Meta
} }
func (c *CapabilitiesCommand) Run(args []string) int { func (c *CapabilitiesCommand) Run(args []string) int {
flags := c.Meta.FlagSet("capabilities", FlagSetDefault) flags := c.Meta.FlagSet("capabilities", meta.FlagSetDefault)
flags.Usage = func() { c.Ui.Error(c.Help()) } flags.Usage = func() { c.Ui.Error(c.Help()) }
if err := flags.Parse(args); err != nil { if err := flags.Parse(args); err != nil {
return 1 return 1
@@ -81,6 +83,6 @@ Usage: vault capabilities [options] [token] path
General Options: General Options:
` + generalOptionsUsage() ` + meta.GeneralOptionsUsage()
return strings.TrimSpace(helpText) return strings.TrimSpace(helpText)
} }

View File

@@ -4,6 +4,7 @@ import (
"testing" "testing"
"github.com/hashicorp/vault/http" "github.com/hashicorp/vault/http"
"github.com/hashicorp/vault/meta"
"github.com/hashicorp/vault/vault" "github.com/hashicorp/vault/vault"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
) )
@@ -14,7 +15,7 @@ func TestCapabilities_Basic(t *testing.T) {
defer ln.Close() defer ln.Close()
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &CapabilitiesCommand{ c := &CapabilitiesCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },

View File

@@ -3,15 +3,17 @@ package command
import ( import (
"fmt" "fmt"
"strings" "strings"
"github.com/hashicorp/vault/meta"
) )
// DeleteCommand is a Command that puts data into the Vault. // DeleteCommand is a Command that puts data into the Vault.
type DeleteCommand struct { type DeleteCommand struct {
Meta meta.Meta
} }
func (c *DeleteCommand) Run(args []string) int { func (c *DeleteCommand) Run(args []string) int {
flags := c.Meta.FlagSet("delete", FlagSetDefault) flags := c.Meta.FlagSet("delete", meta.FlagSetDefault)
flags.Usage = func() { c.Ui.Error(c.Help()) } flags.Usage = func() { c.Ui.Error(c.Help()) }
if err := flags.Parse(args); err != nil { if err := flags.Parse(args); err != nil {
return 1 return 1
@@ -61,6 +63,6 @@ Usage: vault delete [options] path
General Options: General Options:
` + generalOptionsUsage() ` + meta.GeneralOptionsUsage()
return strings.TrimSpace(helpText) return strings.TrimSpace(helpText)
} }

View File

@@ -4,6 +4,7 @@ import (
"testing" "testing"
"github.com/hashicorp/vault/http" "github.com/hashicorp/vault/http"
"github.com/hashicorp/vault/meta"
"github.com/hashicorp/vault/vault" "github.com/hashicorp/vault/vault"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
) )
@@ -15,7 +16,7 @@ func TestDelete(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &DeleteCommand{ c := &DeleteCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },

View File

@@ -2,10 +2,11 @@ package command
import ( import (
"encoding/json" "encoding/json"
"github.com/ghodss/yaml"
"github.com/hashicorp/vault/api"
"strings" "strings"
"testing" "testing"
"github.com/ghodss/yaml"
"github.com/hashicorp/vault/api"
) )
var output string var output string

View File

@@ -12,11 +12,12 @@ import (
"github.com/hashicorp/vault/helper/password" "github.com/hashicorp/vault/helper/password"
"github.com/hashicorp/vault/helper/pgpkeys" "github.com/hashicorp/vault/helper/pgpkeys"
"github.com/hashicorp/vault/helper/xor" "github.com/hashicorp/vault/helper/xor"
"github.com/hashicorp/vault/meta"
) )
// GenerateRootCommand is a Command that generates a new root token. // GenerateRootCommand is a Command that generates a new root token.
type GenerateRootCommand struct { type GenerateRootCommand struct {
Meta meta.Meta
// Key can be used to pre-seed the key. If it is set, it will not // Key can be used to pre-seed the key. If it is set, it will not
// be asked with the `password` helper. // be asked with the `password` helper.
@@ -30,7 +31,7 @@ func (c *GenerateRootCommand) Run(args []string) int {
var init, cancel, status, genotp bool var init, cancel, status, genotp bool
var nonce, decode, otp, pgpKey string var nonce, decode, otp, pgpKey string
var pgpKeyArr pgpkeys.PubKeyFilesFlag var pgpKeyArr pgpkeys.PubKeyFilesFlag
flags := c.Meta.FlagSet("generate-root", FlagSetDefault) flags := c.Meta.FlagSet("generate-root", meta.FlagSetDefault)
flags.BoolVar(&init, "init", false, "") flags.BoolVar(&init, "init", false, "")
flags.BoolVar(&cancel, "cancel", false, "") flags.BoolVar(&cancel, "cancel", false, "")
flags.BoolVar(&status, "status", false, "") flags.BoolVar(&status, "status", false, "")
@@ -315,7 +316,7 @@ Usage: vault generate-root [options] [key]
General Options: General Options:
` + generalOptionsUsage() + ` ` + meta.GeneralOptionsUsage() + `
Rekey Options: Rekey Options:

View File

@@ -12,6 +12,7 @@ import (
"github.com/hashicorp/vault/helper/xor" "github.com/hashicorp/vault/helper/xor"
"github.com/hashicorp/vault/http" "github.com/hashicorp/vault/http"
"github.com/hashicorp/vault/logical" "github.com/hashicorp/vault/logical"
"github.com/hashicorp/vault/meta"
"github.com/hashicorp/vault/vault" "github.com/hashicorp/vault/vault"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
) )
@@ -24,7 +25,7 @@ func TestGenerateRoot_Cancel(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &GenerateRootCommand{ c := &GenerateRootCommand{
Key: hex.EncodeToString(key), Key: hex.EncodeToString(key),
Meta: Meta{ Meta: meta.Meta{
Ui: ui, Ui: ui,
}, },
} }
@@ -62,7 +63,7 @@ func TestGenerateRoot_status(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &GenerateRootCommand{ c := &GenerateRootCommand{
Key: hex.EncodeToString(key), Key: hex.EncodeToString(key),
Meta: Meta{ Meta: meta.Meta{
Ui: ui, Ui: ui,
}, },
} }
@@ -96,7 +97,7 @@ func TestGenerateRoot_OTP(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &GenerateRootCommand{ c := &GenerateRootCommand{
Key: hex.EncodeToString(key), Key: hex.EncodeToString(key),
Meta: Meta{ Meta: meta.Meta{
Ui: ui, Ui: ui,
}, },
} }
@@ -201,7 +202,7 @@ func TestGenerateRoot_PGP(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &GenerateRootCommand{ c := &GenerateRootCommand{
Key: hex.EncodeToString(key), Key: hex.EncodeToString(key),
Meta: Meta{ Meta: meta.Meta{
Ui: ui, Ui: ui,
}, },
} }

View File

@@ -6,18 +6,19 @@ import (
"github.com/hashicorp/vault/api" "github.com/hashicorp/vault/api"
"github.com/hashicorp/vault/helper/pgpkeys" "github.com/hashicorp/vault/helper/pgpkeys"
"github.com/hashicorp/vault/meta"
) )
// InitCommand is a Command that initializes a new Vault server. // InitCommand is a Command that initializes a new Vault server.
type InitCommand struct { type InitCommand struct {
Meta meta.Meta
} }
func (c *InitCommand) Run(args []string) int { func (c *InitCommand) Run(args []string) int {
var threshold, shares int var threshold, shares int
var pgpKeys pgpkeys.PubKeyFilesFlag var pgpKeys pgpkeys.PubKeyFilesFlag
var check bool var check bool
flags := c.Meta.FlagSet("init", FlagSetDefault) flags := c.Meta.FlagSet("init", meta.FlagSetDefault)
flags.Usage = func() { c.Ui.Error(c.Help()) } flags.Usage = func() { c.Ui.Error(c.Help()) }
flags.IntVar(&shares, "key-shares", 5, "") flags.IntVar(&shares, "key-shares", 5, "")
flags.IntVar(&threshold, "key-threshold", 3, "") flags.IntVar(&threshold, "key-threshold", 3, "")
@@ -106,7 +107,7 @@ Usage: vault init [options]
General Options: General Options:
` + generalOptionsUsage() + ` ` + meta.GeneralOptionsUsage() + `
Init Options: Init Options:

View File

@@ -8,6 +8,7 @@ import (
"github.com/hashicorp/vault/helper/pgpkeys" "github.com/hashicorp/vault/helper/pgpkeys"
"github.com/hashicorp/vault/http" "github.com/hashicorp/vault/http"
"github.com/hashicorp/vault/meta"
"github.com/hashicorp/vault/vault" "github.com/hashicorp/vault/vault"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
) )
@@ -15,7 +16,7 @@ import (
func TestInit(t *testing.T) { func TestInit(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &InitCommand{ c := &InitCommand{
Meta: Meta{ Meta: meta.Meta{
Ui: ui, Ui: ui,
}, },
} }
@@ -61,7 +62,7 @@ func TestInit(t *testing.T) {
func TestInit_Check(t *testing.T) { func TestInit_Check(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &InitCommand{ c := &InitCommand{
Meta: Meta{ Meta: meta.Meta{
Ui: ui, Ui: ui,
}, },
} }
@@ -100,7 +101,7 @@ func TestInit_Check(t *testing.T) {
func TestInit_custom(t *testing.T) { func TestInit_custom(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &InitCommand{ c := &InitCommand{
Meta: Meta{ Meta: meta.Meta{
Ui: ui, Ui: ui,
}, },
} }
@@ -150,7 +151,7 @@ func TestInit_custom(t *testing.T) {
func TestInit_PGP(t *testing.T) { func TestInit_PGP(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &InitCommand{ c := &InitCommand{
Meta: Meta{ Meta: meta.Meta{
Ui: ui, Ui: ui,
}, },
} }

View File

@@ -3,15 +3,17 @@ package command
import ( import (
"fmt" "fmt"
"strings" "strings"
"github.com/hashicorp/vault/meta"
) )
// KeyStatusCommand is a Command that provides information about the key status // KeyStatusCommand is a Command that provides information about the key status
type KeyStatusCommand struct { type KeyStatusCommand struct {
Meta meta.Meta
} }
func (c *KeyStatusCommand) Run(args []string) int { func (c *KeyStatusCommand) Run(args []string) int {
flags := c.Meta.FlagSet("key-status", FlagSetDefault) flags := c.Meta.FlagSet("key-status", meta.FlagSetDefault)
flags.Usage = func() { c.Ui.Error(c.Help()) } flags.Usage = func() { c.Ui.Error(c.Help()) }
if err := flags.Parse(args); err != nil { if err := flags.Parse(args); err != nil {
return 1 return 1
@@ -49,6 +51,6 @@ Usage: vault key-status [options]
General Options: General Options:
` + generalOptionsUsage() ` + meta.GeneralOptionsUsage()
return strings.TrimSpace(helpText) return strings.TrimSpace(helpText)
} }

View File

@@ -4,6 +4,7 @@ import (
"testing" "testing"
"github.com/hashicorp/vault/http" "github.com/hashicorp/vault/http"
"github.com/hashicorp/vault/meta"
"github.com/hashicorp/vault/vault" "github.com/hashicorp/vault/vault"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
) )
@@ -15,7 +16,7 @@ func TestKeyStatus(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &KeyStatusCommand{ c := &KeyStatusCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },

View File

@@ -6,11 +6,12 @@ import (
"strings" "strings"
"github.com/hashicorp/vault/api" "github.com/hashicorp/vault/api"
"github.com/hashicorp/vault/meta"
) )
// ListCommand is a Command that lists data from the Vault. // ListCommand is a Command that lists data from the Vault.
type ListCommand struct { type ListCommand struct {
Meta meta.Meta
} }
func (c *ListCommand) Run(args []string) int { func (c *ListCommand) Run(args []string) int {
@@ -18,7 +19,7 @@ func (c *ListCommand) Run(args []string) int {
var err error var err error
var secret *api.Secret var secret *api.Secret
var flags *flag.FlagSet var flags *flag.FlagSet
flags = c.Meta.FlagSet("list", FlagSetDefault) flags = c.Meta.FlagSet("list", meta.FlagSetDefault)
flags.StringVar(&format, "format", "table", "") flags.StringVar(&format, "format", "table", "")
flags.Usage = func() { c.Ui.Error(c.Help()) } flags.Usage = func() { c.Ui.Error(c.Help()) }
if err := flags.Parse(args); err != nil { if err := flags.Parse(args); err != nil {
@@ -83,7 +84,7 @@ Usage: vault list [options] path
General Options: General Options:
` + generalOptionsUsage() + ` ` + meta.GeneralOptionsUsage() + `
Read Options: Read Options:

View File

@@ -5,6 +5,7 @@ import (
"testing" "testing"
"github.com/hashicorp/vault/http" "github.com/hashicorp/vault/http"
"github.com/hashicorp/vault/meta"
"github.com/hashicorp/vault/vault" "github.com/hashicorp/vault/vault"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
) )
@@ -16,7 +17,7 @@ func TestList(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &ReadCommand{ c := &ReadCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },

View File

@@ -5,16 +5,17 @@ import (
"strings" "strings"
"github.com/hashicorp/vault/api" "github.com/hashicorp/vault/api"
"github.com/hashicorp/vault/meta"
) )
// MountCommand is a Command that mounts a new mount. // MountCommand is a Command that mounts a new mount.
type MountCommand struct { type MountCommand struct {
Meta meta.Meta
} }
func (c *MountCommand) Run(args []string) int { func (c *MountCommand) Run(args []string) int {
var description, path, defaultLeaseTTL, maxLeaseTTL string var description, path, defaultLeaseTTL, maxLeaseTTL string
flags := c.Meta.FlagSet("mount", FlagSetDefault) flags := c.Meta.FlagSet("mount", meta.FlagSetDefault)
flags.StringVar(&description, "description", "", "") flags.StringVar(&description, "description", "", "")
flags.StringVar(&path, "path", "", "") flags.StringVar(&path, "path", "", "")
flags.StringVar(&defaultLeaseTTL, "default-lease-ttl", "", "") flags.StringVar(&defaultLeaseTTL, "default-lease-ttl", "", "")
@@ -83,7 +84,7 @@ Usage: vault mount [options] type
General Options: General Options:
` + generalOptionsUsage() + ` ` + meta.GeneralOptionsUsage() + `
Mount Options: Mount Options:

View File

@@ -4,6 +4,7 @@ import (
"testing" "testing"
"github.com/hashicorp/vault/http" "github.com/hashicorp/vault/http"
"github.com/hashicorp/vault/meta"
"github.com/hashicorp/vault/vault" "github.com/hashicorp/vault/vault"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
) )
@@ -15,7 +16,7 @@ func TestMount(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &MountCommand{ c := &MountCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },

View File

@@ -6,16 +6,17 @@ import (
"strconv" "strconv"
"strings" "strings"
"github.com/hashicorp/vault/meta"
"github.com/ryanuber/columnize" "github.com/ryanuber/columnize"
) )
// MountsCommand is a Command that lists the mounts. // MountsCommand is a Command that lists the mounts.
type MountsCommand struct { type MountsCommand struct {
Meta meta.Meta
} }
func (c *MountsCommand) Run(args []string) int { func (c *MountsCommand) Run(args []string) int {
flags := c.Meta.FlagSet("mounts", FlagSetDefault) flags := c.Meta.FlagSet("mounts", meta.FlagSetDefault)
flags.Usage = func() { c.Ui.Error(c.Help()) } flags.Usage = func() { c.Ui.Error(c.Help()) }
if err := flags.Parse(args); err != nil { if err := flags.Parse(args); err != nil {
return 1 return 1
@@ -86,6 +87,6 @@ Usage: vault mounts [options]
General Options: General Options:
` + generalOptionsUsage() ` + meta.GeneralOptionsUsage()
return strings.TrimSpace(helpText) return strings.TrimSpace(helpText)
} }

View File

@@ -4,6 +4,7 @@ import (
"testing" "testing"
"github.com/hashicorp/vault/http" "github.com/hashicorp/vault/http"
"github.com/hashicorp/vault/meta"
"github.com/hashicorp/vault/vault" "github.com/hashicorp/vault/vault"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
) )
@@ -15,7 +16,7 @@ func TestMounts(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &MountsCommand{ c := &MountsCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },

View File

@@ -5,17 +5,18 @@ import (
"strings" "strings"
"github.com/hashicorp/vault/api" "github.com/hashicorp/vault/api"
"github.com/hashicorp/vault/meta"
) )
// MountTuneCommand is a Command that remounts a mounted secret backend // MountTuneCommand is a Command that remounts a mounted secret backend
// to a new endpoint. // to a new endpoint.
type MountTuneCommand struct { type MountTuneCommand struct {
Meta meta.Meta
} }
func (c *MountTuneCommand) Run(args []string) int { func (c *MountTuneCommand) Run(args []string) int {
var defaultLeaseTTL, maxLeaseTTL string var defaultLeaseTTL, maxLeaseTTL string
flags := c.Meta.FlagSet("mount-tune", FlagSetDefault) flags := c.Meta.FlagSet("mount-tune", meta.FlagSetDefault)
flags.StringVar(&defaultLeaseTTL, "default-lease-ttl", "", "") flags.StringVar(&defaultLeaseTTL, "default-lease-ttl", "", "")
flags.StringVar(&maxLeaseTTL, "max-lease-ttl", "", "") flags.StringVar(&maxLeaseTTL, "max-lease-ttl", "", "")
flags.Usage = func() { c.Ui.Error(c.Help()) } flags.Usage = func() { c.Ui.Error(c.Help()) }
@@ -71,7 +72,7 @@ func (c *MountTuneCommand) Help() string {
General Options: General Options:
` + generalOptionsUsage() + ` ` + meta.GeneralOptionsUsage() + `
Mount Options: Mount Options:

View File

@@ -3,15 +3,17 @@ package command
import ( import (
"fmt" "fmt"
"strings" "strings"
"github.com/hashicorp/vault/meta"
) )
// PathHelpCommand is a Command that lists the mounts. // PathHelpCommand is a Command that lists the mounts.
type PathHelpCommand struct { type PathHelpCommand struct {
Meta meta.Meta
} }
func (c *PathHelpCommand) Run(args []string) int { func (c *PathHelpCommand) Run(args []string) int {
flags := c.Meta.FlagSet("help", FlagSetDefault) flags := c.Meta.FlagSet("help", meta.FlagSetDefault)
flags.Usage = func() { c.Ui.Error(c.Help()) } flags.Usage = func() { c.Ui.Error(c.Help()) }
if err := flags.Parse(args); err != nil { if err := flags.Parse(args); err != nil {
return 1 return 1
@@ -70,6 +72,6 @@ Usage: vault path-help [options] path
General Options: General Options:
` + generalOptionsUsage() ` + meta.GeneralOptionsUsage()
return strings.TrimSpace(helpText) return strings.TrimSpace(helpText)
} }

View File

@@ -4,6 +4,7 @@ import (
"testing" "testing"
"github.com/hashicorp/vault/http" "github.com/hashicorp/vault/http"
"github.com/hashicorp/vault/meta"
"github.com/hashicorp/vault/vault" "github.com/hashicorp/vault/vault"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
) )
@@ -15,7 +16,7 @@ func TestHelp(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &PathHelpCommand{ c := &PathHelpCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },

View File

@@ -3,15 +3,17 @@ package command
import ( import (
"fmt" "fmt"
"strings" "strings"
"github.com/hashicorp/vault/meta"
) )
// PolicyDeleteCommand is a Command that enables a new endpoint. // PolicyDeleteCommand is a Command that enables a new endpoint.
type PolicyDeleteCommand struct { type PolicyDeleteCommand struct {
Meta meta.Meta
} }
func (c *PolicyDeleteCommand) Run(args []string) int { func (c *PolicyDeleteCommand) Run(args []string) int {
flags := c.Meta.FlagSet("policy-delete", FlagSetDefault) flags := c.Meta.FlagSet("policy-delete", meta.FlagSetDefault)
flags.Usage = func() { c.Ui.Error(c.Help()) } flags.Usage = func() { c.Ui.Error(c.Help()) }
if err := flags.Parse(args); err != nil { if err := flags.Parse(args); err != nil {
return 1 return 1
@@ -59,6 +61,6 @@ Usage: vault policy-delete [options] name
General Options: General Options:
` + generalOptionsUsage() ` + meta.GeneralOptionsUsage()
return strings.TrimSpace(helpText) return strings.TrimSpace(helpText)
} }

View File

@@ -4,6 +4,7 @@ import (
"testing" "testing"
"github.com/hashicorp/vault/http" "github.com/hashicorp/vault/http"
"github.com/hashicorp/vault/meta"
"github.com/hashicorp/vault/vault" "github.com/hashicorp/vault/vault"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
) )
@@ -15,7 +16,7 @@ func TestPolicyDelete(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &PolicyDeleteCommand{ c := &PolicyDeleteCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },

View File

@@ -3,15 +3,17 @@ package command
import ( import (
"fmt" "fmt"
"strings" "strings"
"github.com/hashicorp/vault/meta"
) )
// PolicyListCommand is a Command that enables a new endpoint. // PolicyListCommand is a Command that enables a new endpoint.
type PolicyListCommand struct { type PolicyListCommand struct {
Meta meta.Meta
} }
func (c *PolicyListCommand) Run(args []string) int { func (c *PolicyListCommand) Run(args []string) int {
flags := c.Meta.FlagSet("policy-list", FlagSetDefault) flags := c.Meta.FlagSet("policy-list", meta.FlagSetDefault)
flags.Usage = func() { c.Ui.Error(c.Help()) } flags.Usage = func() { c.Ui.Error(c.Help()) }
if err := flags.Parse(args); err != nil { if err := flags.Parse(args); err != nil {
return 1 return 1
@@ -86,6 +88,6 @@ Usage: vault policies [options] [name]
General Options: General Options:
` + generalOptionsUsage() ` + meta.GeneralOptionsUsage()
return strings.TrimSpace(helpText) return strings.TrimSpace(helpText)
} }

View File

@@ -4,6 +4,7 @@ import (
"testing" "testing"
"github.com/hashicorp/vault/http" "github.com/hashicorp/vault/http"
"github.com/hashicorp/vault/meta"
"github.com/hashicorp/vault/vault" "github.com/hashicorp/vault/vault"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
) )
@@ -15,7 +16,7 @@ func TestPolicyList(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &PolicyListCommand{ c := &PolicyListCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },
@@ -36,7 +37,7 @@ func TestPolicyRead(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &PolicyListCommand{ c := &PolicyListCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },

View File

@@ -6,15 +6,17 @@ import (
"io" "io"
"os" "os"
"strings" "strings"
"github.com/hashicorp/vault/meta"
) )
// PolicyWriteCommand is a Command that enables a new endpoint. // PolicyWriteCommand is a Command that enables a new endpoint.
type PolicyWriteCommand struct { type PolicyWriteCommand struct {
Meta meta.Meta
} }
func (c *PolicyWriteCommand) Run(args []string) int { func (c *PolicyWriteCommand) Run(args []string) int {
flags := c.Meta.FlagSet("policy-write", FlagSetDefault) flags := c.Meta.FlagSet("policy-write", meta.FlagSetDefault)
flags.Usage = func() { c.Ui.Error(c.Help()) } flags.Usage = func() { c.Ui.Error(c.Help()) }
if err := flags.Parse(args); err != nil { if err := flags.Parse(args); err != nil {
return 1 return 1
@@ -83,6 +85,6 @@ Usage: vault policy-write [options] name path
General Options: General Options:
` + generalOptionsUsage() ` + meta.GeneralOptionsUsage()
return strings.TrimSpace(helpText) return strings.TrimSpace(helpText)
} }

View File

@@ -4,6 +4,7 @@ import (
"testing" "testing"
"github.com/hashicorp/vault/http" "github.com/hashicorp/vault/http"
"github.com/hashicorp/vault/meta"
"github.com/hashicorp/vault/vault" "github.com/hashicorp/vault/vault"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
) )
@@ -15,7 +16,7 @@ func TestPolicyWrite(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &PolicyWriteCommand{ c := &PolicyWriteCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },

View File

@@ -8,11 +8,12 @@ import (
"strings" "strings"
"github.com/hashicorp/vault/api" "github.com/hashicorp/vault/api"
"github.com/hashicorp/vault/meta"
) )
// ReadCommand is a Command that reads data from the Vault. // ReadCommand is a Command that reads data from the Vault.
type ReadCommand struct { type ReadCommand struct {
Meta meta.Meta
} }
func (c *ReadCommand) Run(args []string) int { func (c *ReadCommand) Run(args []string) int {
@@ -21,7 +22,7 @@ func (c *ReadCommand) Run(args []string) int {
var err error var err error
var secret *api.Secret var secret *api.Secret
var flags *flag.FlagSet var flags *flag.FlagSet
flags = c.Meta.FlagSet("read", FlagSetDefault) flags = c.Meta.FlagSet("read", meta.FlagSetDefault)
flags.StringVar(&format, "format", "table", "") flags.StringVar(&format, "format", "table", "")
flags.StringVar(&field, "field", "", "") flags.StringVar(&field, "field", "", "")
flags.Usage = func() { c.Ui.Error(c.Help()) } flags.Usage = func() { c.Ui.Error(c.Help()) }
@@ -101,7 +102,7 @@ Usage: vault read [options] path
General Options: General Options:
` + generalOptionsUsage() + ` ` + meta.GeneralOptionsUsage() + `
Read Options: Read Options:

View File

@@ -4,6 +4,7 @@ import (
"testing" "testing"
"github.com/hashicorp/vault/http" "github.com/hashicorp/vault/http"
"github.com/hashicorp/vault/meta"
"github.com/hashicorp/vault/vault" "github.com/hashicorp/vault/vault"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
) )
@@ -15,7 +16,7 @@ func TestRead(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &ReadCommand{ c := &ReadCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },
@@ -37,7 +38,7 @@ func TestRead_notFound(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &ReadCommand{ c := &ReadCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },
@@ -59,7 +60,7 @@ func TestRead_field(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &ReadCommand{ c := &ReadCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },
@@ -103,7 +104,7 @@ func TestRead_field_notFound(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &ReadCommand{ c := &ReadCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },

View File

@@ -9,11 +9,12 @@ import (
"github.com/hashicorp/vault/api" "github.com/hashicorp/vault/api"
"github.com/hashicorp/vault/helper/password" "github.com/hashicorp/vault/helper/password"
"github.com/hashicorp/vault/helper/pgpkeys" "github.com/hashicorp/vault/helper/pgpkeys"
"github.com/hashicorp/vault/meta"
) )
// RekeyCommand is a Command that rekeys the vault. // RekeyCommand is a Command that rekeys the vault.
type RekeyCommand struct { type RekeyCommand struct {
Meta meta.Meta
// Key can be used to pre-seed the key. If it is set, it will not // Key can be used to pre-seed the key. If it is set, it will not
// be asked with the `password` helper. // be asked with the `password` helper.
@@ -28,7 +29,7 @@ func (c *RekeyCommand) Run(args []string) int {
var shares, threshold int var shares, threshold int
var nonce string var nonce string
var pgpKeys pgpkeys.PubKeyFilesFlag var pgpKeys pgpkeys.PubKeyFilesFlag
flags := c.Meta.FlagSet("rekey", FlagSetDefault) flags := c.Meta.FlagSet("rekey", meta.FlagSetDefault)
flags.BoolVar(&init, "init", false, "") flags.BoolVar(&init, "init", false, "")
flags.BoolVar(&cancel, "cancel", false, "") flags.BoolVar(&cancel, "cancel", false, "")
flags.BoolVar(&status, "status", false, "") flags.BoolVar(&status, "status", false, "")
@@ -301,7 +302,7 @@ Usage: vault rekey [options] [key]
General Options: General Options:
` + generalOptionsUsage() + ` ` + meta.GeneralOptionsUsage() + `
Rekey Options: Rekey Options:

View File

@@ -10,6 +10,7 @@ import (
"github.com/hashicorp/vault/http" "github.com/hashicorp/vault/http"
"github.com/hashicorp/vault/logical" "github.com/hashicorp/vault/logical"
"github.com/hashicorp/vault/meta"
"github.com/hashicorp/vault/vault" "github.com/hashicorp/vault/vault"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
) )
@@ -22,7 +23,7 @@ func TestRekey(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &RekeyCommand{ c := &RekeyCommand{
Key: hex.EncodeToString(key), Key: hex.EncodeToString(key),
Meta: Meta{ Meta: meta.Meta{
Ui: ui, Ui: ui,
}, },
} }
@@ -48,7 +49,7 @@ func TestRekey_arg(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &RekeyCommand{ c := &RekeyCommand{
Meta: Meta{ Meta: meta.Meta{
Ui: ui, Ui: ui,
}, },
} }
@@ -75,7 +76,7 @@ func TestRekey_init(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &RekeyCommand{ c := &RekeyCommand{
Key: hex.EncodeToString(key), Key: hex.EncodeToString(key),
Meta: Meta{ Meta: meta.Meta{
Ui: ui, Ui: ui,
}, },
} }
@@ -110,7 +111,7 @@ func TestRekey_cancel(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &RekeyCommand{ c := &RekeyCommand{
Key: hex.EncodeToString(key), Key: hex.EncodeToString(key),
Meta: Meta{ Meta: meta.Meta{
Ui: ui, Ui: ui,
}, },
} }
@@ -142,7 +143,7 @@ func TestRekey_status(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &RekeyCommand{ c := &RekeyCommand{
Key: hex.EncodeToString(key), Key: hex.EncodeToString(key),
Meta: Meta{ Meta: meta.Meta{
Ui: ui, Ui: ui,
}, },
} }
@@ -179,7 +180,7 @@ func TestRekey_init_pgp(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &RekeyCommand{ c := &RekeyCommand{
Key: hex.EncodeToString(key), Key: hex.EncodeToString(key),
Meta: Meta{ Meta: meta.Meta{
Ui: ui, Ui: ui,
}, },
} }

View File

@@ -3,16 +3,18 @@ package command
import ( import (
"fmt" "fmt"
"strings" "strings"
"github.com/hashicorp/vault/meta"
) )
// RemountCommand is a Command that remounts a mounted secret backend // RemountCommand is a Command that remounts a mounted secret backend
// to a new endpoint. // to a new endpoint.
type RemountCommand struct { type RemountCommand struct {
Meta meta.Meta
} }
func (c *RemountCommand) Run(args []string) int { func (c *RemountCommand) Run(args []string) int {
flags := c.Meta.FlagSet("remount", FlagSetDefault) flags := c.Meta.FlagSet("remount", meta.FlagSetDefault)
flags.Usage = func() { c.Ui.Error(c.Help()) } flags.Usage = func() { c.Ui.Error(c.Help()) }
if err := flags.Parse(args); err != nil { if err := flags.Parse(args); err != nil {
return 1 return 1
@@ -67,7 +69,7 @@ Usage: vault remount [options] from to
General Options: General Options:
` + generalOptionsUsage() ` + meta.GeneralOptionsUsage()
return strings.TrimSpace(helpText) return strings.TrimSpace(helpText)
} }

View File

@@ -4,6 +4,7 @@ import (
"testing" "testing"
"github.com/hashicorp/vault/http" "github.com/hashicorp/vault/http"
"github.com/hashicorp/vault/meta"
"github.com/hashicorp/vault/vault" "github.com/hashicorp/vault/vault"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
) )
@@ -15,7 +16,7 @@ func TestRemount(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &RemountCommand{ c := &RemountCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },

View File

@@ -4,16 +4,18 @@ import (
"fmt" "fmt"
"strconv" "strconv"
"strings" "strings"
"github.com/hashicorp/vault/meta"
) )
// RenewCommand is a Command that mounts a new mount. // RenewCommand is a Command that mounts a new mount.
type RenewCommand struct { type RenewCommand struct {
Meta meta.Meta
} }
func (c *RenewCommand) Run(args []string) int { func (c *RenewCommand) Run(args []string) int {
var format string var format string
flags := c.Meta.FlagSet("renew", FlagSetDefault) flags := c.Meta.FlagSet("renew", meta.FlagSetDefault)
flags.StringVar(&format, "format", "table", "") flags.StringVar(&format, "format", "table", "")
flags.Usage = func() { c.Ui.Error(c.Help()) } flags.Usage = func() { c.Ui.Error(c.Help()) }
if err := flags.Parse(args); err != nil { if err := flags.Parse(args); err != nil {
@@ -79,7 +81,7 @@ Usage: vault renew [options] id [increment]
General Options: General Options:
` + generalOptionsUsage() + ` ` + meta.GeneralOptionsUsage() + `
Renew Options: Renew Options:

View File

@@ -4,6 +4,7 @@ import (
"testing" "testing"
"github.com/hashicorp/vault/http" "github.com/hashicorp/vault/http"
"github.com/hashicorp/vault/meta"
"github.com/hashicorp/vault/vault" "github.com/hashicorp/vault/vault"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
) )
@@ -15,7 +16,7 @@ func TestRenew(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &RenewCommand{ c := &RenewCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },

View File

@@ -3,16 +3,18 @@ package command
import ( import (
"fmt" "fmt"
"strings" "strings"
"github.com/hashicorp/vault/meta"
) )
// RevokeCommand is a Command that mounts a new mount. // RevokeCommand is a Command that mounts a new mount.
type RevokeCommand struct { type RevokeCommand struct {
Meta meta.Meta
} }
func (c *RevokeCommand) Run(args []string) int { func (c *RevokeCommand) Run(args []string) int {
var prefix, force bool var prefix, force bool
flags := c.Meta.FlagSet("revoke", FlagSetDefault) flags := c.Meta.FlagSet("revoke", meta.FlagSetDefault)
flags.BoolVar(&prefix, "prefix", false, "") flags.BoolVar(&prefix, "prefix", false, "")
flags.BoolVar(&force, "force", false, "") flags.BoolVar(&force, "force", false, "")
flags.Usage = func() { c.Ui.Error(c.Help()) } flags.Usage = func() { c.Ui.Error(c.Help()) }
@@ -81,7 +83,7 @@ Usage: vault revoke [options] id
General Options: General Options:
` + generalOptionsUsage() + ` ` + meta.GeneralOptionsUsage() + `
Revoke Options: Revoke Options:

View File

@@ -4,6 +4,7 @@ import (
"testing" "testing"
"github.com/hashicorp/vault/http" "github.com/hashicorp/vault/http"
"github.com/hashicorp/vault/meta"
"github.com/hashicorp/vault/vault" "github.com/hashicorp/vault/vault"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
) )
@@ -15,7 +16,7 @@ func TestRevoke(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &RevokeCommand{ c := &RevokeCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },

View File

@@ -3,15 +3,17 @@ package command
import ( import (
"fmt" "fmt"
"strings" "strings"
"github.com/hashicorp/vault/meta"
) )
// RotateCommand is a Command that rotates the encryption key being used // RotateCommand is a Command that rotates the encryption key being used
type RotateCommand struct { type RotateCommand struct {
Meta meta.Meta
} }
func (c *RotateCommand) Run(args []string) int { func (c *RotateCommand) Run(args []string) int {
flags := c.Meta.FlagSet("rotate", FlagSetDefault) flags := c.Meta.FlagSet("rotate", meta.FlagSetDefault)
flags.Usage = func() { c.Ui.Error(c.Help()) } flags.Usage = func() { c.Ui.Error(c.Help()) }
if err := flags.Parse(args); err != nil { if err := flags.Parse(args); err != nil {
return 1 return 1
@@ -61,6 +63,6 @@ Usage: vault rotate [options]
General Options: General Options:
` + generalOptionsUsage() ` + meta.GeneralOptionsUsage()
return strings.TrimSpace(helpText) return strings.TrimSpace(helpText)
} }

View File

@@ -4,6 +4,7 @@ import (
"testing" "testing"
"github.com/hashicorp/vault/http" "github.com/hashicorp/vault/http"
"github.com/hashicorp/vault/meta"
"github.com/hashicorp/vault/vault" "github.com/hashicorp/vault/vault"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
) )
@@ -15,7 +16,7 @@ func TestRotate(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &RotateCommand{ c := &RotateCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },

View File

@@ -3,15 +3,17 @@ package command
import ( import (
"fmt" "fmt"
"strings" "strings"
"github.com/hashicorp/vault/meta"
) )
// SealCommand is a Command that seals the vault. // SealCommand is a Command that seals the vault.
type SealCommand struct { type SealCommand struct {
Meta meta.Meta
} }
func (c *SealCommand) Run(args []string) int { func (c *SealCommand) Run(args []string) int {
flags := c.Meta.FlagSet("seal", FlagSetDefault) flags := c.Meta.FlagSet("seal", meta.FlagSetDefault)
flags.Usage = func() { c.Ui.Error(c.Help()) } flags.Usage = func() { c.Ui.Error(c.Help()) }
if err := flags.Parse(args); err != nil { if err := flags.Parse(args); err != nil {
return 1 return 1
@@ -57,6 +59,6 @@ Usage: vault seal [options]
General Options: General Options:
` + generalOptionsUsage() ` + meta.GeneralOptionsUsage()
return strings.TrimSpace(helpText) return strings.TrimSpace(helpText)
} }

View File

@@ -4,6 +4,7 @@ import (
"testing" "testing"
"github.com/hashicorp/vault/http" "github.com/hashicorp/vault/http"
"github.com/hashicorp/vault/meta"
"github.com/hashicorp/vault/vault" "github.com/hashicorp/vault/vault"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
) )
@@ -15,7 +16,7 @@ func TestSeal(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &SealCommand{ c := &SealCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },

View File

@@ -26,6 +26,7 @@ import (
"github.com/hashicorp/vault/helper/mlock" "github.com/hashicorp/vault/helper/mlock"
vaulthttp "github.com/hashicorp/vault/http" vaulthttp "github.com/hashicorp/vault/http"
"github.com/hashicorp/vault/logical" "github.com/hashicorp/vault/logical"
"github.com/hashicorp/vault/meta"
"github.com/hashicorp/vault/physical" "github.com/hashicorp/vault/physical"
"github.com/hashicorp/vault/vault" "github.com/hashicorp/vault/vault"
"github.com/hashicorp/vault/version" "github.com/hashicorp/vault/version"
@@ -40,7 +41,7 @@ type ServerCommand struct {
ShutdownCh chan struct{} ShutdownCh chan struct{}
SighupCh chan struct{} SighupCh chan struct{}
Meta meta.Meta
ReloadFuncs map[string][]server.ReloadFunc ReloadFuncs map[string][]server.ReloadFunc
} }
@@ -49,7 +50,7 @@ func (c *ServerCommand) Run(args []string) int {
var dev, verifyOnly bool var dev, verifyOnly bool
var configPath []string var configPath []string
var logLevel, devRootTokenID, devListenAddress string var logLevel, devRootTokenID, devListenAddress string
flags := c.Meta.FlagSet("server", FlagSetDefault) flags := c.Meta.FlagSet("server", meta.FlagSetDefault)
flags.BoolVar(&dev, "dev", false, "") flags.BoolVar(&dev, "dev", false, "")
flags.StringVar(&devRootTokenID, "dev-root-token-id", "", "") flags.StringVar(&devRootTokenID, "dev-root-token-id", "", "")
flags.StringVar(&devListenAddress, "dev-listen-address", "", "") flags.StringVar(&devListenAddress, "dev-listen-address", "", "")

View File

@@ -15,6 +15,7 @@ import (
"time" "time"
"github.com/hashicorp/vault/command/server" "github.com/hashicorp/vault/command/server"
"github.com/hashicorp/vault/meta"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
) )
@@ -66,7 +67,7 @@ listener "tcp" {
func TestServer_CommonHA(t *testing.T) { func TestServer_CommonHA(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &ServerCommand{ c := &ServerCommand{
Meta: Meta{ Meta: meta.Meta{
Ui: ui, Ui: ui,
}, },
} }
@@ -94,7 +95,7 @@ func TestServer_CommonHA(t *testing.T) {
func TestServer_GoodSeparateHA(t *testing.T) { func TestServer_GoodSeparateHA(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &ServerCommand{ c := &ServerCommand{
Meta: Meta{ Meta: meta.Meta{
Ui: ui, Ui: ui,
}, },
} }
@@ -122,7 +123,7 @@ func TestServer_GoodSeparateHA(t *testing.T) {
func TestServer_BadSeparateHA(t *testing.T) { func TestServer_BadSeparateHA(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &ServerCommand{ c := &ServerCommand{
Meta: Meta{ Meta: meta.Meta{
Ui: ui, Ui: ui,
}, },
} }
@@ -177,7 +178,7 @@ func TestServer_ReloadListener(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &ServerCommand{ c := &ServerCommand{
Meta: Meta{ Meta: meta.Meta{
Ui: ui, Ui: ui,
}, },
ShutdownCh: MakeShutdownCh(), ShutdownCh: MakeShutdownCh(),

View File

@@ -11,13 +11,14 @@ import (
"strings" "strings"
"github.com/hashicorp/vault/builtin/logical/ssh" "github.com/hashicorp/vault/builtin/logical/ssh"
"github.com/hashicorp/vault/meta"
"github.com/mitchellh/mapstructure" "github.com/mitchellh/mapstructure"
) )
// SSHCommand is a Command that establishes a SSH connection // SSHCommand is a Command that establishes a SSH connection
// with target by generating a dynamic key // with target by generating a dynamic key
type SSHCommand struct { type SSHCommand struct {
Meta meta.Meta
} }
// Structure to hold the fields returned when asked for a credential from SSHh backend. // Structure to hold the fields returned when asked for a credential from SSHh backend.
@@ -34,7 +35,7 @@ func (c *SSHCommand) Run(args []string) int {
var noExec bool var noExec bool
var sshCmdArgs []string var sshCmdArgs []string
var sshDynamicKeyFileName string var sshDynamicKeyFileName string
flags := c.Meta.FlagSet("ssh", FlagSetDefault) flags := c.Meta.FlagSet("ssh", meta.FlagSetDefault)
flags.StringVar(&format, "format", "table", "") flags.StringVar(&format, "format", "table", "")
flags.StringVar(&role, "role", "", "") flags.StringVar(&role, "role", "", "")
flags.StringVar(&mountPoint, "mount-point", "ssh", "") flags.StringVar(&mountPoint, "mount-point", "ssh", "")
@@ -256,7 +257,7 @@ Usage: vault ssh [options] username@ip
General Options: General Options:
` + generalOptionsUsage() + ` ` + meta.GeneralOptionsUsage() + `
SSH Options: SSH Options:

View File

@@ -10,6 +10,7 @@ import (
logicalssh "github.com/hashicorp/vault/builtin/logical/ssh" logicalssh "github.com/hashicorp/vault/builtin/logical/ssh"
"github.com/hashicorp/vault/http" "github.com/hashicorp/vault/http"
"github.com/hashicorp/vault/meta"
"github.com/hashicorp/vault/vault" "github.com/hashicorp/vault/vault"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
) )
@@ -87,7 +88,7 @@ func testSSH(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
mountCmd := &MountCommand{ mountCmd := &MountCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },
@@ -120,7 +121,7 @@ func testSSH(t *testing.T) {
} }
writeCmd := &WriteCommand{ writeCmd := &WriteCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },
@@ -150,7 +151,7 @@ func testSSH(t *testing.T) {
} }
sshCmd := &SSHCommand{ sshCmd := &SSHCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },

View File

@@ -5,16 +5,17 @@ import (
"strings" "strings"
"github.com/hashicorp/vault/api" "github.com/hashicorp/vault/api"
"github.com/hashicorp/vault/meta"
) )
// StatusCommand is a Command that outputs the status of whether // StatusCommand is a Command that outputs the status of whether
// Vault is sealed or not as well as HA information. // Vault is sealed or not as well as HA information.
type StatusCommand struct { type StatusCommand struct {
Meta meta.Meta
} }
func (c *StatusCommand) Run(args []string) int { func (c *StatusCommand) Run(args []string) int {
flags := c.Meta.FlagSet("status", FlagSetDefault) flags := c.Meta.FlagSet("status", meta.FlagSetDefault)
flags.Usage = func() { c.Ui.Error(c.Help()) } flags.Usage = func() { c.Ui.Error(c.Help()) }
if err := flags.Parse(args); err != nil { if err := flags.Parse(args); err != nil {
return 1 return 1
@@ -98,6 +99,6 @@ Usage: vault status [options]
General Options: General Options:
` + generalOptionsUsage() ` + meta.GeneralOptionsUsage()
return strings.TrimSpace(helpText) return strings.TrimSpace(helpText)
} }

View File

@@ -4,6 +4,7 @@ import (
"testing" "testing"
"github.com/hashicorp/vault/http" "github.com/hashicorp/vault/http"
"github.com/hashicorp/vault/meta"
"github.com/hashicorp/vault/vault" "github.com/hashicorp/vault/vault"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
) )
@@ -11,7 +12,7 @@ import (
func TestStatus(t *testing.T) { func TestStatus(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &StatusCommand{ c := &StatusCommand{
Meta: Meta{ Meta: meta.Meta{
Ui: ui, Ui: ui,
}, },
} }

View File

@@ -3,15 +3,17 @@ package command
import ( import (
"fmt" "fmt"
"strings" "strings"
"github.com/hashicorp/vault/meta"
) )
// StepDownCommand is a Command that seals the vault. // StepDownCommand is a Command that seals the vault.
type StepDownCommand struct { type StepDownCommand struct {
Meta meta.Meta
} }
func (c *StepDownCommand) Run(args []string) int { func (c *StepDownCommand) Run(args []string) int {
flags := c.Meta.FlagSet("step-down", FlagSetDefault) flags := c.Meta.FlagSet("step-down", meta.FlagSetDefault)
flags.Usage = func() { c.Ui.Error(c.Help()) } flags.Usage = func() { c.Ui.Error(c.Help()) }
if err := flags.Parse(args); err != nil { if err := flags.Parse(args); err != nil {
return 1 return 1
@@ -49,6 +51,6 @@ Usage: vault step-down [options]
General Options: General Options:
` + generalOptionsUsage() ` + meta.GeneralOptionsUsage()
return strings.TrimSpace(helpText) return strings.TrimSpace(helpText)
} }

View File

@@ -7,11 +7,12 @@ import (
"github.com/hashicorp/vault/api" "github.com/hashicorp/vault/api"
"github.com/hashicorp/vault/helper/flag-kv" "github.com/hashicorp/vault/helper/flag-kv"
"github.com/hashicorp/vault/helper/flag-slice" "github.com/hashicorp/vault/helper/flag-slice"
"github.com/hashicorp/vault/meta"
) )
// TokenCreateCommand is a Command that mounts a new mount. // TokenCreateCommand is a Command that mounts a new mount.
type TokenCreateCommand struct { type TokenCreateCommand struct {
Meta meta.Meta
} }
func (c *TokenCreateCommand) Run(args []string) int { func (c *TokenCreateCommand) Run(args []string) int {
@@ -21,7 +22,7 @@ func (c *TokenCreateCommand) Run(args []string) int {
var metadata map[string]string var metadata map[string]string
var numUses int var numUses int
var policies []string var policies []string
flags := c.Meta.FlagSet("mount", FlagSetDefault) flags := c.Meta.FlagSet("mount", meta.FlagSetDefault)
flags.StringVar(&format, "format", "table", "") flags.StringVar(&format, "format", "table", "")
flags.StringVar(&displayName, "display-name", "", "") flags.StringVar(&displayName, "display-name", "", "")
flags.StringVar(&id, "id", "", "") flags.StringVar(&id, "id", "", "")
@@ -109,7 +110,7 @@ Usage: vault token-create [options]
General Options: General Options:
` + generalOptionsUsage() + ` ` + meta.GeneralOptionsUsage() + `
Token Options: Token Options:

View File

@@ -5,6 +5,7 @@ import (
"testing" "testing"
"github.com/hashicorp/vault/http" "github.com/hashicorp/vault/http"
"github.com/hashicorp/vault/meta"
"github.com/hashicorp/vault/vault" "github.com/hashicorp/vault/vault"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
) )
@@ -16,7 +17,7 @@ func TestTokenCreate(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &TokenCreateCommand{ c := &TokenCreateCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },

View File

@@ -5,18 +5,19 @@ import (
"strings" "strings"
"github.com/hashicorp/vault/api" "github.com/hashicorp/vault/api"
"github.com/hashicorp/vault/meta"
) )
// TokenLookupCommand is a Command that outputs details about the // TokenLookupCommand is a Command that outputs details about the
// provided. // provided.
type TokenLookupCommand struct { type TokenLookupCommand struct {
Meta meta.Meta
} }
func (c *TokenLookupCommand) Run(args []string) int { func (c *TokenLookupCommand) Run(args []string) int {
var format string var format string
var accessor bool var accessor bool
flags := c.Meta.FlagSet("token-lookup", FlagSetDefault) flags := c.Meta.FlagSet("token-lookup", meta.FlagSetDefault)
flags.BoolVar(&accessor, "accessor", false, "") flags.BoolVar(&accessor, "accessor", false, "")
flags.StringVar(&format, "format", "table", "") flags.StringVar(&format, "format", "table", "")
flags.Usage = func() { c.Ui.Error(c.Help()) } flags.Usage = func() { c.Ui.Error(c.Help()) }
@@ -85,7 +86,7 @@ Usage: vault token-lookup [options] [token|accessor]
General Options: General Options:
` + generalOptionsUsage() + ` ` + meta.GeneralOptionsUsage() + `
Token Lookup Options: Token Lookup Options:
-accessor A boolean flag, if set, treats the argument as an accessor of the token. -accessor A boolean flag, if set, treats the argument as an accessor of the token.

View File

@@ -5,6 +5,7 @@ import (
"github.com/hashicorp/vault/api" "github.com/hashicorp/vault/api"
"github.com/hashicorp/vault/http" "github.com/hashicorp/vault/http"
"github.com/hashicorp/vault/meta"
"github.com/hashicorp/vault/vault" "github.com/hashicorp/vault/vault"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
) )
@@ -16,7 +17,7 @@ func TestTokenLookupAccessor(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &TokenLookupCommand{ c := &TokenLookupCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },
@@ -62,7 +63,7 @@ func TestTokenLookupSelf(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &TokenLookupCommand{ c := &TokenLookupCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },
@@ -88,7 +89,7 @@ func TestTokenLookup(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &TokenLookupCommand{ c := &TokenLookupCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },

View File

@@ -6,16 +6,17 @@ import (
"time" "time"
"github.com/hashicorp/vault/api" "github.com/hashicorp/vault/api"
"github.com/hashicorp/vault/meta"
) )
// TokenRenewCommand is a Command that mounts a new mount. // TokenRenewCommand is a Command that mounts a new mount.
type TokenRenewCommand struct { type TokenRenewCommand struct {
Meta meta.Meta
} }
func (c *TokenRenewCommand) Run(args []string) int { func (c *TokenRenewCommand) Run(args []string) int {
var format, increment string var format, increment string
flags := c.Meta.FlagSet("token-renew", FlagSetDefault) flags := c.Meta.FlagSet("token-renew", meta.FlagSetDefault)
flags.StringVar(&format, "format", "table", "") flags.StringVar(&format, "format", "table", "")
flags.StringVar(&increment, "increment", "", "") flags.StringVar(&increment, "increment", "", "")
flags.Usage = func() { c.Ui.Error(c.Help()) } flags.Usage = func() { c.Ui.Error(c.Help()) }
@@ -98,7 +99,7 @@ Usage: vault token-renew [options] [token] [increment]
General Options: General Options:
` + generalOptionsUsage() + ` ` + meta.GeneralOptionsUsage() + `
Token Renew Options: Token Renew Options:

View File

@@ -5,6 +5,7 @@ import (
"github.com/hashicorp/vault/api" "github.com/hashicorp/vault/api"
"github.com/hashicorp/vault/http" "github.com/hashicorp/vault/http"
"github.com/hashicorp/vault/meta"
"github.com/hashicorp/vault/vault" "github.com/hashicorp/vault/vault"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
) )
@@ -16,7 +17,7 @@ func TestTokenRenew(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &TokenRenewCommand{ c := &TokenRenewCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },
@@ -55,7 +56,7 @@ func TestTokenRenewWithIncrement(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &TokenRenewCommand{ c := &TokenRenewCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },
@@ -95,7 +96,7 @@ func TestTokenRenewSelf(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &TokenRenewCommand{ c := &TokenRenewCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },
@@ -138,7 +139,7 @@ func TestTokenRenewSelfWithIncrement(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &TokenRenewCommand{ c := &TokenRenewCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },

View File

@@ -3,17 +3,19 @@ package command
import ( import (
"fmt" "fmt"
"strings" "strings"
"github.com/hashicorp/vault/meta"
) )
// TokenRevokeCommand is a Command that mounts a new mount. // TokenRevokeCommand is a Command that mounts a new mount.
type TokenRevokeCommand struct { type TokenRevokeCommand struct {
Meta meta.Meta
} }
func (c *TokenRevokeCommand) Run(args []string) int { func (c *TokenRevokeCommand) Run(args []string) int {
var mode string var mode string
var accessor bool var accessor bool
flags := c.Meta.FlagSet("token-revoke", FlagSetDefault) flags := c.Meta.FlagSet("token-revoke", meta.FlagSetDefault)
flags.BoolVar(&accessor, "accessor", false, "") flags.BoolVar(&accessor, "accessor", false, "")
flags.StringVar(&mode, "mode", "", "") flags.StringVar(&mode, "mode", "", "")
flags.Usage = func() { c.Ui.Error(c.Help()) } flags.Usage = func() { c.Ui.Error(c.Help()) }
@@ -100,7 +102,7 @@ Usage: vault token-revoke [options] [token|accessor]
General Options: General Options:
` + generalOptionsUsage() + ` ` + meta.GeneralOptionsUsage() + `
Token Options: Token Options:

View File

@@ -4,6 +4,7 @@ import (
"testing" "testing"
"github.com/hashicorp/vault/http" "github.com/hashicorp/vault/http"
"github.com/hashicorp/vault/meta"
"github.com/hashicorp/vault/vault" "github.com/hashicorp/vault/vault"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
) )
@@ -15,7 +16,7 @@ func TestTokenRevokeAccessor(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &TokenRevokeCommand{ c := &TokenRevokeCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },
@@ -70,7 +71,7 @@ func TestTokenRevoke(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &TokenRevokeCommand{ c := &TokenRevokeCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },

View File

@@ -3,15 +3,17 @@ package command
import ( import (
"fmt" "fmt"
"strings" "strings"
"github.com/hashicorp/vault/meta"
) )
// UnmountCommand is a Command that mounts a new mount. // UnmountCommand is a Command that mounts a new mount.
type UnmountCommand struct { type UnmountCommand struct {
Meta meta.Meta
} }
func (c *UnmountCommand) Run(args []string) int { func (c *UnmountCommand) Run(args []string) int {
flags := c.Meta.FlagSet("mount", FlagSetDefault) flags := c.Meta.FlagSet("mount", meta.FlagSetDefault)
flags.Usage = func() { c.Ui.Error(c.Help()) } flags.Usage = func() { c.Ui.Error(c.Help()) }
if err := flags.Parse(args); err != nil { if err := flags.Parse(args); err != nil {
return 1 return 1
@@ -61,6 +63,6 @@ Usage: vault unmount [options] path
General Options: General Options:
` + generalOptionsUsage() ` + meta.GeneralOptionsUsage()
return strings.TrimSpace(helpText) return strings.TrimSpace(helpText)
} }

View File

@@ -4,6 +4,7 @@ import (
"testing" "testing"
"github.com/hashicorp/vault/http" "github.com/hashicorp/vault/http"
"github.com/hashicorp/vault/meta"
"github.com/hashicorp/vault/vault" "github.com/hashicorp/vault/vault"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
) )
@@ -15,7 +16,7 @@ func TestUnmount(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &UnmountCommand{ c := &UnmountCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },

View File

@@ -6,11 +6,12 @@ import (
"strings" "strings"
"github.com/hashicorp/vault/helper/password" "github.com/hashicorp/vault/helper/password"
"github.com/hashicorp/vault/meta"
) )
// UnsealCommand is a Command that unseals the vault. // UnsealCommand is a Command that unseals the vault.
type UnsealCommand struct { type UnsealCommand struct {
Meta meta.Meta
// Key can be used to pre-seed the key. If it is set, it will not // Key can be used to pre-seed the key. If it is set, it will not
// be asked with the `password` helper. // be asked with the `password` helper.
@@ -19,7 +20,7 @@ type UnsealCommand struct {
func (c *UnsealCommand) Run(args []string) int { func (c *UnsealCommand) Run(args []string) int {
var reset bool var reset bool
flags := c.Meta.FlagSet("unseal", FlagSetDefault) flags := c.Meta.FlagSet("unseal", meta.FlagSetDefault)
flags.BoolVar(&reset, "reset", false, "") flags.BoolVar(&reset, "reset", false, "")
flags.Usage = func() { c.Ui.Error(c.Help()) } flags.Usage = func() { c.Ui.Error(c.Help()) }
if err := flags.Parse(args); err != nil { if err := flags.Parse(args); err != nil {
@@ -115,7 +116,7 @@ Usage: vault unseal [options] [key]
General Options: General Options:
` + generalOptionsUsage() + ` ` + meta.GeneralOptionsUsage() + `
Unseal Options: Unseal Options:

View File

@@ -5,6 +5,7 @@ import (
"testing" "testing"
"github.com/hashicorp/vault/http" "github.com/hashicorp/vault/http"
"github.com/hashicorp/vault/meta"
"github.com/hashicorp/vault/vault" "github.com/hashicorp/vault/vault"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
) )
@@ -18,7 +19,7 @@ func TestUnseal(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &UnsealCommand{ c := &UnsealCommand{
Key: hex.EncodeToString(key), Key: hex.EncodeToString(key),
Meta: Meta{ Meta: meta.Meta{
Ui: ui, Ui: ui,
}, },
} }
@@ -45,7 +46,7 @@ func TestUnseal_arg(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &UnsealCommand{ c := &UnsealCommand{
Meta: Meta{ Meta: meta.Meta{
Ui: ui, Ui: ui,
}, },
} }

View File

@@ -8,11 +8,12 @@ import (
"strings" "strings"
"github.com/hashicorp/vault/helper/kv-builder" "github.com/hashicorp/vault/helper/kv-builder"
"github.com/hashicorp/vault/meta"
) )
// WriteCommand is a Command that puts data into the Vault. // WriteCommand is a Command that puts data into the Vault.
type WriteCommand struct { type WriteCommand struct {
Meta meta.Meta
// The fields below can be overwritten for tests // The fields below can be overwritten for tests
testStdin io.Reader testStdin io.Reader
@@ -21,7 +22,7 @@ type WriteCommand struct {
func (c *WriteCommand) Run(args []string) int { func (c *WriteCommand) Run(args []string) int {
var field, format string var field, format string
var force bool var force bool
flags := c.Meta.FlagSet("write", FlagSetDefault) flags := c.Meta.FlagSet("write", meta.FlagSetDefault)
flags.StringVar(&format, "format", "table", "") flags.StringVar(&format, "format", "table", "")
flags.StringVar(&field, "field", "", "") flags.StringVar(&field, "field", "", "")
flags.BoolVar(&force, "force", false, "") flags.BoolVar(&force, "force", false, "")
@@ -134,7 +135,7 @@ Usage: vault write [options] path [data]
General Options: General Options:
` + generalOptionsUsage() + ` ` + meta.GeneralOptionsUsage() + `
Write Options: Write Options:

View File

@@ -8,6 +8,7 @@ import (
"testing" "testing"
"github.com/hashicorp/vault/http" "github.com/hashicorp/vault/http"
"github.com/hashicorp/vault/meta"
"github.com/hashicorp/vault/vault" "github.com/hashicorp/vault/vault"
"github.com/mitchellh/cli" "github.com/mitchellh/cli"
) )
@@ -19,7 +20,7 @@ func TestWrite(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &WriteCommand{ c := &WriteCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },
@@ -57,7 +58,7 @@ func TestWrite_arbitrary(t *testing.T) {
stdinR, stdinW := io.Pipe() stdinR, stdinW := io.Pipe()
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &WriteCommand{ c := &WriteCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },
@@ -101,7 +102,7 @@ func TestWrite_escaped(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &WriteCommand{ c := &WriteCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },
@@ -146,7 +147,7 @@ func TestWrite_file(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &WriteCommand{ c := &WriteCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },
@@ -191,7 +192,7 @@ func TestWrite_fileValue(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &WriteCommand{ c := &WriteCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },
@@ -228,7 +229,7 @@ func TestWrite_Output(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &WriteCommand{ c := &WriteCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },
@@ -254,7 +255,7 @@ func TestWrite_force(t *testing.T) {
ui := new(cli.MockUi) ui := new(cli.MockUi)
c := &WriteCommand{ c := &WriteCommand{
Meta: Meta{ Meta: meta.Meta{
ClientToken: token, ClientToken: token,
Ui: ui, Ui: ui,
}, },

View File

@@ -1,4 +1,4 @@
package command package meta
import ( import (
"fmt" "fmt"

View File

@@ -1,4 +1,4 @@
package command package meta
import ( import (
"path/filepath" "path/filepath"
@@ -7,6 +7,8 @@ import (
"testing" "testing"
) )
const FixturePath = "./test-fixtures"
func TestLoadConfig(t *testing.T) { func TestLoadConfig(t *testing.T) {
config, err := LoadConfig(filepath.Join(FixturePath, "config.hcl")) config, err := LoadConfig(filepath.Join(FixturePath, "config.hcl"))
if err != nil { if err != nil {

View File

@@ -1,4 +1,4 @@
package command package meta
import ( import (
"bufio" "bufio"
@@ -279,9 +279,9 @@ func (m *Meta) loadCertFromPEM(path string) ([]*x509.Certificate, error) {
return certs, nil return certs, nil
} }
// generalOptionsUsage returns the usage documenation for commonly // GeneralOptionsUsage returns the usage documenation for commonly
// available options // available options
func generalOptionsUsage() string { func GeneralOptionsUsage() string {
general := ` general := `
-address=addr The address of the Vault server. -address=addr The address of the Vault server.
Overrides the VAULT_ADDR environment variable if set. Overrides the VAULT_ADDR environment variable if set.

View File

@@ -1,4 +1,4 @@
package command package meta
import ( import (
"flag" "flag"