2015-04-12 23:58:45 +00:00
|
|
|
package cli
|
2015-03-04 07:03:24 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
|
2015-04-05 01:07:53 +00:00
|
|
|
auditFile "github.com/hashicorp/vault/builtin/audit/file"
|
|
|
|
|
2015-04-05 01:40:21 +00:00
|
|
|
credAppId "github.com/hashicorp/vault/builtin/credential/app-id"
|
|
|
|
credGitHub "github.com/hashicorp/vault/builtin/credential/github"
|
2015-04-19 22:17:24 +00:00
|
|
|
credUserpass "github.com/hashicorp/vault/builtin/credential/userpass"
|
2015-04-05 01:07:53 +00:00
|
|
|
|
2015-03-20 18:32:18 +00:00
|
|
|
"github.com/hashicorp/vault/builtin/logical/aws"
|
2015-03-21 16:25:12 +00:00
|
|
|
"github.com/hashicorp/vault/builtin/logical/consul"
|
2015-04-19 01:44:23 +00:00
|
|
|
"github.com/hashicorp/vault/builtin/logical/postgresql"
|
2015-04-16 00:08:12 +00:00
|
|
|
"github.com/hashicorp/vault/builtin/logical/transit"
|
2015-04-05 01:07:53 +00:00
|
|
|
|
|
|
|
"github.com/hashicorp/vault/audit"
|
2015-03-30 16:21:59 +00:00
|
|
|
tokenDisk "github.com/hashicorp/vault/builtin/token/disk"
|
2015-03-04 07:03:24 +00:00
|
|
|
"github.com/hashicorp/vault/command"
|
2015-03-20 18:32:18 +00:00
|
|
|
"github.com/hashicorp/vault/logical"
|
2015-03-04 07:03:24 +00:00
|
|
|
"github.com/mitchellh/cli"
|
|
|
|
)
|
|
|
|
|
2015-04-13 00:19:26 +00:00
|
|
|
// 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 {
|
|
|
|
if metaPtr == nil {
|
|
|
|
metaPtr = new(command.Meta)
|
2015-03-04 07:34:32 +00:00
|
|
|
}
|
2015-03-04 07:03:24 +00:00
|
|
|
|
2015-04-13 00:19:26 +00:00
|
|
|
meta := *metaPtr
|
|
|
|
if meta.Ui == nil {
|
|
|
|
meta.Ui = &cli.BasicUi{
|
|
|
|
Writer: os.Stdout,
|
|
|
|
ErrorWriter: os.Stderr,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return map[string]cli.CommandFactory{
|
2015-04-07 20:46:35 +00:00
|
|
|
"init": func() (cli.Command, error) {
|
|
|
|
return &command.InitCommand{
|
|
|
|
Meta: meta,
|
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
|
|
|
"server": func() (cli.Command, error) {
|
|
|
|
return &command.ServerCommand{
|
|
|
|
Meta: meta,
|
|
|
|
AuditBackends: map[string]audit.Factory{
|
|
|
|
"file": auditFile.Factory,
|
|
|
|
},
|
|
|
|
CredentialBackends: map[string]logical.Factory{
|
2015-04-19 22:17:24 +00:00
|
|
|
"app-id": credAppId.Factory,
|
|
|
|
"github": credGitHub.Factory,
|
|
|
|
"userpass": credUserpass.Factory,
|
2015-04-07 20:46:35 +00:00
|
|
|
},
|
|
|
|
LogicalBackends: map[string]logical.Factory{
|
2015-04-19 01:44:23 +00:00
|
|
|
"aws": aws.Factory,
|
|
|
|
"consul": consul.Factory,
|
|
|
|
"postgresql": postgresql.Factory,
|
|
|
|
"transit": transit.Factory,
|
2015-04-07 20:46:35 +00:00
|
|
|
},
|
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-04-03 05:42:05 +00:00
|
|
|
"help": func() (cli.Command, error) {
|
|
|
|
return &command.HelpCommand{
|
|
|
|
Meta: meta,
|
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-03-04 07:34:32 +00:00
|
|
|
"auth": func() (cli.Command, error) {
|
|
|
|
return &command.AuthCommand{
|
|
|
|
Meta: meta,
|
2015-04-06 16:53:43 +00:00
|
|
|
Handlers: map[string]command.AuthHandler{
|
2015-04-19 22:17:24 +00:00
|
|
|
"github": &credGitHub.CLIHandler{},
|
|
|
|
"userpass": &credUserpass.CLIHandler{},
|
2015-04-06 16:53:43 +00:00
|
|
|
},
|
2015-03-04 07:34:32 +00:00
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-04-02 00:09:11 +00:00
|
|
|
"auth-enable": func() (cli.Command, error) {
|
|
|
|
return &command.AuthEnableCommand{
|
|
|
|
Meta: meta,
|
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-04-02 00:14:11 +00:00
|
|
|
"auth-disable": func() (cli.Command, error) {
|
|
|
|
return &command.AuthDisableCommand{
|
|
|
|
Meta: meta,
|
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-04-08 01:19:44 +00:00
|
|
|
"audit-list": func() (cli.Command, error) {
|
|
|
|
return &command.AuditListCommand{
|
|
|
|
Meta: meta,
|
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-04-08 01:23:28 +00:00
|
|
|
"audit-disable": func() (cli.Command, error) {
|
|
|
|
return &command.AuditDisableCommand{
|
|
|
|
Meta: meta,
|
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-04-08 05:42:04 +00:00
|
|
|
"audit-enable": func() (cli.Command, error) {
|
|
|
|
return &command.AuditEnableCommand{
|
|
|
|
Meta: meta,
|
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-04-02 06:07:49 +00:00
|
|
|
"policies": func() (cli.Command, error) {
|
2015-04-02 01:45:11 +00:00
|
|
|
return &command.PolicyListCommand{
|
|
|
|
Meta: meta,
|
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-04-19 23:36:11 +00:00
|
|
|
"policy-delete": func() (cli.Command, error) {
|
|
|
|
return &command.PolicyDeleteCommand{
|
|
|
|
Meta: meta,
|
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-04-02 05:58:37 +00:00
|
|
|
"policy-write": func() (cli.Command, error) {
|
|
|
|
return &command.PolicyWriteCommand{
|
|
|
|
Meta: meta,
|
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-03-16 03:35:33 +00:00
|
|
|
"read": func() (cli.Command, error) {
|
|
|
|
return &command.ReadCommand{
|
2015-03-04 19:08:13 +00:00
|
|
|
Meta: meta,
|
|
|
|
}, nil
|
|
|
|
},
|
2015-03-04 07:34:32 +00:00
|
|
|
|
2015-03-16 03:35:33 +00:00
|
|
|
"write": func() (cli.Command, error) {
|
|
|
|
return &command.WriteCommand{
|
2015-03-04 19:08:13 +00:00
|
|
|
Meta: meta,
|
|
|
|
}, nil
|
|
|
|
},
|
2015-03-04 07:34:32 +00:00
|
|
|
|
2015-04-07 18:16:08 +00:00
|
|
|
"delete": func() (cli.Command, error) {
|
|
|
|
return &command.DeleteCommand{
|
|
|
|
Meta: meta,
|
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-04-14 00:37:39 +00:00
|
|
|
"renew": func() (cli.Command, error) {
|
|
|
|
return &command.RenewCommand{
|
|
|
|
Meta: meta,
|
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-04-01 02:21:02 +00:00
|
|
|
"revoke": func() (cli.Command, error) {
|
|
|
|
return &command.RevokeCommand{
|
|
|
|
Meta: meta,
|
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-03-04 16:56:10 +00:00
|
|
|
"seal": func() (cli.Command, error) {
|
|
|
|
return &command.SealCommand{
|
|
|
|
Meta: meta,
|
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-03-13 18:33:17 +00:00
|
|
|
"seal-status": func() (cli.Command, error) {
|
|
|
|
return &command.SealStatusCommand{
|
|
|
|
Meta: meta,
|
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-03-04 07:57:23 +00:00
|
|
|
"unseal": func() (cli.Command, error) {
|
|
|
|
return &command.UnsealCommand{
|
|
|
|
Meta: meta,
|
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-03-31 23:28:46 +00:00
|
|
|
"mount": func() (cli.Command, error) {
|
|
|
|
return &command.MountCommand{
|
|
|
|
Meta: meta,
|
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-03-16 04:28:31 +00:00
|
|
|
"mounts": func() (cli.Command, error) {
|
|
|
|
return &command.MountsCommand{
|
|
|
|
Meta: meta,
|
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-04-07 17:46:47 +00:00
|
|
|
"remount": func() (cli.Command, error) {
|
|
|
|
return &command.RemountCommand{
|
|
|
|
Meta: meta,
|
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-04-07 17:38:51 +00:00
|
|
|
"unmount": func() (cli.Command, error) {
|
|
|
|
return &command.UnmountCommand{
|
|
|
|
Meta: meta,
|
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-04-07 21:20:18 +00:00
|
|
|
"token-create": func() (cli.Command, error) {
|
|
|
|
return &command.TokenCreateCommand{
|
|
|
|
Meta: meta,
|
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-04-07 21:36:17 +00:00
|
|
|
"token-revoke": func() (cli.Command, error) {
|
|
|
|
return &command.TokenRevokeCommand{
|
|
|
|
Meta: meta,
|
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-03-04 07:03:24 +00:00
|
|
|
"version": func() (cli.Command, error) {
|
|
|
|
ver := Version
|
|
|
|
rel := VersionPrerelease
|
|
|
|
if GitDescribe != "" {
|
|
|
|
ver = GitDescribe
|
|
|
|
}
|
|
|
|
if GitDescribe == "" && rel == "" {
|
|
|
|
rel = "dev"
|
|
|
|
}
|
|
|
|
|
|
|
|
return &command.VersionCommand{
|
|
|
|
Revision: GitCommit,
|
|
|
|
Version: ver,
|
|
|
|
VersionPrerelease: rel,
|
2015-04-13 00:19:26 +00:00
|
|
|
Ui: meta.Ui,
|
2015-03-04 07:03:24 +00:00
|
|
|
}, nil
|
|
|
|
},
|
2015-03-30 16:21:59 +00:00
|
|
|
|
2015-04-13 00:19:26 +00:00
|
|
|
// The commands below are hidden from the help output
|
|
|
|
"token-disk": func() (cli.Command, error) {
|
|
|
|
return &tokenDisk.Command{}, nil
|
|
|
|
},
|
2015-03-30 16:21:59 +00:00
|
|
|
}
|
2015-03-04 07:03:24 +00:00
|
|
|
}
|