Trivial cleanup / ordering / inline doc

Signed-off-by: Olivier Gambier <olivier@docker.com>
This commit is contained in:
Olivier Gambier 2015-10-20 18:37:36 -07:00
parent bf3cd8b8f4
commit c2589c8099
5 changed files with 14 additions and 18 deletions

View File

@ -55,6 +55,7 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
}
}
// NewDriver creates and returns a new instance of the driver
func NewDriver(hostName, storePath string) drivers.Driver {
return &Driver{
SSHKey: defaultSSHKey,

View File

@ -9,11 +9,7 @@ import (
"github.com/docker/machine/libmachine/state"
)
const drivername = "none"
// func main() {
// plugin.RegisterDriver(new(Driver))
// }
const driverName = "none"
// Driver is the driver used when no driver is selected. It is used to
// connect to existing Docker hosts by specifying the URL of the host as
@ -47,7 +43,7 @@ func (d *Driver) Create() error {
}
func (d *Driver) DriverName() string {
return drivername
return driverName
}
func (d *Driver) GetIP() (string, error) {

View File

@ -20,12 +20,12 @@ func (d *BaseDriver) GetSSHKeyPath() string {
return filepath.Join(d.StorePath, "machines", d.MachineName, "id_rsa")
}
// DriverName - This must be implemented in every driver
// DriverName returns the name of the driver
func (d *BaseDriver) DriverName() string {
return "unknown"
}
// GetMachineName -
// GetIP returns the ip
func (d *BaseDriver) GetMachineName() string {
return d.MachineName
}
@ -35,7 +35,7 @@ func (d *BaseDriver) ResolveStorePath(file string) string {
return filepath.Join(d.StorePath, "machines", d.MachineName, file)
}
// GetSSHPort -
// GetSSHPort returns the ssh port, 22 if not specified
func (d *BaseDriver) GetSSHPort() (int, error) {
if d.SSHPort == 0 {
d.SSHPort = 22
@ -44,7 +44,7 @@ func (d *BaseDriver) GetSSHPort() (int, error) {
return d.SSHPort, nil
}
// GetSSHUsername -
// GetSSHUsername returns the ssh user name, root if not specified
func (d *BaseDriver) GetSSHUsername() string {
if d.SSHUser == "" {
d.SSHUser = "root"

View File

@ -18,6 +18,10 @@ type Driver interface {
// DriverName returns the name of the driver as it is registered
DriverName() string
// GetCreateFlags returns the mcnflag.Flag slice representing the flags
// that can be set, their descriptions and defaults.
GetCreateFlags() []mcnflag.Flag
// GetIP returns an IP or hostname that this host is available at
// e.g. 1.2.3.4 or docker-host-d60b70a14d3a.cloudapp.net
GetIP() (string, error)
@ -57,10 +61,6 @@ type Driver interface {
// have any special restart behaviour.
Restart() error
// GetCreateFlags returns the mcnflag.Flag slice representing the flags
// that can be set, their descriptions and defaults.
GetCreateFlags() []mcnflag.Flag
// SetConfigFromFlags configures the driver with the object that was returned
// by RegisterCreateFlags
SetConfigFromFlags(opts DriverOptions) error

View File

@ -10,7 +10,7 @@ import (
)
func GetSSHClientFromDriver(d Driver) (ssh.Client, error) {
addr, err := d.GetSSHHostname()
address, err := d.GetSSHHostname()
if err != nil {
return nil, err
}
@ -24,7 +24,7 @@ func GetSSHClientFromDriver(d Driver) (ssh.Client, error) {
Keys: []string{d.GetSSHKeyPath()},
}
client, err := ssh.NewClient(d.GetSSHUsername(), addr, port, auth)
client, err := ssh.NewClient(d.GetSSHUsername(), address, port, auth)
return client, err
}
@ -40,12 +40,11 @@ func RunSSHCommandFromDriver(d Driver, command string) (string, error) {
output, err := client.Output(command)
log.Debugf("SSH cmd err, output: %v: %s", err, output)
if err != nil {
returnedErr := fmt.Errorf(`Something went wrong running an SSH command!
return "", fmt.Errorf(`Something went wrong running an SSH command!
command : %s
err : %v
output : %s
`, command, err, output)
return "", returnedErr
}
return output, nil