diff --git a/api/ssh.go b/api/ssh.go index 7f0cb157e7..ee6c460732 100644 --- a/api/ssh.go +++ b/api/ssh.go @@ -2,29 +2,29 @@ package api import "fmt" -const SSHDefaultPath = "ssh" +const SSHDefaultMountPoint = "ssh" // SSH is used to return a client to invoke operations on SSH backend. type SSH struct { - c *Client - Path string + c *Client + MountPoint string } // SSH is used to return the client for logical-backend API calls. func (c *Client) SSH() *SSH { - return c.SSHWithPath(SSHDefaultPath) + return c.SSHWithMountPoint(SSHDefaultMountPoint) } -func (c *Client) SSHWithPath(path string) *SSH { +func (c *Client) SSHWithMountPoint(mountPoint string) *SSH { return &SSH{ - c: c, - Path: path, + c: c, + MountPoint: mountPoint, } } // Invokes the SSH backend API to create a dynamic key or an OTP func (c *SSH) Credential(role string, data map[string]interface{}) (*Secret, error) { - r := c.c.NewRequest("PUT", fmt.Sprintf("/v1/%s/creds/%s", c.Path, role)) + r := c.c.NewRequest("PUT", fmt.Sprintf("/v1/%s/creds/%s", c.MountPoint, role)) if err := r.SetJSONBody(data); err != nil { return nil, err } diff --git a/command/ssh.go b/command/ssh.go index 92a3c21e4e..0bc6314a0c 100644 --- a/command/ssh.go +++ b/command/ssh.go @@ -19,14 +19,14 @@ type SSHCommand struct { } func (c *SSHCommand) Run(args []string) int { - var role, port, path string + var role, port, mountPoint string var noExec bool var sshCmdArgs []string var sshDynamicKeyFileName string flags := c.Meta.FlagSet("ssh", FlagSetDefault) flags.StringVar(&role, "role", "", "") flags.StringVar(&port, "port", "22", "") - flags.StringVar(&path, "path", "ssh", "") + flags.StringVar(&mountPoint, "mount-point", "ssh", "") flags.BoolVar(&noExec, "no-exec", false, "") flags.Usage = func() { c.Ui.Error(c.Help()) } @@ -70,7 +70,7 @@ func (c *SSHCommand) Run(args []string) int { } if role == "" { - role, err = c.defaultRole(path, ip.String()) + role, err = c.defaultRole(mountPoint, ip.String()) if err != nil { c.Ui.Error(fmt.Sprintf("Error setting default role: %s", err)) return 1 @@ -83,7 +83,7 @@ func (c *SSHCommand) Run(args []string) int { "ip": ip.String(), } - keySecret, err := client.SSHWithPath(path).Credential(role, data) + keySecret, err := client.SSHWithMountPoint(mountPoint).Credential(role, data) if err != nil { c.Ui.Error(fmt.Sprintf("Error getting key for SSH session:%s", err)) return 2 @@ -152,7 +152,7 @@ func (c *SSHCommand) Run(args []string) int { // If user did not provide the role with which SSH connection has // to be established and if there is only one role associated with // the IP, it is used by default. -func (c *SSHCommand) defaultRole(path, ip string) (string, error) { +func (c *SSHCommand) defaultRole(mountPoint, ip string) (string, error) { data := map[string]interface{}{ "ip": ip, } @@ -160,7 +160,7 @@ func (c *SSHCommand) defaultRole(path, ip string) (string, error) { if err != nil { return "", err } - secret, err := client.Logical().Write(path+"/lookup", data) + secret, err := client.Logical().Write(mountPoint+"/lookup", data) if err != nil { return "", fmt.Errorf("Error finding roles for IP %s: %s", ip, err) @@ -222,7 +222,7 @@ SSH Options: -no-exec Shows the credentials but does not establish connection. - -path Mount point of SSH backend. If the backend is mounted at + -mount-point Mount point of SSH backend. If the backend is mounted at 'ssh', which is the default as well, this parameter can be skipped. `