Move meta into its own package
This commit is contained in:
parent
da00982529
commit
33326b30c3
@ -27,19 +27,19 @@ import (
|
||||
"github.com/hashicorp/vault/audit"
|
||||
"github.com/hashicorp/vault/command"
|
||||
"github.com/hashicorp/vault/logical"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
|
||||
// Commands returns the mapping of CLI commands for Vault. The meta
|
||||
// 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 {
|
||||
metaPtr = new(command.Meta)
|
||||
metaPtr = new(meta.Meta)
|
||||
}
|
||||
|
||||
meta := *metaPtr
|
||||
if meta.Ui == nil {
|
||||
meta.Ui = &cli.BasicUi{
|
||||
if metaPtr.Ui == nil {
|
||||
metaPtr.Ui = &cli.BasicUi{
|
||||
Writer: os.Stdout,
|
||||
ErrorWriter: os.Stderr,
|
||||
}
|
||||
@ -48,13 +48,13 @@ func Commands(metaPtr *command.Meta) map[string]cli.CommandFactory {
|
||||
return map[string]cli.CommandFactory{
|
||||
"init": func() (cli.Command, error) {
|
||||
return &command.InitCommand{
|
||||
Meta: meta,
|
||||
Meta: *metaPtr,
|
||||
}, nil
|
||||
},
|
||||
|
||||
"server": func() (cli.Command, error) {
|
||||
return &command.ServerCommand{
|
||||
Meta: meta,
|
||||
Meta: *metaPtr,
|
||||
AuditBackends: map[string]audit.Factory{
|
||||
"file": auditFile.Factory,
|
||||
"syslog": auditSyslog.Factory,
|
||||
@ -85,19 +85,19 @@ func Commands(metaPtr *command.Meta) map[string]cli.CommandFactory {
|
||||
|
||||
"ssh": func() (cli.Command, error) {
|
||||
return &command.SSHCommand{
|
||||
Meta: meta,
|
||||
Meta: *metaPtr,
|
||||
}, nil
|
||||
},
|
||||
|
||||
"path-help": func() (cli.Command, error) {
|
||||
return &command.PathHelpCommand{
|
||||
Meta: meta,
|
||||
Meta: *metaPtr,
|
||||
}, nil
|
||||
},
|
||||
|
||||
"auth": func() (cli.Command, error) {
|
||||
return &command.AuthCommand{
|
||||
Meta: meta,
|
||||
Meta: *metaPtr,
|
||||
Handlers: map[string]command.AuthHandler{
|
||||
"github": &credGitHub.CLIHandler{},
|
||||
"userpass": &credUserpass.CLIHandler{},
|
||||
@ -109,193 +109,193 @@ func Commands(metaPtr *command.Meta) map[string]cli.CommandFactory {
|
||||
|
||||
"auth-enable": func() (cli.Command, error) {
|
||||
return &command.AuthEnableCommand{
|
||||
Meta: meta,
|
||||
Meta: *metaPtr,
|
||||
}, nil
|
||||
},
|
||||
|
||||
"auth-disable": func() (cli.Command, error) {
|
||||
return &command.AuthDisableCommand{
|
||||
Meta: meta,
|
||||
Meta: *metaPtr,
|
||||
}, nil
|
||||
},
|
||||
|
||||
"audit-list": func() (cli.Command, error) {
|
||||
return &command.AuditListCommand{
|
||||
Meta: meta,
|
||||
Meta: *metaPtr,
|
||||
}, nil
|
||||
},
|
||||
|
||||
"audit-disable": func() (cli.Command, error) {
|
||||
return &command.AuditDisableCommand{
|
||||
Meta: meta,
|
||||
Meta: *metaPtr,
|
||||
}, nil
|
||||
},
|
||||
|
||||
"audit-enable": func() (cli.Command, error) {
|
||||
return &command.AuditEnableCommand{
|
||||
Meta: meta,
|
||||
Meta: *metaPtr,
|
||||
}, nil
|
||||
},
|
||||
|
||||
"key-status": func() (cli.Command, error) {
|
||||
return &command.KeyStatusCommand{
|
||||
Meta: meta,
|
||||
Meta: *metaPtr,
|
||||
}, nil
|
||||
},
|
||||
|
||||
"policies": func() (cli.Command, error) {
|
||||
return &command.PolicyListCommand{
|
||||
Meta: meta,
|
||||
Meta: *metaPtr,
|
||||
}, nil
|
||||
},
|
||||
|
||||
"policy-delete": func() (cli.Command, error) {
|
||||
return &command.PolicyDeleteCommand{
|
||||
Meta: meta,
|
||||
Meta: *metaPtr,
|
||||
}, nil
|
||||
},
|
||||
|
||||
"policy-write": func() (cli.Command, error) {
|
||||
return &command.PolicyWriteCommand{
|
||||
Meta: meta,
|
||||
Meta: *metaPtr,
|
||||
}, nil
|
||||
},
|
||||
|
||||
"read": func() (cli.Command, error) {
|
||||
return &command.ReadCommand{
|
||||
Meta: meta,
|
||||
Meta: *metaPtr,
|
||||
}, nil
|
||||
},
|
||||
|
||||
"list": func() (cli.Command, error) {
|
||||
return &command.ListCommand{
|
||||
Meta: meta,
|
||||
Meta: *metaPtr,
|
||||
}, nil
|
||||
},
|
||||
|
||||
"write": func() (cli.Command, error) {
|
||||
return &command.WriteCommand{
|
||||
Meta: meta,
|
||||
Meta: *metaPtr,
|
||||
}, nil
|
||||
},
|
||||
|
||||
"delete": func() (cli.Command, error) {
|
||||
return &command.DeleteCommand{
|
||||
Meta: meta,
|
||||
Meta: *metaPtr,
|
||||
}, nil
|
||||
},
|
||||
|
||||
"rekey": func() (cli.Command, error) {
|
||||
return &command.RekeyCommand{
|
||||
Meta: meta,
|
||||
Meta: *metaPtr,
|
||||
}, nil
|
||||
},
|
||||
|
||||
"generate-root": func() (cli.Command, error) {
|
||||
return &command.GenerateRootCommand{
|
||||
Meta: meta,
|
||||
Meta: *metaPtr,
|
||||
}, nil
|
||||
},
|
||||
|
||||
"renew": func() (cli.Command, error) {
|
||||
return &command.RenewCommand{
|
||||
Meta: meta,
|
||||
Meta: *metaPtr,
|
||||
}, nil
|
||||
},
|
||||
|
||||
"revoke": func() (cli.Command, error) {
|
||||
return &command.RevokeCommand{
|
||||
Meta: meta,
|
||||
Meta: *metaPtr,
|
||||
}, nil
|
||||
},
|
||||
|
||||
"seal": func() (cli.Command, error) {
|
||||
return &command.SealCommand{
|
||||
Meta: meta,
|
||||
Meta: *metaPtr,
|
||||
}, nil
|
||||
},
|
||||
|
||||
"status": func() (cli.Command, error) {
|
||||
return &command.StatusCommand{
|
||||
Meta: meta,
|
||||
Meta: *metaPtr,
|
||||
}, nil
|
||||
},
|
||||
|
||||
"unseal": func() (cli.Command, error) {
|
||||
return &command.UnsealCommand{
|
||||
Meta: meta,
|
||||
Meta: *metaPtr,
|
||||
}, nil
|
||||
},
|
||||
|
||||
"step-down": func() (cli.Command, error) {
|
||||
return &command.StepDownCommand{
|
||||
Meta: meta,
|
||||
Meta: *metaPtr,
|
||||
}, nil
|
||||
},
|
||||
|
||||
"mount": func() (cli.Command, error) {
|
||||
return &command.MountCommand{
|
||||
Meta: meta,
|
||||
Meta: *metaPtr,
|
||||
}, nil
|
||||
},
|
||||
|
||||
"mounts": func() (cli.Command, error) {
|
||||
return &command.MountsCommand{
|
||||
Meta: meta,
|
||||
Meta: *metaPtr,
|
||||
}, nil
|
||||
},
|
||||
|
||||
"mount-tune": func() (cli.Command, error) {
|
||||
return &command.MountTuneCommand{
|
||||
Meta: meta,
|
||||
Meta: *metaPtr,
|
||||
}, nil
|
||||
},
|
||||
|
||||
"remount": func() (cli.Command, error) {
|
||||
return &command.RemountCommand{
|
||||
Meta: meta,
|
||||
Meta: *metaPtr,
|
||||
}, nil
|
||||
},
|
||||
|
||||
"rotate": func() (cli.Command, error) {
|
||||
return &command.RotateCommand{
|
||||
Meta: meta,
|
||||
Meta: *metaPtr,
|
||||
}, nil
|
||||
},
|
||||
|
||||
"unmount": func() (cli.Command, error) {
|
||||
return &command.UnmountCommand{
|
||||
Meta: meta,
|
||||
Meta: *metaPtr,
|
||||
}, nil
|
||||
},
|
||||
|
||||
"token-create": func() (cli.Command, error) {
|
||||
return &command.TokenCreateCommand{
|
||||
Meta: meta,
|
||||
Meta: *metaPtr,
|
||||
}, nil
|
||||
},
|
||||
|
||||
"token-lookup": func() (cli.Command, error) {
|
||||
return &command.TokenLookupCommand{
|
||||
Meta: meta,
|
||||
Meta: *metaPtr,
|
||||
}, nil
|
||||
},
|
||||
|
||||
"token-renew": func() (cli.Command, error) {
|
||||
return &command.TokenRenewCommand{
|
||||
Meta: meta,
|
||||
Meta: *metaPtr,
|
||||
}, nil
|
||||
},
|
||||
|
||||
"token-revoke": func() (cli.Command, error) {
|
||||
return &command.TokenRevokeCommand{
|
||||
Meta: meta,
|
||||
Meta: *metaPtr,
|
||||
}, nil
|
||||
},
|
||||
|
||||
"capabilities": func() (cli.Command, error) {
|
||||
return &command.CapabilitiesCommand{
|
||||
Meta: meta,
|
||||
Meta: *metaPtr,
|
||||
}, nil
|
||||
},
|
||||
|
||||
@ -304,7 +304,7 @@ func Commands(metaPtr *command.Meta) map[string]cli.CommandFactory {
|
||||
|
||||
return &command.VersionCommand{
|
||||
VersionInfo: versionInfo,
|
||||
Ui: meta.Ui,
|
||||
Ui: metaPtr.Ui,
|
||||
}, nil
|
||||
},
|
||||
}
|
||||
|
@ -3,15 +3,17 @@ package command
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/vault/meta"
|
||||
)
|
||||
|
||||
// AuditDisableCommand is a Command that mounts a new mount.
|
||||
type AuditDisableCommand struct {
|
||||
Meta
|
||||
meta.Meta
|
||||
}
|
||||
|
||||
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()) }
|
||||
if err := flags.Parse(args); err != nil {
|
||||
return 1
|
||||
@ -64,6 +66,6 @@ Usage: vault audit-disable [options] id
|
||||
|
||||
General Options:
|
||||
|
||||
` + generalOptionsUsage()
|
||||
` + meta.GeneralOptionsUsage()
|
||||
return strings.TrimSpace(helpText)
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/vault/http"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
"github.com/hashicorp/vault/vault"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
@ -15,7 +16,7 @@ func TestAuditDisable(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &AuditDisableCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
|
@ -7,12 +7,13 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/vault/helper/kv-builder"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
)
|
||||
|
||||
// AuditEnableCommand is a Command that mounts a new mount.
|
||||
type AuditEnableCommand struct {
|
||||
Meta
|
||||
meta.Meta
|
||||
|
||||
// A test stdin that can be used for tests
|
||||
testStdin io.Reader
|
||||
@ -20,7 +21,7 @@ type AuditEnableCommand struct {
|
||||
|
||||
func (c *AuditEnableCommand) Run(args []string) int {
|
||||
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(&path, "path", "", "")
|
||||
flags.Usage = func() { c.Ui.Error(c.Help()) }
|
||||
@ -96,7 +97,7 @@ Usage: vault audit-enable [options] type [config...]
|
||||
|
||||
General Options:
|
||||
|
||||
` + generalOptionsUsage() + `
|
||||
` + meta.GeneralOptionsUsage() + `
|
||||
|
||||
Audit Enable Options:
|
||||
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/vault/http"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
"github.com/hashicorp/vault/vault"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
@ -16,7 +17,7 @@ func TestAuditEnable(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &AuditEnableCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
|
@ -5,16 +5,17 @@ import (
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/vault/meta"
|
||||
"github.com/ryanuber/columnize"
|
||||
)
|
||||
|
||||
// AuditListCommand is a Command that lists the enabled audits.
|
||||
type AuditListCommand struct {
|
||||
Meta
|
||||
meta.Meta
|
||||
}
|
||||
|
||||
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()) }
|
||||
if err := flags.Parse(args); err != nil {
|
||||
return 1
|
||||
@ -79,6 +80,6 @@ Usage: vault audit-list [options]
|
||||
|
||||
General Options:
|
||||
|
||||
` + generalOptionsUsage()
|
||||
` + meta.GeneralOptionsUsage()
|
||||
return strings.TrimSpace(helpText)
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/vault/http"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
"github.com/hashicorp/vault/vault"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
@ -15,7 +16,7 @@ func TestAuditList(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &AuditListCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
|
@ -11,6 +11,7 @@ import (
|
||||
"github.com/hashicorp/vault/api"
|
||||
"github.com/hashicorp/vault/helper/kv-builder"
|
||||
"github.com/hashicorp/vault/helper/password"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
"github.com/ryanuber/columnize"
|
||||
)
|
||||
@ -24,7 +25,7 @@ type AuthHandler interface {
|
||||
|
||||
// AuthCommand is a Command that handles authentication.
|
||||
type AuthCommand struct {
|
||||
Meta
|
||||
meta.Meta
|
||||
|
||||
Handlers map[string]AuthHandler
|
||||
|
||||
@ -35,7 +36,7 @@ type AuthCommand struct {
|
||||
func (c *AuthCommand) Run(args []string) int {
|
||||
var method string
|
||||
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(&methodHelp, "method-help", false, "")
|
||||
flags.BoolVar(&noVerify, "no-verify", false, "")
|
||||
@ -299,7 +300,7 @@ Usage: vault auth [options] [token or config...]
|
||||
|
||||
General Options:
|
||||
|
||||
` + generalOptionsUsage() + `
|
||||
` + meta.GeneralOptionsUsage() + `
|
||||
|
||||
Auth Options:
|
||||
|
||||
|
@ -3,15 +3,17 @@ package command
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/vault/meta"
|
||||
)
|
||||
|
||||
// AuthDisableCommand is a Command that enables a new endpoint.
|
||||
type AuthDisableCommand struct {
|
||||
Meta
|
||||
meta.Meta
|
||||
}
|
||||
|
||||
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()) }
|
||||
if err := flags.Parse(args); err != nil {
|
||||
return 1
|
||||
@ -63,6 +65,6 @@ Usage: vault auth-disable [options] path
|
||||
|
||||
General Options:
|
||||
|
||||
` + generalOptionsUsage()
|
||||
` + meta.GeneralOptionsUsage()
|
||||
return strings.TrimSpace(helpText)
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/vault/http"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
"github.com/hashicorp/vault/vault"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
@ -15,7 +16,7 @@ func TestAuthDisable(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &AuthDisableCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
|
@ -3,16 +3,18 @@ package command
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/vault/meta"
|
||||
)
|
||||
|
||||
// AuthEnableCommand is a Command that enables a new endpoint.
|
||||
type AuthEnableCommand struct {
|
||||
Meta
|
||||
meta.Meta
|
||||
}
|
||||
|
||||
func (c *AuthEnableCommand) Run(args []string) int {
|
||||
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(&path, "path", "", "")
|
||||
flags.Usage = func() { c.Ui.Error(c.Help()) }
|
||||
@ -71,7 +73,7 @@ Usage: vault auth-enable [options] type
|
||||
|
||||
General Options:
|
||||
|
||||
` + generalOptionsUsage() + `
|
||||
` + meta.GeneralOptionsUsage() + `
|
||||
|
||||
Auth Enable Options:
|
||||
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/vault/http"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
"github.com/hashicorp/vault/vault"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
@ -15,7 +16,7 @@ func TestAuthEnable(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &AuthEnableCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
|
@ -11,6 +11,7 @@ import (
|
||||
|
||||
"github.com/hashicorp/vault/api"
|
||||
"github.com/hashicorp/vault/http"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
"github.com/hashicorp/vault/vault"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
@ -24,7 +25,7 @@ func TestAuth_methods(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &AuthCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
@ -53,7 +54,7 @@ func TestAuth_token(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &AuthCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
Ui: ui,
|
||||
},
|
||||
}
|
||||
@ -91,7 +92,7 @@ func TestAuth_stdin(t *testing.T) {
|
||||
stdinR, stdinW := io.Pipe()
|
||||
ui := new(cli.MockUi)
|
||||
c := &AuthCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
Ui: ui,
|
||||
},
|
||||
testStdin: stdinR,
|
||||
@ -120,7 +121,7 @@ func TestAuth_badToken(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &AuthCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
Ui: ui,
|
||||
},
|
||||
}
|
||||
@ -146,7 +147,7 @@ func TestAuth_method(t *testing.T) {
|
||||
Handlers: map[string]AuthHandler{
|
||||
"test": &testAuthHandler{},
|
||||
},
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
Ui: ui,
|
||||
},
|
||||
}
|
||||
|
@ -3,15 +3,17 @@ package command
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/vault/meta"
|
||||
)
|
||||
|
||||
// CapabilitiesCommand is a Command that enables a new endpoint.
|
||||
type CapabilitiesCommand struct {
|
||||
Meta
|
||||
meta.Meta
|
||||
}
|
||||
|
||||
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()) }
|
||||
if err := flags.Parse(args); err != nil {
|
||||
return 1
|
||||
@ -81,6 +83,6 @@ Usage: vault capabilities [options] [token] path
|
||||
|
||||
General Options:
|
||||
|
||||
` + generalOptionsUsage()
|
||||
` + meta.GeneralOptionsUsage()
|
||||
return strings.TrimSpace(helpText)
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/vault/http"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
"github.com/hashicorp/vault/vault"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
@ -14,7 +15,7 @@ func TestCapabilities_Basic(t *testing.T) {
|
||||
defer ln.Close()
|
||||
ui := new(cli.MockUi)
|
||||
c := &CapabilitiesCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
|
@ -3,15 +3,17 @@ package command
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/vault/meta"
|
||||
)
|
||||
|
||||
// DeleteCommand is a Command that puts data into the Vault.
|
||||
type DeleteCommand struct {
|
||||
Meta
|
||||
meta.Meta
|
||||
}
|
||||
|
||||
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()) }
|
||||
if err := flags.Parse(args); err != nil {
|
||||
return 1
|
||||
@ -61,6 +63,6 @@ Usage: vault delete [options] path
|
||||
|
||||
General Options:
|
||||
|
||||
` + generalOptionsUsage()
|
||||
` + meta.GeneralOptionsUsage()
|
||||
return strings.TrimSpace(helpText)
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/vault/http"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
"github.com/hashicorp/vault/vault"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
@ -15,7 +16,7 @@ func TestDelete(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &DeleteCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
|
@ -2,10 +2,11 @@ package command
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/ghodss/yaml"
|
||||
"github.com/hashicorp/vault/api"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/ghodss/yaml"
|
||||
"github.com/hashicorp/vault/api"
|
||||
)
|
||||
|
||||
var output string
|
||||
|
@ -12,11 +12,12 @@ import (
|
||||
"github.com/hashicorp/vault/helper/password"
|
||||
"github.com/hashicorp/vault/helper/pgpkeys"
|
||||
"github.com/hashicorp/vault/helper/xor"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
)
|
||||
|
||||
// GenerateRootCommand is a Command that generates a new root token.
|
||||
type GenerateRootCommand struct {
|
||||
Meta
|
||||
meta.Meta
|
||||
|
||||
// Key can be used to pre-seed the key. If it is set, it will not
|
||||
// be asked with the `password` helper.
|
||||
@ -30,7 +31,7 @@ func (c *GenerateRootCommand) Run(args []string) int {
|
||||
var init, cancel, status, genotp bool
|
||||
var nonce, decode, otp, pgpKey string
|
||||
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(&cancel, "cancel", false, "")
|
||||
flags.BoolVar(&status, "status", false, "")
|
||||
@ -315,7 +316,7 @@ Usage: vault generate-root [options] [key]
|
||||
|
||||
General Options:
|
||||
|
||||
` + generalOptionsUsage() + `
|
||||
` + meta.GeneralOptionsUsage() + `
|
||||
|
||||
Rekey Options:
|
||||
|
||||
|
@ -12,6 +12,7 @@ import (
|
||||
"github.com/hashicorp/vault/helper/xor"
|
||||
"github.com/hashicorp/vault/http"
|
||||
"github.com/hashicorp/vault/logical"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
"github.com/hashicorp/vault/vault"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
@ -24,7 +25,7 @@ func TestGenerateRoot_Cancel(t *testing.T) {
|
||||
ui := new(cli.MockUi)
|
||||
c := &GenerateRootCommand{
|
||||
Key: hex.EncodeToString(key),
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
Ui: ui,
|
||||
},
|
||||
}
|
||||
@ -62,7 +63,7 @@ func TestGenerateRoot_status(t *testing.T) {
|
||||
ui := new(cli.MockUi)
|
||||
c := &GenerateRootCommand{
|
||||
Key: hex.EncodeToString(key),
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
Ui: ui,
|
||||
},
|
||||
}
|
||||
@ -96,7 +97,7 @@ func TestGenerateRoot_OTP(t *testing.T) {
|
||||
ui := new(cli.MockUi)
|
||||
c := &GenerateRootCommand{
|
||||
Key: hex.EncodeToString(key),
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
Ui: ui,
|
||||
},
|
||||
}
|
||||
@ -201,7 +202,7 @@ func TestGenerateRoot_PGP(t *testing.T) {
|
||||
ui := new(cli.MockUi)
|
||||
c := &GenerateRootCommand{
|
||||
Key: hex.EncodeToString(key),
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
Ui: ui,
|
||||
},
|
||||
}
|
||||
|
@ -6,18 +6,19 @@ import (
|
||||
|
||||
"github.com/hashicorp/vault/api"
|
||||
"github.com/hashicorp/vault/helper/pgpkeys"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
)
|
||||
|
||||
// InitCommand is a Command that initializes a new Vault server.
|
||||
type InitCommand struct {
|
||||
Meta
|
||||
meta.Meta
|
||||
}
|
||||
|
||||
func (c *InitCommand) Run(args []string) int {
|
||||
var threshold, shares int
|
||||
var pgpKeys pgpkeys.PubKeyFilesFlag
|
||||
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.IntVar(&shares, "key-shares", 5, "")
|
||||
flags.IntVar(&threshold, "key-threshold", 3, "")
|
||||
@ -106,7 +107,7 @@ Usage: vault init [options]
|
||||
|
||||
General Options:
|
||||
|
||||
` + generalOptionsUsage() + `
|
||||
` + meta.GeneralOptionsUsage() + `
|
||||
|
||||
Init Options:
|
||||
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
|
||||
"github.com/hashicorp/vault/helper/pgpkeys"
|
||||
"github.com/hashicorp/vault/http"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
"github.com/hashicorp/vault/vault"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
@ -15,7 +16,7 @@ import (
|
||||
func TestInit(t *testing.T) {
|
||||
ui := new(cli.MockUi)
|
||||
c := &InitCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
Ui: ui,
|
||||
},
|
||||
}
|
||||
@ -61,7 +62,7 @@ func TestInit(t *testing.T) {
|
||||
func TestInit_Check(t *testing.T) {
|
||||
ui := new(cli.MockUi)
|
||||
c := &InitCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
Ui: ui,
|
||||
},
|
||||
}
|
||||
@ -100,7 +101,7 @@ func TestInit_Check(t *testing.T) {
|
||||
func TestInit_custom(t *testing.T) {
|
||||
ui := new(cli.MockUi)
|
||||
c := &InitCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
Ui: ui,
|
||||
},
|
||||
}
|
||||
@ -150,7 +151,7 @@ func TestInit_custom(t *testing.T) {
|
||||
func TestInit_PGP(t *testing.T) {
|
||||
ui := new(cli.MockUi)
|
||||
c := &InitCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
Ui: ui,
|
||||
},
|
||||
}
|
||||
|
@ -3,15 +3,17 @@ package command
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/vault/meta"
|
||||
)
|
||||
|
||||
// KeyStatusCommand is a Command that provides information about the key status
|
||||
type KeyStatusCommand struct {
|
||||
Meta
|
||||
meta.Meta
|
||||
}
|
||||
|
||||
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()) }
|
||||
if err := flags.Parse(args); err != nil {
|
||||
return 1
|
||||
@ -49,6 +51,6 @@ Usage: vault key-status [options]
|
||||
|
||||
General Options:
|
||||
|
||||
` + generalOptionsUsage()
|
||||
` + meta.GeneralOptionsUsage()
|
||||
return strings.TrimSpace(helpText)
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/vault/http"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
"github.com/hashicorp/vault/vault"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
@ -15,7 +16,7 @@ func TestKeyStatus(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &KeyStatusCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
|
@ -6,11 +6,12 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/vault/api"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
)
|
||||
|
||||
// ListCommand is a Command that lists data from the Vault.
|
||||
type ListCommand struct {
|
||||
Meta
|
||||
meta.Meta
|
||||
}
|
||||
|
||||
func (c *ListCommand) Run(args []string) int {
|
||||
@ -18,7 +19,7 @@ func (c *ListCommand) Run(args []string) int {
|
||||
var err error
|
||||
var secret *api.Secret
|
||||
var flags *flag.FlagSet
|
||||
flags = c.Meta.FlagSet("list", FlagSetDefault)
|
||||
flags = c.Meta.FlagSet("list", meta.FlagSetDefault)
|
||||
flags.StringVar(&format, "format", "table", "")
|
||||
flags.Usage = func() { c.Ui.Error(c.Help()) }
|
||||
if err := flags.Parse(args); err != nil {
|
||||
@ -83,7 +84,7 @@ Usage: vault list [options] path
|
||||
|
||||
General Options:
|
||||
|
||||
` + generalOptionsUsage() + `
|
||||
` + meta.GeneralOptionsUsage() + `
|
||||
|
||||
Read Options:
|
||||
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/vault/http"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
"github.com/hashicorp/vault/vault"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
@ -16,7 +17,7 @@ func TestList(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &ReadCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
|
@ -5,16 +5,17 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/vault/api"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
)
|
||||
|
||||
// MountCommand is a Command that mounts a new mount.
|
||||
type MountCommand struct {
|
||||
Meta
|
||||
meta.Meta
|
||||
}
|
||||
|
||||
func (c *MountCommand) Run(args []string) int {
|
||||
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(&path, "path", "", "")
|
||||
flags.StringVar(&defaultLeaseTTL, "default-lease-ttl", "", "")
|
||||
@ -83,7 +84,7 @@ Usage: vault mount [options] type
|
||||
|
||||
General Options:
|
||||
|
||||
` + generalOptionsUsage() + `
|
||||
` + meta.GeneralOptionsUsage() + `
|
||||
|
||||
Mount Options:
|
||||
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/vault/http"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
"github.com/hashicorp/vault/vault"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
@ -15,7 +16,7 @@ func TestMount(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &MountCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
|
@ -6,16 +6,17 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/vault/meta"
|
||||
"github.com/ryanuber/columnize"
|
||||
)
|
||||
|
||||
// MountsCommand is a Command that lists the mounts.
|
||||
type MountsCommand struct {
|
||||
Meta
|
||||
meta.Meta
|
||||
}
|
||||
|
||||
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()) }
|
||||
if err := flags.Parse(args); err != nil {
|
||||
return 1
|
||||
@ -86,6 +87,6 @@ Usage: vault mounts [options]
|
||||
|
||||
General Options:
|
||||
|
||||
` + generalOptionsUsage()
|
||||
` + meta.GeneralOptionsUsage()
|
||||
return strings.TrimSpace(helpText)
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/vault/http"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
"github.com/hashicorp/vault/vault"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
@ -15,7 +16,7 @@ func TestMounts(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &MountsCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
|
@ -5,17 +5,18 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/vault/api"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
)
|
||||
|
||||
// MountTuneCommand is a Command that remounts a mounted secret backend
|
||||
// to a new endpoint.
|
||||
type MountTuneCommand struct {
|
||||
Meta
|
||||
meta.Meta
|
||||
}
|
||||
|
||||
func (c *MountTuneCommand) Run(args []string) int {
|
||||
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(&maxLeaseTTL, "max-lease-ttl", "", "")
|
||||
flags.Usage = func() { c.Ui.Error(c.Help()) }
|
||||
@ -71,7 +72,7 @@ func (c *MountTuneCommand) Help() string {
|
||||
|
||||
General Options:
|
||||
|
||||
` + generalOptionsUsage() + `
|
||||
` + meta.GeneralOptionsUsage() + `
|
||||
|
||||
Mount Options:
|
||||
|
||||
|
@ -3,15 +3,17 @@ package command
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/vault/meta"
|
||||
)
|
||||
|
||||
// PathHelpCommand is a Command that lists the mounts.
|
||||
type PathHelpCommand struct {
|
||||
Meta
|
||||
meta.Meta
|
||||
}
|
||||
|
||||
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()) }
|
||||
if err := flags.Parse(args); err != nil {
|
||||
return 1
|
||||
@ -70,6 +72,6 @@ Usage: vault path-help [options] path
|
||||
|
||||
General Options:
|
||||
|
||||
` + generalOptionsUsage()
|
||||
` + meta.GeneralOptionsUsage()
|
||||
return strings.TrimSpace(helpText)
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/vault/http"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
"github.com/hashicorp/vault/vault"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
@ -15,7 +16,7 @@ func TestHelp(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &PathHelpCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
|
@ -3,15 +3,17 @@ package command
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/vault/meta"
|
||||
)
|
||||
|
||||
// PolicyDeleteCommand is a Command that enables a new endpoint.
|
||||
type PolicyDeleteCommand struct {
|
||||
Meta
|
||||
meta.Meta
|
||||
}
|
||||
|
||||
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()) }
|
||||
if err := flags.Parse(args); err != nil {
|
||||
return 1
|
||||
@ -59,6 +61,6 @@ Usage: vault policy-delete [options] name
|
||||
|
||||
General Options:
|
||||
|
||||
` + generalOptionsUsage()
|
||||
` + meta.GeneralOptionsUsage()
|
||||
return strings.TrimSpace(helpText)
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/vault/http"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
"github.com/hashicorp/vault/vault"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
@ -15,7 +16,7 @@ func TestPolicyDelete(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &PolicyDeleteCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
|
@ -3,15 +3,17 @@ package command
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/vault/meta"
|
||||
)
|
||||
|
||||
// PolicyListCommand is a Command that enables a new endpoint.
|
||||
type PolicyListCommand struct {
|
||||
Meta
|
||||
meta.Meta
|
||||
}
|
||||
|
||||
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()) }
|
||||
if err := flags.Parse(args); err != nil {
|
||||
return 1
|
||||
@ -86,6 +88,6 @@ Usage: vault policies [options] [name]
|
||||
|
||||
General Options:
|
||||
|
||||
` + generalOptionsUsage()
|
||||
` + meta.GeneralOptionsUsage()
|
||||
return strings.TrimSpace(helpText)
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/vault/http"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
"github.com/hashicorp/vault/vault"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
@ -15,7 +16,7 @@ func TestPolicyList(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &PolicyListCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
@ -36,7 +37,7 @@ func TestPolicyRead(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &PolicyListCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
|
@ -6,15 +6,17 @@ import (
|
||||
"io"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/vault/meta"
|
||||
)
|
||||
|
||||
// PolicyWriteCommand is a Command that enables a new endpoint.
|
||||
type PolicyWriteCommand struct {
|
||||
Meta
|
||||
meta.Meta
|
||||
}
|
||||
|
||||
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()) }
|
||||
if err := flags.Parse(args); err != nil {
|
||||
return 1
|
||||
@ -83,6 +85,6 @@ Usage: vault policy-write [options] name path
|
||||
|
||||
General Options:
|
||||
|
||||
` + generalOptionsUsage()
|
||||
` + meta.GeneralOptionsUsage()
|
||||
return strings.TrimSpace(helpText)
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/vault/http"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
"github.com/hashicorp/vault/vault"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
@ -15,7 +16,7 @@ func TestPolicyWrite(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &PolicyWriteCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
|
@ -8,11 +8,12 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/vault/api"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
)
|
||||
|
||||
// ReadCommand is a Command that reads data from the Vault.
|
||||
type ReadCommand struct {
|
||||
Meta
|
||||
meta.Meta
|
||||
}
|
||||
|
||||
func (c *ReadCommand) Run(args []string) int {
|
||||
@ -21,7 +22,7 @@ func (c *ReadCommand) Run(args []string) int {
|
||||
var err error
|
||||
var secret *api.Secret
|
||||
var flags *flag.FlagSet
|
||||
flags = c.Meta.FlagSet("read", FlagSetDefault)
|
||||
flags = c.Meta.FlagSet("read", meta.FlagSetDefault)
|
||||
flags.StringVar(&format, "format", "table", "")
|
||||
flags.StringVar(&field, "field", "", "")
|
||||
flags.Usage = func() { c.Ui.Error(c.Help()) }
|
||||
@ -101,7 +102,7 @@ Usage: vault read [options] path
|
||||
|
||||
General Options:
|
||||
|
||||
` + generalOptionsUsage() + `
|
||||
` + meta.GeneralOptionsUsage() + `
|
||||
|
||||
Read Options:
|
||||
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/vault/http"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
"github.com/hashicorp/vault/vault"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
@ -15,7 +16,7 @@ func TestRead(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &ReadCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
@ -37,7 +38,7 @@ func TestRead_notFound(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &ReadCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
@ -59,7 +60,7 @@ func TestRead_field(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &ReadCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
@ -103,7 +104,7 @@ func TestRead_field_notFound(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &ReadCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
|
@ -9,11 +9,12 @@ import (
|
||||
"github.com/hashicorp/vault/api"
|
||||
"github.com/hashicorp/vault/helper/password"
|
||||
"github.com/hashicorp/vault/helper/pgpkeys"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
)
|
||||
|
||||
// RekeyCommand is a Command that rekeys the vault.
|
||||
type RekeyCommand struct {
|
||||
Meta
|
||||
meta.Meta
|
||||
|
||||
// Key can be used to pre-seed the key. If it is set, it will not
|
||||
// be asked with the `password` helper.
|
||||
@ -28,7 +29,7 @@ func (c *RekeyCommand) Run(args []string) int {
|
||||
var shares, threshold int
|
||||
var nonce string
|
||||
var pgpKeys pgpkeys.PubKeyFilesFlag
|
||||
flags := c.Meta.FlagSet("rekey", FlagSetDefault)
|
||||
flags := c.Meta.FlagSet("rekey", meta.FlagSetDefault)
|
||||
flags.BoolVar(&init, "init", false, "")
|
||||
flags.BoolVar(&cancel, "cancel", false, "")
|
||||
flags.BoolVar(&status, "status", false, "")
|
||||
@ -301,7 +302,7 @@ Usage: vault rekey [options] [key]
|
||||
|
||||
General Options:
|
||||
|
||||
` + generalOptionsUsage() + `
|
||||
` + meta.GeneralOptionsUsage() + `
|
||||
|
||||
Rekey Options:
|
||||
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
|
||||
"github.com/hashicorp/vault/http"
|
||||
"github.com/hashicorp/vault/logical"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
"github.com/hashicorp/vault/vault"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
@ -22,7 +23,7 @@ func TestRekey(t *testing.T) {
|
||||
ui := new(cli.MockUi)
|
||||
c := &RekeyCommand{
|
||||
Key: hex.EncodeToString(key),
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
Ui: ui,
|
||||
},
|
||||
}
|
||||
@ -48,7 +49,7 @@ func TestRekey_arg(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &RekeyCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
Ui: ui,
|
||||
},
|
||||
}
|
||||
@ -75,7 +76,7 @@ func TestRekey_init(t *testing.T) {
|
||||
ui := new(cli.MockUi)
|
||||
c := &RekeyCommand{
|
||||
Key: hex.EncodeToString(key),
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
Ui: ui,
|
||||
},
|
||||
}
|
||||
@ -110,7 +111,7 @@ func TestRekey_cancel(t *testing.T) {
|
||||
ui := new(cli.MockUi)
|
||||
c := &RekeyCommand{
|
||||
Key: hex.EncodeToString(key),
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
Ui: ui,
|
||||
},
|
||||
}
|
||||
@ -142,7 +143,7 @@ func TestRekey_status(t *testing.T) {
|
||||
ui := new(cli.MockUi)
|
||||
c := &RekeyCommand{
|
||||
Key: hex.EncodeToString(key),
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
Ui: ui,
|
||||
},
|
||||
}
|
||||
@ -179,7 +180,7 @@ func TestRekey_init_pgp(t *testing.T) {
|
||||
ui := new(cli.MockUi)
|
||||
c := &RekeyCommand{
|
||||
Key: hex.EncodeToString(key),
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
Ui: ui,
|
||||
},
|
||||
}
|
||||
|
@ -3,16 +3,18 @@ package command
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/vault/meta"
|
||||
)
|
||||
|
||||
// RemountCommand is a Command that remounts a mounted secret backend
|
||||
// to a new endpoint.
|
||||
type RemountCommand struct {
|
||||
Meta
|
||||
meta.Meta
|
||||
}
|
||||
|
||||
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()) }
|
||||
if err := flags.Parse(args); err != nil {
|
||||
return 1
|
||||
@ -67,7 +69,7 @@ Usage: vault remount [options] from to
|
||||
|
||||
General Options:
|
||||
|
||||
` + generalOptionsUsage()
|
||||
` + meta.GeneralOptionsUsage()
|
||||
|
||||
return strings.TrimSpace(helpText)
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/vault/http"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
"github.com/hashicorp/vault/vault"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
@ -15,7 +16,7 @@ func TestRemount(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &RemountCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
|
@ -4,16 +4,18 @@ import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/vault/meta"
|
||||
)
|
||||
|
||||
// RenewCommand is a Command that mounts a new mount.
|
||||
type RenewCommand struct {
|
||||
Meta
|
||||
meta.Meta
|
||||
}
|
||||
|
||||
func (c *RenewCommand) Run(args []string) int {
|
||||
var format string
|
||||
flags := c.Meta.FlagSet("renew", FlagSetDefault)
|
||||
flags := c.Meta.FlagSet("renew", meta.FlagSetDefault)
|
||||
flags.StringVar(&format, "format", "table", "")
|
||||
flags.Usage = func() { c.Ui.Error(c.Help()) }
|
||||
if err := flags.Parse(args); err != nil {
|
||||
@ -79,7 +81,7 @@ Usage: vault renew [options] id [increment]
|
||||
|
||||
General Options:
|
||||
|
||||
` + generalOptionsUsage() + `
|
||||
` + meta.GeneralOptionsUsage() + `
|
||||
|
||||
Renew Options:
|
||||
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/vault/http"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
"github.com/hashicorp/vault/vault"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
@ -15,7 +16,7 @@ func TestRenew(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &RenewCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
|
@ -3,16 +3,18 @@ package command
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/vault/meta"
|
||||
)
|
||||
|
||||
// RevokeCommand is a Command that mounts a new mount.
|
||||
type RevokeCommand struct {
|
||||
Meta
|
||||
meta.Meta
|
||||
}
|
||||
|
||||
func (c *RevokeCommand) Run(args []string) int {
|
||||
var prefix, force bool
|
||||
flags := c.Meta.FlagSet("revoke", FlagSetDefault)
|
||||
flags := c.Meta.FlagSet("revoke", meta.FlagSetDefault)
|
||||
flags.BoolVar(&prefix, "prefix", false, "")
|
||||
flags.BoolVar(&force, "force", false, "")
|
||||
flags.Usage = func() { c.Ui.Error(c.Help()) }
|
||||
@ -81,7 +83,7 @@ Usage: vault revoke [options] id
|
||||
|
||||
General Options:
|
||||
|
||||
` + generalOptionsUsage() + `
|
||||
` + meta.GeneralOptionsUsage() + `
|
||||
|
||||
Revoke Options:
|
||||
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/vault/http"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
"github.com/hashicorp/vault/vault"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
@ -15,7 +16,7 @@ func TestRevoke(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &RevokeCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
|
@ -3,15 +3,17 @@ package command
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/vault/meta"
|
||||
)
|
||||
|
||||
// RotateCommand is a Command that rotates the encryption key being used
|
||||
type RotateCommand struct {
|
||||
Meta
|
||||
meta.Meta
|
||||
}
|
||||
|
||||
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()) }
|
||||
if err := flags.Parse(args); err != nil {
|
||||
return 1
|
||||
@ -61,6 +63,6 @@ Usage: vault rotate [options]
|
||||
|
||||
General Options:
|
||||
|
||||
` + generalOptionsUsage()
|
||||
` + meta.GeneralOptionsUsage()
|
||||
return strings.TrimSpace(helpText)
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/vault/http"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
"github.com/hashicorp/vault/vault"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
@ -15,7 +16,7 @@ func TestRotate(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &RotateCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
|
@ -3,15 +3,17 @@ package command
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/vault/meta"
|
||||
)
|
||||
|
||||
// SealCommand is a Command that seals the vault.
|
||||
type SealCommand struct {
|
||||
Meta
|
||||
meta.Meta
|
||||
}
|
||||
|
||||
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()) }
|
||||
if err := flags.Parse(args); err != nil {
|
||||
return 1
|
||||
@ -57,6 +59,6 @@ Usage: vault seal [options]
|
||||
|
||||
General Options:
|
||||
|
||||
` + generalOptionsUsage()
|
||||
` + meta.GeneralOptionsUsage()
|
||||
return strings.TrimSpace(helpText)
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/vault/http"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
"github.com/hashicorp/vault/vault"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
@ -15,7 +16,7 @@ func TestSeal(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &SealCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
|
@ -26,6 +26,7 @@ import (
|
||||
"github.com/hashicorp/vault/helper/mlock"
|
||||
vaulthttp "github.com/hashicorp/vault/http"
|
||||
"github.com/hashicorp/vault/logical"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
"github.com/hashicorp/vault/physical"
|
||||
"github.com/hashicorp/vault/vault"
|
||||
"github.com/hashicorp/vault/version"
|
||||
@ -40,7 +41,7 @@ type ServerCommand struct {
|
||||
ShutdownCh chan struct{}
|
||||
SighupCh chan struct{}
|
||||
|
||||
Meta
|
||||
meta.Meta
|
||||
|
||||
ReloadFuncs map[string][]server.ReloadFunc
|
||||
}
|
||||
@ -49,7 +50,7 @@ func (c *ServerCommand) Run(args []string) int {
|
||||
var dev, verifyOnly bool
|
||||
var configPath []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.StringVar(&devRootTokenID, "dev-root-token-id", "", "")
|
||||
flags.StringVar(&devListenAddress, "dev-listen-address", "", "")
|
||||
|
@ -15,6 +15,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/vault/command/server"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
|
||||
@ -66,7 +67,7 @@ listener "tcp" {
|
||||
func TestServer_CommonHA(t *testing.T) {
|
||||
ui := new(cli.MockUi)
|
||||
c := &ServerCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
Ui: ui,
|
||||
},
|
||||
}
|
||||
@ -94,7 +95,7 @@ func TestServer_CommonHA(t *testing.T) {
|
||||
func TestServer_GoodSeparateHA(t *testing.T) {
|
||||
ui := new(cli.MockUi)
|
||||
c := &ServerCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
Ui: ui,
|
||||
},
|
||||
}
|
||||
@ -122,7 +123,7 @@ func TestServer_GoodSeparateHA(t *testing.T) {
|
||||
func TestServer_BadSeparateHA(t *testing.T) {
|
||||
ui := new(cli.MockUi)
|
||||
c := &ServerCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
Ui: ui,
|
||||
},
|
||||
}
|
||||
@ -177,7 +178,7 @@ func TestServer_ReloadListener(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &ServerCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
Ui: ui,
|
||||
},
|
||||
ShutdownCh: MakeShutdownCh(),
|
||||
|
@ -11,13 +11,14 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/vault/builtin/logical/ssh"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
"github.com/mitchellh/mapstructure"
|
||||
)
|
||||
|
||||
// SSHCommand is a Command that establishes a SSH connection
|
||||
// with target by generating a dynamic key
|
||||
type SSHCommand struct {
|
||||
Meta
|
||||
meta.Meta
|
||||
}
|
||||
|
||||
// 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 sshCmdArgs []string
|
||||
var sshDynamicKeyFileName string
|
||||
flags := c.Meta.FlagSet("ssh", FlagSetDefault)
|
||||
flags := c.Meta.FlagSet("ssh", meta.FlagSetDefault)
|
||||
flags.StringVar(&format, "format", "table", "")
|
||||
flags.StringVar(&role, "role", "", "")
|
||||
flags.StringVar(&mountPoint, "mount-point", "ssh", "")
|
||||
@ -256,7 +257,7 @@ Usage: vault ssh [options] username@ip
|
||||
|
||||
General Options:
|
||||
|
||||
` + generalOptionsUsage() + `
|
||||
` + meta.GeneralOptionsUsage() + `
|
||||
|
||||
SSH Options:
|
||||
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
|
||||
logicalssh "github.com/hashicorp/vault/builtin/logical/ssh"
|
||||
"github.com/hashicorp/vault/http"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
"github.com/hashicorp/vault/vault"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
@ -87,7 +88,7 @@ func testSSH(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
mountCmd := &MountCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
@ -120,7 +121,7 @@ func testSSH(t *testing.T) {
|
||||
}
|
||||
|
||||
writeCmd := &WriteCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
@ -150,7 +151,7 @@ func testSSH(t *testing.T) {
|
||||
}
|
||||
|
||||
sshCmd := &SSHCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
|
@ -5,16 +5,17 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/vault/api"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
)
|
||||
|
||||
// StatusCommand is a Command that outputs the status of whether
|
||||
// Vault is sealed or not as well as HA information.
|
||||
type StatusCommand struct {
|
||||
Meta
|
||||
meta.Meta
|
||||
}
|
||||
|
||||
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()) }
|
||||
if err := flags.Parse(args); err != nil {
|
||||
return 1
|
||||
@ -98,6 +99,6 @@ Usage: vault status [options]
|
||||
|
||||
General Options:
|
||||
|
||||
` + generalOptionsUsage()
|
||||
` + meta.GeneralOptionsUsage()
|
||||
return strings.TrimSpace(helpText)
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/vault/http"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
"github.com/hashicorp/vault/vault"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
@ -11,7 +12,7 @@ import (
|
||||
func TestStatus(t *testing.T) {
|
||||
ui := new(cli.MockUi)
|
||||
c := &StatusCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
Ui: ui,
|
||||
},
|
||||
}
|
||||
|
@ -3,15 +3,17 @@ package command
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/vault/meta"
|
||||
)
|
||||
|
||||
// StepDownCommand is a Command that seals the vault.
|
||||
type StepDownCommand struct {
|
||||
Meta
|
||||
meta.Meta
|
||||
}
|
||||
|
||||
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()) }
|
||||
if err := flags.Parse(args); err != nil {
|
||||
return 1
|
||||
@ -49,6 +51,6 @@ Usage: vault step-down [options]
|
||||
|
||||
General Options:
|
||||
|
||||
` + generalOptionsUsage()
|
||||
` + meta.GeneralOptionsUsage()
|
||||
return strings.TrimSpace(helpText)
|
||||
}
|
||||
|
@ -7,11 +7,12 @@ import (
|
||||
"github.com/hashicorp/vault/api"
|
||||
"github.com/hashicorp/vault/helper/flag-kv"
|
||||
"github.com/hashicorp/vault/helper/flag-slice"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
)
|
||||
|
||||
// TokenCreateCommand is a Command that mounts a new mount.
|
||||
type TokenCreateCommand struct {
|
||||
Meta
|
||||
meta.Meta
|
||||
}
|
||||
|
||||
func (c *TokenCreateCommand) Run(args []string) int {
|
||||
@ -21,7 +22,7 @@ func (c *TokenCreateCommand) Run(args []string) int {
|
||||
var metadata map[string]string
|
||||
var numUses int
|
||||
var policies []string
|
||||
flags := c.Meta.FlagSet("mount", FlagSetDefault)
|
||||
flags := c.Meta.FlagSet("mount", meta.FlagSetDefault)
|
||||
flags.StringVar(&format, "format", "table", "")
|
||||
flags.StringVar(&displayName, "display-name", "", "")
|
||||
flags.StringVar(&id, "id", "", "")
|
||||
@ -109,7 +110,7 @@ Usage: vault token-create [options]
|
||||
|
||||
General Options:
|
||||
|
||||
` + generalOptionsUsage() + `
|
||||
` + meta.GeneralOptionsUsage() + `
|
||||
|
||||
Token Options:
|
||||
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/vault/http"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
"github.com/hashicorp/vault/vault"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
@ -16,7 +17,7 @@ func TestTokenCreate(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &TokenCreateCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
|
@ -5,18 +5,19 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/vault/api"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
)
|
||||
|
||||
// TokenLookupCommand is a Command that outputs details about the
|
||||
// provided.
|
||||
type TokenLookupCommand struct {
|
||||
Meta
|
||||
meta.Meta
|
||||
}
|
||||
|
||||
func (c *TokenLookupCommand) Run(args []string) int {
|
||||
var format string
|
||||
var accessor bool
|
||||
flags := c.Meta.FlagSet("token-lookup", FlagSetDefault)
|
||||
flags := c.Meta.FlagSet("token-lookup", meta.FlagSetDefault)
|
||||
flags.BoolVar(&accessor, "accessor", false, "")
|
||||
flags.StringVar(&format, "format", "table", "")
|
||||
flags.Usage = func() { c.Ui.Error(c.Help()) }
|
||||
@ -85,7 +86,7 @@ Usage: vault token-lookup [options] [token|accessor]
|
||||
|
||||
General Options:
|
||||
|
||||
` + generalOptionsUsage() + `
|
||||
` + meta.GeneralOptionsUsage() + `
|
||||
|
||||
Token Lookup Options:
|
||||
-accessor A boolean flag, if set, treats the argument as an accessor of the token.
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
|
||||
"github.com/hashicorp/vault/api"
|
||||
"github.com/hashicorp/vault/http"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
"github.com/hashicorp/vault/vault"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
@ -16,7 +17,7 @@ func TestTokenLookupAccessor(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &TokenLookupCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
@ -62,7 +63,7 @@ func TestTokenLookupSelf(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &TokenLookupCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
@ -88,7 +89,7 @@ func TestTokenLookup(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &TokenLookupCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
|
@ -6,16 +6,17 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/hashicorp/vault/api"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
)
|
||||
|
||||
// TokenRenewCommand is a Command that mounts a new mount.
|
||||
type TokenRenewCommand struct {
|
||||
Meta
|
||||
meta.Meta
|
||||
}
|
||||
|
||||
func (c *TokenRenewCommand) Run(args []string) int {
|
||||
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(&increment, "increment", "", "")
|
||||
flags.Usage = func() { c.Ui.Error(c.Help()) }
|
||||
@ -98,7 +99,7 @@ Usage: vault token-renew [options] [token] [increment]
|
||||
|
||||
General Options:
|
||||
|
||||
` + generalOptionsUsage() + `
|
||||
` + meta.GeneralOptionsUsage() + `
|
||||
|
||||
Token Renew Options:
|
||||
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
|
||||
"github.com/hashicorp/vault/api"
|
||||
"github.com/hashicorp/vault/http"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
"github.com/hashicorp/vault/vault"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
@ -16,7 +17,7 @@ func TestTokenRenew(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &TokenRenewCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
@ -55,7 +56,7 @@ func TestTokenRenewWithIncrement(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &TokenRenewCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
@ -95,7 +96,7 @@ func TestTokenRenewSelf(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &TokenRenewCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
@ -138,7 +139,7 @@ func TestTokenRenewSelfWithIncrement(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &TokenRenewCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
|
@ -3,17 +3,19 @@ package command
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/vault/meta"
|
||||
)
|
||||
|
||||
// TokenRevokeCommand is a Command that mounts a new mount.
|
||||
type TokenRevokeCommand struct {
|
||||
Meta
|
||||
meta.Meta
|
||||
}
|
||||
|
||||
func (c *TokenRevokeCommand) Run(args []string) int {
|
||||
var mode string
|
||||
var accessor bool
|
||||
flags := c.Meta.FlagSet("token-revoke", FlagSetDefault)
|
||||
flags := c.Meta.FlagSet("token-revoke", meta.FlagSetDefault)
|
||||
flags.BoolVar(&accessor, "accessor", false, "")
|
||||
flags.StringVar(&mode, "mode", "", "")
|
||||
flags.Usage = func() { c.Ui.Error(c.Help()) }
|
||||
@ -100,7 +102,7 @@ Usage: vault token-revoke [options] [token|accessor]
|
||||
|
||||
General Options:
|
||||
|
||||
` + generalOptionsUsage() + `
|
||||
` + meta.GeneralOptionsUsage() + `
|
||||
|
||||
Token Options:
|
||||
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/vault/http"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
"github.com/hashicorp/vault/vault"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
@ -15,7 +16,7 @@ func TestTokenRevokeAccessor(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &TokenRevokeCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
@ -70,7 +71,7 @@ func TestTokenRevoke(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &TokenRevokeCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
|
@ -3,15 +3,17 @@ package command
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/vault/meta"
|
||||
)
|
||||
|
||||
// UnmountCommand is a Command that mounts a new mount.
|
||||
type UnmountCommand struct {
|
||||
Meta
|
||||
meta.Meta
|
||||
}
|
||||
|
||||
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()) }
|
||||
if err := flags.Parse(args); err != nil {
|
||||
return 1
|
||||
@ -61,6 +63,6 @@ Usage: vault unmount [options] path
|
||||
|
||||
General Options:
|
||||
|
||||
` + generalOptionsUsage()
|
||||
` + meta.GeneralOptionsUsage()
|
||||
return strings.TrimSpace(helpText)
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/vault/http"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
"github.com/hashicorp/vault/vault"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
@ -15,7 +16,7 @@ func TestUnmount(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &UnmountCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
|
@ -6,11 +6,12 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/vault/helper/password"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
)
|
||||
|
||||
// UnsealCommand is a Command that unseals the vault.
|
||||
type UnsealCommand struct {
|
||||
Meta
|
||||
meta.Meta
|
||||
|
||||
// Key can be used to pre-seed the key. If it is set, it will not
|
||||
// be asked with the `password` helper.
|
||||
@ -19,7 +20,7 @@ type UnsealCommand struct {
|
||||
|
||||
func (c *UnsealCommand) Run(args []string) int {
|
||||
var reset bool
|
||||
flags := c.Meta.FlagSet("unseal", FlagSetDefault)
|
||||
flags := c.Meta.FlagSet("unseal", meta.FlagSetDefault)
|
||||
flags.BoolVar(&reset, "reset", false, "")
|
||||
flags.Usage = func() { c.Ui.Error(c.Help()) }
|
||||
if err := flags.Parse(args); err != nil {
|
||||
@ -115,7 +116,7 @@ Usage: vault unseal [options] [key]
|
||||
|
||||
General Options:
|
||||
|
||||
` + generalOptionsUsage() + `
|
||||
` + meta.GeneralOptionsUsage() + `
|
||||
|
||||
Unseal Options:
|
||||
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/vault/http"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
"github.com/hashicorp/vault/vault"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
@ -18,7 +19,7 @@ func TestUnseal(t *testing.T) {
|
||||
ui := new(cli.MockUi)
|
||||
c := &UnsealCommand{
|
||||
Key: hex.EncodeToString(key),
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
Ui: ui,
|
||||
},
|
||||
}
|
||||
@ -45,7 +46,7 @@ func TestUnseal_arg(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &UnsealCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
Ui: ui,
|
||||
},
|
||||
}
|
||||
|
@ -8,11 +8,12 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/hashicorp/vault/helper/kv-builder"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
)
|
||||
|
||||
// WriteCommand is a Command that puts data into the Vault.
|
||||
type WriteCommand struct {
|
||||
Meta
|
||||
meta.Meta
|
||||
|
||||
// The fields below can be overwritten for tests
|
||||
testStdin io.Reader
|
||||
@ -21,7 +22,7 @@ type WriteCommand struct {
|
||||
func (c *WriteCommand) Run(args []string) int {
|
||||
var field, format string
|
||||
var force bool
|
||||
flags := c.Meta.FlagSet("write", FlagSetDefault)
|
||||
flags := c.Meta.FlagSet("write", meta.FlagSetDefault)
|
||||
flags.StringVar(&format, "format", "table", "")
|
||||
flags.StringVar(&field, "field", "", "")
|
||||
flags.BoolVar(&force, "force", false, "")
|
||||
@ -134,7 +135,7 @@ Usage: vault write [options] path [data]
|
||||
|
||||
General Options:
|
||||
|
||||
` + generalOptionsUsage() + `
|
||||
` + meta.GeneralOptionsUsage() + `
|
||||
|
||||
Write Options:
|
||||
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/vault/http"
|
||||
"github.com/hashicorp/vault/meta"
|
||||
"github.com/hashicorp/vault/vault"
|
||||
"github.com/mitchellh/cli"
|
||||
)
|
||||
@ -19,7 +20,7 @@ func TestWrite(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &WriteCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
@ -57,7 +58,7 @@ func TestWrite_arbitrary(t *testing.T) {
|
||||
stdinR, stdinW := io.Pipe()
|
||||
ui := new(cli.MockUi)
|
||||
c := &WriteCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
@ -101,7 +102,7 @@ func TestWrite_escaped(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &WriteCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
@ -146,7 +147,7 @@ func TestWrite_file(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &WriteCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
@ -191,7 +192,7 @@ func TestWrite_fileValue(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &WriteCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
@ -228,7 +229,7 @@ func TestWrite_Output(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &WriteCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
@ -254,7 +255,7 @@ func TestWrite_force(t *testing.T) {
|
||||
|
||||
ui := new(cli.MockUi)
|
||||
c := &WriteCommand{
|
||||
Meta: Meta{
|
||||
Meta: meta.Meta{
|
||||
ClientToken: token,
|
||||
Ui: ui,
|
||||
},
|
||||
|
@ -1,4 +1,4 @@
|
||||
package command
|
||||
package meta
|
||||
|
||||
import (
|
||||
"fmt"
|
@ -1,4 +1,4 @@
|
||||
package command
|
||||
package meta
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
@ -7,6 +7,8 @@ import (
|
||||
"testing"
|
||||
)
|
||||
|
||||
const FixturePath = "./test-fixtures"
|
||||
|
||||
func TestLoadConfig(t *testing.T) {
|
||||
config, err := LoadConfig(filepath.Join(FixturePath, "config.hcl"))
|
||||
if err != nil {
|
@ -1,4 +1,4 @@
|
||||
package command
|
||||
package meta
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
@ -279,9 +279,9 @@ func (m *Meta) loadCertFromPEM(path string) ([]*x509.Certificate, error) {
|
||||
return certs, nil
|
||||
}
|
||||
|
||||
// generalOptionsUsage returns the usage documenation for commonly
|
||||
// GeneralOptionsUsage returns the usage documenation for commonly
|
||||
// available options
|
||||
func generalOptionsUsage() string {
|
||||
func GeneralOptionsUsage() string {
|
||||
general := `
|
||||
-address=addr The address of the Vault server.
|
||||
Overrides the VAULT_ADDR environment variable if set.
|
@ -1,4 +1,4 @@
|
||||
package command
|
||||
package meta
|
||||
|
||||
import (
|
||||
"flag"
|
Loading…
Reference in New Issue
Block a user