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"
|
2016-12-07 04:35:30 +00:00
|
|
|
auditSocket "github.com/hashicorp/vault/builtin/audit/socket"
|
2015-04-24 18:06:19 +00:00
|
|
|
auditSyslog "github.com/hashicorp/vault/builtin/audit/syslog"
|
2015-11-09 18:52:55 +00:00
|
|
|
"github.com/hashicorp/vault/version"
|
2015-04-05 01:07:53 +00:00
|
|
|
|
2015-04-05 01:40:21 +00:00
|
|
|
credAppId "github.com/hashicorp/vault/builtin/credential/app-id"
|
2016-05-30 18:30:01 +00:00
|
|
|
credAppRole "github.com/hashicorp/vault/builtin/credential/approle"
|
2016-05-29 14:55:06 +00:00
|
|
|
credAwsEc2 "github.com/hashicorp/vault/builtin/credential/aws-ec2"
|
2015-04-24 04:46:30 +00:00
|
|
|
credCert "github.com/hashicorp/vault/builtin/credential/cert"
|
2015-04-05 01:40:21 +00:00
|
|
|
credGitHub "github.com/hashicorp/vault/builtin/credential/github"
|
2015-05-06 01:54:27 +00:00
|
|
|
credLdap "github.com/hashicorp/vault/builtin/credential/ldap"
|
2017-01-27 00:08:52 +00:00
|
|
|
credOkta "github.com/hashicorp/vault/builtin/credential/okta"
|
2017-02-07 21:04:27 +00:00
|
|
|
credRadius "github.com/hashicorp/vault/builtin/credential/radius"
|
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-06-19 17:10:19 +00:00
|
|
|
"github.com/hashicorp/vault/builtin/logical/cassandra"
|
2015-03-21 16:25:12 +00:00
|
|
|
"github.com/hashicorp/vault/builtin/logical/consul"
|
2016-12-19 18:15:58 +00:00
|
|
|
"github.com/hashicorp/vault/builtin/logical/database"
|
2016-05-13 20:42:09 +00:00
|
|
|
"github.com/hashicorp/vault/builtin/logical/mongodb"
|
2016-03-03 14:19:17 +00:00
|
|
|
"github.com/hashicorp/vault/builtin/logical/mssql"
|
2015-04-25 19:06:08 +00:00
|
|
|
"github.com/hashicorp/vault/builtin/logical/mysql"
|
2015-05-15 16:13:05 +00:00
|
|
|
"github.com/hashicorp/vault/builtin/logical/pki"
|
2015-04-19 01:44:23 +00:00
|
|
|
"github.com/hashicorp/vault/builtin/logical/postgresql"
|
2015-11-18 16:25:42 +00:00
|
|
|
"github.com/hashicorp/vault/builtin/logical/rabbitmq"
|
2015-06-16 20:58:54 +00:00
|
|
|
"github.com/hashicorp/vault/builtin/logical/ssh"
|
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-04 07:03:24 +00:00
|
|
|
"github.com/hashicorp/vault/command"
|
2015-03-20 18:32:18 +00:00
|
|
|
"github.com/hashicorp/vault/logical"
|
2016-04-01 17:16:05 +00:00
|
|
|
"github.com/hashicorp/vault/meta"
|
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.
|
2016-04-01 17:16:05 +00:00
|
|
|
func Commands(metaPtr *meta.Meta) map[string]cli.CommandFactory {
|
2015-04-13 00:19:26 +00:00
|
|
|
if metaPtr == nil {
|
2016-04-01 18:23:15 +00:00
|
|
|
metaPtr = &meta.Meta{
|
|
|
|
TokenHelper: command.DefaultTokenHelper,
|
|
|
|
}
|
2015-03-04 07:34:32 +00:00
|
|
|
}
|
2015-03-04 07:03:24 +00:00
|
|
|
|
2016-04-01 17:16:05 +00:00
|
|
|
if metaPtr.Ui == nil {
|
|
|
|
metaPtr.Ui = &cli.BasicUi{
|
2015-04-13 00:19:26 +00:00
|
|
|
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{
|
2016-04-01 17:16:05 +00:00
|
|
|
Meta: *metaPtr,
|
2015-04-07 20:46:35 +00:00
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
|
|
|
"server": func() (cli.Command, error) {
|
|
|
|
return &command.ServerCommand{
|
2016-04-01 17:16:05 +00:00
|
|
|
Meta: *metaPtr,
|
2015-04-07 20:46:35 +00:00
|
|
|
AuditBackends: map[string]audit.Factory{
|
2015-04-24 18:06:19 +00:00
|
|
|
"file": auditFile.Factory,
|
|
|
|
"syslog": auditSyslog.Factory,
|
2016-12-07 04:35:30 +00:00
|
|
|
"socket": auditSocket.Factory,
|
2015-04-07 20:46:35 +00:00
|
|
|
},
|
|
|
|
CredentialBackends: map[string]logical.Factory{
|
2016-05-30 18:30:01 +00:00
|
|
|
"approle": credAppRole.Factory,
|
2015-04-24 04:46:30 +00:00
|
|
|
"cert": credCert.Factory,
|
2016-05-29 14:55:06 +00:00
|
|
|
"aws-ec2": credAwsEc2.Factory,
|
2015-04-19 22:17:24 +00:00
|
|
|
"app-id": credAppId.Factory,
|
|
|
|
"github": credGitHub.Factory,
|
|
|
|
"userpass": credUserpass.Factory,
|
2015-05-06 01:54:27 +00:00
|
|
|
"ldap": credLdap.Factory,
|
2017-01-27 00:08:52 +00:00
|
|
|
"okta": credOkta.Factory,
|
2017-02-07 21:04:27 +00:00
|
|
|
"radius": credRadius.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,
|
2015-06-19 17:10:19 +00:00
|
|
|
"cassandra": cassandra.Factory,
|
2015-05-15 16:13:05 +00:00
|
|
|
"pki": pki.Factory,
|
2015-04-19 01:44:23 +00:00
|
|
|
"transit": transit.Factory,
|
2016-05-13 20:42:09 +00:00
|
|
|
"mongodb": mongodb.Factory,
|
2016-03-03 14:19:17 +00:00
|
|
|
"mssql": mssql.Factory,
|
2015-04-25 19:06:08 +00:00
|
|
|
"mysql": mysql.Factory,
|
2015-06-16 20:58:54 +00:00
|
|
|
"ssh": ssh.Factory,
|
2015-11-18 16:25:42 +00:00
|
|
|
"rabbitmq": rabbitmq.Factory,
|
2016-12-19 18:15:58 +00:00
|
|
|
"database": database.Factory,
|
2015-04-07 20:46:35 +00:00
|
|
|
},
|
2016-09-30 04:06:40 +00:00
|
|
|
ShutdownCh: command.MakeShutdownCh(),
|
|
|
|
SighupCh: command.MakeSighupCh(),
|
2015-04-07 20:46:35 +00:00
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-06-17 16:39:49 +00:00
|
|
|
"ssh": func() (cli.Command, error) {
|
2015-07-01 15:58:49 +00:00
|
|
|
return &command.SSHCommand{
|
2016-04-01 17:16:05 +00:00
|
|
|
Meta: *metaPtr,
|
2015-06-17 16:39:49 +00:00
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-06-18 22:56:42 +00:00
|
|
|
"path-help": func() (cli.Command, error) {
|
|
|
|
return &command.PathHelpCommand{
|
2016-04-01 17:16:05 +00:00
|
|
|
Meta: *metaPtr,
|
2015-04-03 05:42:05 +00:00
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-03-04 07:34:32 +00:00
|
|
|
"auth": func() (cli.Command, error) {
|
|
|
|
return &command.AuthCommand{
|
2016-04-01 17:16:05 +00:00
|
|
|
Meta: *metaPtr,
|
2015-04-06 16:53:43 +00:00
|
|
|
Handlers: map[string]command.AuthHandler{
|
2015-04-19 22:17:24 +00:00
|
|
|
"github": &credGitHub.CLIHandler{},
|
2017-02-04 12:47:09 +00:00
|
|
|
"userpass": &credUserpass.CLIHandler{DefaultMount: "userpass"},
|
2015-05-06 01:54:27 +00:00
|
|
|
"ldap": &credLdap.CLIHandler{},
|
2017-01-27 00:08:52 +00:00
|
|
|
"okta": &credOkta.CLIHandler{},
|
2015-06-30 03:29:41 +00:00
|
|
|
"cert": &credCert.CLIHandler{},
|
2017-02-07 21:04:27 +00:00
|
|
|
"radius": &credUserpass.CLIHandler{DefaultMount: "radius"},
|
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{
|
2016-04-01 17:16:05 +00:00
|
|
|
Meta: *metaPtr,
|
2015-04-02 00:09:11 +00:00
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-04-02 00:14:11 +00:00
|
|
|
"auth-disable": func() (cli.Command, error) {
|
|
|
|
return &command.AuthDisableCommand{
|
2016-04-01 17:16:05 +00:00
|
|
|
Meta: *metaPtr,
|
2015-04-02 00:14:11 +00:00
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-04-08 01:19:44 +00:00
|
|
|
"audit-list": func() (cli.Command, error) {
|
|
|
|
return &command.AuditListCommand{
|
2016-04-01 17:16:05 +00:00
|
|
|
Meta: *metaPtr,
|
2015-04-08 01:19:44 +00:00
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-04-08 01:23:28 +00:00
|
|
|
"audit-disable": func() (cli.Command, error) {
|
|
|
|
return &command.AuditDisableCommand{
|
2016-04-01 17:16:05 +00:00
|
|
|
Meta: *metaPtr,
|
2015-04-08 01:23:28 +00:00
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-04-08 05:42:04 +00:00
|
|
|
"audit-enable": func() (cli.Command, error) {
|
|
|
|
return &command.AuditEnableCommand{
|
2016-04-01 17:16:05 +00:00
|
|
|
Meta: *metaPtr,
|
2015-04-08 05:42:04 +00:00
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-05-28 01:17:02 +00:00
|
|
|
"key-status": func() (cli.Command, error) {
|
|
|
|
return &command.KeyStatusCommand{
|
2016-04-01 17:16:05 +00:00
|
|
|
Meta: *metaPtr,
|
2015-05-28 01:17:02 +00:00
|
|
|
}, 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{
|
2016-04-01 17:16:05 +00:00
|
|
|
Meta: *metaPtr,
|
2015-04-02 01:45:11 +00:00
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-04-19 23:36:11 +00:00
|
|
|
"policy-delete": func() (cli.Command, error) {
|
|
|
|
return &command.PolicyDeleteCommand{
|
2016-04-01 17:16:05 +00:00
|
|
|
Meta: *metaPtr,
|
2015-04-19 23:36:11 +00:00
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-04-02 05:58:37 +00:00
|
|
|
"policy-write": func() (cli.Command, error) {
|
|
|
|
return &command.PolicyWriteCommand{
|
2016-04-01 17:16:05 +00:00
|
|
|
Meta: *metaPtr,
|
2015-04-02 05:58:37 +00:00
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-03-16 03:35:33 +00:00
|
|
|
"read": func() (cli.Command, error) {
|
|
|
|
return &command.ReadCommand{
|
2016-04-01 17:16:05 +00:00
|
|
|
Meta: *metaPtr,
|
2015-03-04 19:08:13 +00:00
|
|
|
}, nil
|
|
|
|
},
|
2015-03-04 07:34:32 +00:00
|
|
|
|
2016-05-19 15:25:15 +00:00
|
|
|
"unwrap": func() (cli.Command, error) {
|
|
|
|
return &command.UnwrapCommand{
|
|
|
|
Meta: *metaPtr,
|
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2016-01-14 19:18:27 +00:00
|
|
|
"list": func() (cli.Command, error) {
|
|
|
|
return &command.ListCommand{
|
2016-04-01 17:16:05 +00:00
|
|
|
Meta: *metaPtr,
|
2015-03-04 19:08:13 +00:00
|
|
|
}, nil
|
|
|
|
},
|
2015-03-04 07:34:32 +00:00
|
|
|
|
2016-01-14 19:18:27 +00:00
|
|
|
"write": func() (cli.Command, error) {
|
|
|
|
return &command.WriteCommand{
|
2016-04-01 17:16:05 +00:00
|
|
|
Meta: *metaPtr,
|
2015-04-07 18:16:08 +00:00
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2016-01-14 19:18:27 +00:00
|
|
|
"delete": func() (cli.Command, error) {
|
|
|
|
return &command.DeleteCommand{
|
2016-04-01 17:16:05 +00:00
|
|
|
Meta: *metaPtr,
|
2015-09-14 19:42:12 +00:00
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-05-28 22:08:09 +00:00
|
|
|
"rekey": func() (cli.Command, error) {
|
|
|
|
return &command.RekeyCommand{
|
2016-04-01 17:16:05 +00:00
|
|
|
Meta: *metaPtr,
|
2015-05-28 22:08:09 +00:00
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2016-01-09 02:21:02 +00:00
|
|
|
"generate-root": func() (cli.Command, error) {
|
|
|
|
return &command.GenerateRootCommand{
|
2016-04-01 17:16:05 +00:00
|
|
|
Meta: *metaPtr,
|
2016-01-09 02:21:02 +00:00
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-04-14 00:37:39 +00:00
|
|
|
"renew": func() (cli.Command, error) {
|
|
|
|
return &command.RenewCommand{
|
2016-04-01 17:16:05 +00:00
|
|
|
Meta: *metaPtr,
|
2015-04-14 00:37:39 +00:00
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-04-01 02:21:02 +00:00
|
|
|
"revoke": func() (cli.Command, error) {
|
|
|
|
return &command.RevokeCommand{
|
2016-04-01 17:16:05 +00:00
|
|
|
Meta: *metaPtr,
|
2015-04-01 02:21:02 +00:00
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-03-04 16:56:10 +00:00
|
|
|
"seal": func() (cli.Command, error) {
|
|
|
|
return &command.SealCommand{
|
2016-04-01 17:16:05 +00:00
|
|
|
Meta: *metaPtr,
|
2015-03-04 16:56:10 +00:00
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-04-20 19:11:21 +00:00
|
|
|
"status": func() (cli.Command, error) {
|
|
|
|
return &command.StatusCommand{
|
2016-04-01 17:16:05 +00:00
|
|
|
Meta: *metaPtr,
|
2015-03-13 18:33:17 +00:00
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-03-04 07:57:23 +00:00
|
|
|
"unseal": func() (cli.Command, error) {
|
|
|
|
return &command.UnsealCommand{
|
2016-04-01 17:16:05 +00:00
|
|
|
Meta: *metaPtr,
|
2015-03-04 07:57:23 +00:00
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2016-02-27 00:43:55 +00:00
|
|
|
"step-down": func() (cli.Command, error) {
|
|
|
|
return &command.StepDownCommand{
|
2016-04-01 17:16:05 +00:00
|
|
|
Meta: *metaPtr,
|
2016-02-27 00:43:55 +00:00
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-03-31 23:28:46 +00:00
|
|
|
"mount": func() (cli.Command, error) {
|
|
|
|
return &command.MountCommand{
|
2016-04-01 17:16:05 +00:00
|
|
|
Meta: *metaPtr,
|
2015-03-31 23:28:46 +00:00
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-03-16 04:28:31 +00:00
|
|
|
"mounts": func() (cli.Command, error) {
|
|
|
|
return &command.MountsCommand{
|
2016-04-01 17:16:05 +00:00
|
|
|
Meta: *metaPtr,
|
2015-03-16 04:28:31 +00:00
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-09-02 19:56:58 +00:00
|
|
|
"mount-tune": func() (cli.Command, error) {
|
|
|
|
return &command.MountTuneCommand{
|
2016-04-01 17:16:05 +00:00
|
|
|
Meta: *metaPtr,
|
2015-09-02 19:56:58 +00:00
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-04-07 17:46:47 +00:00
|
|
|
"remount": func() (cli.Command, error) {
|
|
|
|
return &command.RemountCommand{
|
2016-04-01 17:16:05 +00:00
|
|
|
Meta: *metaPtr,
|
2015-04-07 17:46:47 +00:00
|
|
|
}, nil
|
2015-05-28 17:16:33 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
"rotate": func() (cli.Command, error) {
|
|
|
|
return &command.RotateCommand{
|
2016-04-01 17:16:05 +00:00
|
|
|
Meta: *metaPtr,
|
2015-05-28 17:16:33 +00:00
|
|
|
}, nil
|
2015-04-07 17:46:47 +00:00
|
|
|
},
|
|
|
|
|
2015-04-07 17:38:51 +00:00
|
|
|
"unmount": func() (cli.Command, error) {
|
|
|
|
return &command.UnmountCommand{
|
2016-04-01 17:16:05 +00:00
|
|
|
Meta: *metaPtr,
|
2015-04-07 17:38:51 +00:00
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-04-07 21:20:18 +00:00
|
|
|
"token-create": func() (cli.Command, error) {
|
|
|
|
return &command.TokenCreateCommand{
|
2016-04-01 17:16:05 +00:00
|
|
|
Meta: *metaPtr,
|
2015-04-07 21:20:18 +00:00
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-12-29 20:18:59 +00:00
|
|
|
"token-lookup": func() (cli.Command, error) {
|
|
|
|
return &command.TokenLookupCommand{
|
2016-04-01 17:16:05 +00:00
|
|
|
Meta: *metaPtr,
|
2015-12-29 20:18:59 +00:00
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-04-20 01:04:24 +00:00
|
|
|
"token-renew": func() (cli.Command, error) {
|
|
|
|
return &command.TokenRenewCommand{
|
2016-04-01 17:16:05 +00:00
|
|
|
Meta: *metaPtr,
|
2015-04-20 01:04:24 +00:00
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-04-07 21:36:17 +00:00
|
|
|
"token-revoke": func() (cli.Command, error) {
|
|
|
|
return &command.TokenRevokeCommand{
|
2016-04-01 17:16:05 +00:00
|
|
|
Meta: *metaPtr,
|
2015-04-07 21:36:17 +00:00
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2016-03-02 18:42:32 +00:00
|
|
|
"capabilities": func() (cli.Command, error) {
|
|
|
|
return &command.CapabilitiesCommand{
|
2016-04-01 17:16:05 +00:00
|
|
|
Meta: *metaPtr,
|
2016-03-02 18:42:32 +00:00
|
|
|
}, nil
|
|
|
|
},
|
|
|
|
|
2015-03-04 07:03:24 +00:00
|
|
|
"version": func() (cli.Command, error) {
|
2015-11-09 18:52:55 +00:00
|
|
|
versionInfo := version.GetVersion()
|
2015-03-04 07:03:24 +00:00
|
|
|
|
|
|
|
return &command.VersionCommand{
|
2015-11-09 18:52:55 +00:00
|
|
|
VersionInfo: versionInfo,
|
2016-04-01 17:16:05 +00:00
|
|
|
Ui: metaPtr.Ui,
|
2015-03-04 07:03:24 +00:00
|
|
|
}, nil
|
|
|
|
},
|
2015-03-30 16:21:59 +00:00
|
|
|
}
|
2015-03-04 07:03:24 +00:00
|
|
|
}
|