Merge pull request #2241 from dgageot/linting

Another pass at linting
This commit is contained in:
David Gageot 2015-11-10 17:43:58 +01:00
commit ae027c355d
34 changed files with 324 additions and 311 deletions

View File

@ -60,7 +60,7 @@ func (c *contextCommandLine) Application() *cli.App {
}
func newPluginDriver(driverName string, rawContent []byte) (drivers.Driver, error) {
d, err := rpcdriver.NewRpcClientDriver(rawContent, driverName)
d, err := rpcdriver.NewRPCClientDriver(rawContent, driverName)
if err != nil {
// Not being able to find a driver binary is a "known error"
if _, ok := err.(localbinary.ErrPluginBinaryNotFound); ok {

View File

@ -296,7 +296,7 @@ func cmdCreateOuter(c CommandLine) error {
}
if _, ok := driver.(*errdriver.Driver); ok {
return errdriver.ErrDriverNotLoadable{driverName}
return errdriver.NotLoadable{driverName}
}
// TODO: So much flag manipulation and voodoo here, it seems to be
@ -324,7 +324,7 @@ func cmdCreateOuter(c CommandLine) error {
driver = serialDriver.Driver
}
if rpcd, ok := driver.(*rpcdriver.RpcClientDriver); ok {
if rpcd, ok := driver.(*rpcdriver.RPCClientDriver); ok {
if err := rpcd.Close(); err != nil {
return err
}
@ -340,7 +340,7 @@ func getDriverOpts(c CommandLine, mcnflags []mcnflag.Flag) drivers.DriverOptions
// But, we need it so that we can actually send the flags for creating
// a machine over the wire (cli.Context is a no go since there is so
// much stuff in it).
driverOpts := rpcdriver.RpcFlags{
driverOpts := rpcdriver.RPCFlags{
Values: make(map[string]interface{}),
}

View File

@ -267,6 +267,7 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
return nil
}
// DriverName returns the name of the driver
func (d *Driver) DriverName() string {
return driverName
}

View File

@ -12,7 +12,7 @@ import (
)
const (
testSshPort = 22
testSSHPort = 22
testDockerPort = 2376
testStoreDir = ".store-test"
machineTestName = "test-host"
@ -133,8 +133,8 @@ func TestConfigureSecurityGroupPermissionsSshOnly(t *testing.T) {
group.IpPermissions = []amz.IpPermission{
{
IpProtocol: "tcp",
FromPort: testSshPort,
ToPort: testSshPort,
FromPort: testSSHPort,
ToPort: testSSHPort,
},
}
@ -172,8 +172,8 @@ func TestConfigureSecurityGroupPermissionsDockerOnly(t *testing.T) {
}
receivedPort := perms[0].FromPort
if receivedPort != testSshPort {
t.Fatalf("expected permission on port %d; received port %d", testSshPort, receivedPort)
if receivedPort != testSSHPort {
t.Fatalf("expected permission on port %d; received port %d", testSSHPort, receivedPort)
}
}
@ -189,8 +189,8 @@ func TestConfigureSecurityGroupPermissionsDockerAndSsh(t *testing.T) {
group.IpPermissions = []amz.IpPermission{
{
IpProtocol: "tcp",
FromPort: testSshPort,
ToPort: testSshPort,
FromPort: testSSHPort,
ToPort: testSSHPort,
},
{
IpProtocol: "tcp",

View File

@ -131,6 +131,7 @@ func (d *Driver) GetSSHUsername() string {
return d.SSHUser
}
// DriverName returns the name of the driver
func (d *Driver) DriverName() string {
return "azure"
}
@ -406,13 +407,13 @@ func (d *Driver) addDockerEndpoints(vmConfig *vmClient.Role) error {
LocalPort: d.DockerPort,
}
if d.SwarmMaster {
swarm_ep := vmClient.InputEndpoint{
swarmEp := vmClient.InputEndpoint{
Name: "docker swarm",
Protocol: "tcp",
Port: d.DockerSwarmMasterPort,
LocalPort: d.DockerSwarmMasterPort,
}
configSets[i].InputEndpoints.InputEndpoint = append(configSets[i].InputEndpoints.InputEndpoint, swarm_ep)
configSets[i].InputEndpoints.InputEndpoint = append(configSets[i].InputEndpoints.InputEndpoint, swarmEp)
log.Debugf("added Docker swarm master endpoint (port %d) to configuration", d.DockerSwarmMasterPort)
}
configSets[i].InputEndpoints.InputEndpoint = append(configSets[i].InputEndpoints.InputEndpoint, ep)

View File

@ -101,6 +101,7 @@ func (d *Driver) GetSSHHostname() (string, error) {
return d.GetIP()
}
// DriverName returns the name of the driver
func (d *Driver) DriverName() string {
return "digitalocean"
}

View File

@ -12,11 +12,11 @@ type Driver struct {
Name string
}
type ErrDriverNotLoadable struct {
type NotLoadable struct {
Name string
}
func (e ErrDriverNotLoadable) Error() string {
func (e NotLoadable) Error() string {
return fmt.Sprintf("Driver %q not found. Do you have the plugin binary accessible in your PATH?", e.Name)
}
@ -26,6 +26,7 @@ func NewDriver(Name string) drivers.Driver {
}
}
// DriverName returns the name of the driver
func (d *Driver) DriverName() string {
return "not-found"
}
@ -39,11 +40,11 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
}
func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
return ErrDriverNotLoadable{d.Name}
return NotLoadable{d.Name}
}
func (d *Driver) GetURL() (string, error) {
return "", ErrDriverNotLoadable{d.Name}
return "", NotLoadable{d.Name}
}
func (d *Driver) GetMachineName() string {
@ -51,11 +52,11 @@ func (d *Driver) GetMachineName() string {
}
func (d *Driver) GetIP() (string, error) {
return "1.2.3.4", ErrDriverNotLoadable{d.Name}
return "1.2.3.4", NotLoadable{d.Name}
}
func (d *Driver) GetSSHHostname() (string, error) {
return "", ErrDriverNotLoadable{d.Name}
return "", NotLoadable{d.Name}
}
func (d *Driver) GetSSHKeyPath() string {
@ -63,7 +64,7 @@ func (d *Driver) GetSSHKeyPath() string {
}
func (d *Driver) GetSSHPort() (int, error) {
return 0, ErrDriverNotLoadable{d.Name}
return 0, NotLoadable{d.Name}
}
func (d *Driver) GetSSHUsername() string {
@ -71,33 +72,33 @@ func (d *Driver) GetSSHUsername() string {
}
func (d *Driver) GetState() (state.State, error) {
return state.Error, ErrDriverNotLoadable{d.Name}
return state.Error, NotLoadable{d.Name}
}
func (d *Driver) Create() error {
return ErrDriverNotLoadable{d.Name}
return NotLoadable{d.Name}
}
func (d *Driver) Remove() error {
return ErrDriverNotLoadable{d.Name}
return NotLoadable{d.Name}
}
func (d *Driver) Start() error {
return ErrDriverNotLoadable{d.Name}
return NotLoadable{d.Name}
}
func (d *Driver) Stop() error {
return ErrDriverNotLoadable{d.Name}
return NotLoadable{d.Name}
}
func (d *Driver) Restart() error {
return ErrDriverNotLoadable{d.Name}
return NotLoadable{d.Name}
}
func (d *Driver) Kill() error {
return ErrDriverNotLoadable{d.Name}
return NotLoadable{d.Name}
}
func (d *Driver) Upgrade() error {
return ErrDriverNotLoadable{d.Name}
return NotLoadable{d.Name}
}

View File

@ -19,8 +19,8 @@ import (
type Driver struct {
*drivers.BaseDriver
URL string
ApiKey string
ApiSecretKey string
APIKey string `json:"ApiKey"`
APISecretKey string `json:"ApiSecretKey"`
InstanceProfile string
DiskSize int
Image string
@ -28,7 +28,7 @@ type Driver struct {
AvailabilityZone string
KeyPair string
PublicKey string
Id string
ID string `json:"Id"`
}
const (
@ -38,7 +38,7 @@ const (
defaultAvailabilityZone = "ch-gva-2"
)
// RegisterCreateFlags registers the flags this driver adds to
// GetCreateFlags registers the flags this driver adds to
// "docker hosts create"
func (d *Driver) GetCreateFlags() []mcnflag.Flag {
return []mcnflag.Flag{
@ -111,14 +111,15 @@ func (d *Driver) GetSSHUsername() string {
return "ubuntu"
}
// DriverName returns the name of the driver
func (d *Driver) DriverName() string {
return "exoscale"
}
func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
d.URL = flags.String("exoscale-endpoint")
d.ApiKey = flags.String("exoscale-api-key")
d.ApiSecretKey = flags.String("exoscale-api-secret-key")
d.APIKey = flags.String("exoscale-api-key")
d.APISecretKey = flags.String("exoscale-api-secret-key")
d.InstanceProfile = flags.String("exoscale-instance-profile")
d.DiskSize = flags.Int("exoscale-disk-size")
d.Image = flags.String("exoscale-image")
@ -135,7 +136,7 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
if d.URL == "" {
d.URL = "https://api.exoscale.ch/compute"
}
if d.ApiKey == "" || d.ApiSecretKey == "" {
if d.APIKey == "" || d.APISecretKey == "" {
return fmt.Errorf("Please specify an API key (--exoscale-api-key) and an API secret key (--exoscale-api-secret-key).")
}
@ -151,8 +152,8 @@ func (d *Driver) GetURL() (string, error) {
}
func (d *Driver) GetState() (state.State, error) {
client := egoscale.NewClient(d.URL, d.ApiKey, d.ApiSecretKey)
vm, err := client.GetVirtualMachine(d.Id)
client := egoscale.NewClient(d.URL, d.APIKey, d.APISecretKey)
vm, err := client.GetVirtualMachine(d.ID)
if err != nil {
return state.Error, err
}
@ -222,7 +223,7 @@ func (d *Driver) createDefaultSecurityGroup(client *egoscale.Client, group strin
func (d *Driver) Create() error {
log.Infof("Querying exoscale for the requested parameters...")
client := egoscale.NewClient(d.URL, d.ApiKey, d.ApiSecretKey)
client := egoscale.NewClient(d.URL, d.APIKey, d.APISecretKey)
topology, err := client.GetTopology()
if err != nil {
return err
@ -314,7 +315,7 @@ func (d *Driver) Create() error {
return err
}
d.IPAddress = vm.Nic[0].Ipaddress
d.Id = vm.Id
d.ID = vm.Id
return nil
}
@ -329,8 +330,8 @@ func (d *Driver) Start() error {
return nil
}
client := egoscale.NewClient(d.URL, d.ApiKey, d.ApiSecretKey)
svmresp, err := client.StartVirtualMachine(d.Id)
client := egoscale.NewClient(d.URL, d.APIKey, d.APISecretKey)
svmresp, err := client.StartVirtualMachine(d.ID)
if err != nil {
return err
}
@ -350,8 +351,8 @@ func (d *Driver) Stop() error {
return nil
}
client := egoscale.NewClient(d.URL, d.ApiKey, d.ApiSecretKey)
svmresp, err := client.StopVirtualMachine(d.Id)
client := egoscale.NewClient(d.URL, d.APIKey, d.APISecretKey)
svmresp, err := client.StopVirtualMachine(d.ID)
if err != nil {
return err
}
@ -362,7 +363,7 @@ func (d *Driver) Stop() error {
}
func (d *Driver) Remove() error {
client := egoscale.NewClient(d.URL, d.ApiKey, d.ApiSecretKey)
client := egoscale.NewClient(d.URL, d.APIKey, d.APISecretKey)
// Destroy the SSH key
if _, err := client.DeleteKeypair(d.KeyPair); err != nil {
@ -370,7 +371,7 @@ func (d *Driver) Remove() error {
}
// Destroy the virtual machine
dvmresp, err := client.DestroyVirtualMachine(d.Id)
dvmresp, err := client.DestroyVirtualMachine(d.ID)
if err != nil {
return err
}
@ -389,8 +390,8 @@ func (d *Driver) Restart() error {
return fmt.Errorf("Host is stopped, use start command to start it")
}
client := egoscale.NewClient(d.URL, d.ApiKey, d.ApiSecretKey)
svmresp, err := client.RebootVirtualMachine(d.Id)
client := egoscale.NewClient(d.URL, d.APIKey, d.APISecretKey)
svmresp, err := client.RebootVirtualMachine(d.ID)
if err != nil {
return err
}

View File

@ -17,6 +17,7 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
return []mcnflag.Flag{}
}
// DriverName returns the name of the driver
func (d *Driver) DriverName() string {
return "Driver"
}

View File

@ -66,6 +66,7 @@ func NewDriver(hostName, storePath string) drivers.Driver {
}
}
// DriverName returns the name of the driver
func (d *Driver) DriverName() string {
return "generic"
}

View File

@ -142,7 +142,7 @@ func (d *Driver) GetSSHUsername() string {
return d.SSHUser
}
// DriverName returns the name of the driver.
// DriverName returns the name of the driver
func (d *Driver) DriverName() string {
return "google"
}

View File

@ -97,6 +97,7 @@ func (d *Driver) GetSSHUsername() string {
return d.SSHUser
}
// DriverName returns the name of the driver
func (d *Driver) DriverName() string {
return "hyperv"
}

View File

@ -42,6 +42,7 @@ func (d *Driver) Create() error {
return nil
}
// DriverName returns the name of the driver
func (d *Driver) DriverName() string {
return driverName
}

View File

@ -35,16 +35,16 @@ type Client interface {
RestartInstance(d *Driver) error
DeleteInstance(d *Driver) error
WaitForInstanceStatus(d *Driver, status string) error
GetInstanceIpAddresses(d *Driver) ([]IpAddress, error)
GetInstanceIPAddresses(d *Driver) ([]IPAddress, error)
CreateKeyPair(d *Driver, name string, publicKey string) error
DeleteKeyPair(d *Driver, name string) error
GetNetworkId(d *Driver) (string, error)
GetFlavorId(d *Driver) (string, error)
GetImageId(d *Driver) (string, error)
AssignFloatingIP(d *Driver, floatingIp *FloatingIp) error
GetFloatingIPs(d *Driver) ([]FloatingIp, error)
GetFloatingIpPoolId(d *Driver) (string, error)
GetInstancePortId(d *Driver) (string, error)
GetNetworkID(d *Driver) (string, error)
GetFlavorID(d *Driver) (string, error)
GetImageID(d *Driver) (string, error)
AssignFloatingIP(d *Driver, floatingIP *FloatingIP) error
GetFloatingIPs(d *Driver) ([]FloatingIP, error)
GetFloatingIPPoolID(d *Driver) (string, error)
GetInstancePortID(d *Driver) (string, error)
}
type GenericClient struct {
@ -86,7 +86,7 @@ const (
Fixed string = "fixed"
)
type IpAddress struct {
type IPAddress struct {
Network string
AddressType string
Address string
@ -94,7 +94,7 @@ type IpAddress struct {
Mac string
}
type FloatingIp struct {
type FloatingIP struct {
Id string
Ip string
NetworkId string
@ -158,12 +158,12 @@ func (c *GenericClient) WaitForInstanceStatus(d *Driver, status string) error {
}, (d.ActiveTimeout / 4), 4*time.Second)
}
func (c *GenericClient) GetInstanceIpAddresses(d *Driver) ([]IpAddress, error) {
func (c *GenericClient) GetInstanceIPAddresses(d *Driver) ([]IPAddress, error) {
server, err := c.GetServerDetail(d)
if err != nil {
return nil, err
}
addresses := []IpAddress{}
addresses := []IPAddress{}
for network, networkAddresses := range server.Addresses {
for _, element := range networkAddresses.([]interface{}) {
address := element.(map[string]interface{})
@ -173,7 +173,7 @@ func (c *GenericClient) GetInstanceIpAddresses(d *Driver) ([]IpAddress, error) {
version = 4
}
addr := IpAddress{
addr := IPAddress{
Network: network,
AddressType: Fixed,
Address: address["addr"].(string),
@ -194,18 +194,18 @@ func (c *GenericClient) GetInstanceIpAddresses(d *Driver) ([]IpAddress, error) {
return addresses, nil
}
func (c *GenericClient) GetNetworkId(d *Driver) (string, error) {
return c.getNetworkId(d, d.NetworkName)
func (c *GenericClient) GetNetworkID(d *Driver) (string, error) {
return c.getNetworkID(d, d.NetworkName)
}
func (c *GenericClient) GetFloatingIpPoolId(d *Driver) (string, error) {
return c.getNetworkId(d, d.FloatingIpPool)
func (c *GenericClient) GetFloatingIPPoolID(d *Driver) (string, error) {
return c.getNetworkID(d, d.FloatingIpPool)
}
func (c *GenericClient) getNetworkId(d *Driver, networkName string) (string, error) {
func (c *GenericClient) getNetworkID(d *Driver, networkName string) (string, error) {
opts := networks.ListOpts{Name: networkName}
pager := networks.List(c.Network, opts)
networkId := ""
networkID := ""
err := pager.EachPage(func(page pagination.Page) (bool, error) {
networkList, err := networks.ExtractNetworks(page)
@ -215,7 +215,7 @@ func (c *GenericClient) getNetworkId(d *Driver, networkName string) (string, err
for _, n := range networkList {
if n.Name == networkName {
networkId = n.ID
networkID = n.ID
return false, nil
}
}
@ -223,12 +223,12 @@ func (c *GenericClient) getNetworkId(d *Driver, networkName string) (string, err
return true, nil
})
return networkId, err
return networkID, err
}
func (c *GenericClient) GetFlavorId(d *Driver) (string, error) {
func (c *GenericClient) GetFlavorID(d *Driver) (string, error) {
pager := flavors.ListDetail(c.Compute, nil)
flavorId := ""
flavorID := ""
err := pager.EachPage(func(page pagination.Page) (bool, error) {
flavorList, err := flavors.ExtractFlavors(page)
@ -238,7 +238,7 @@ func (c *GenericClient) GetFlavorId(d *Driver) (string, error) {
for _, f := range flavorList {
if f.Name == d.FlavorName {
flavorId = f.ID
flavorID = f.ID
return false, nil
}
}
@ -246,13 +246,13 @@ func (c *GenericClient) GetFlavorId(d *Driver) (string, error) {
return true, nil
})
return flavorId, err
return flavorID, err
}
func (c *GenericClient) GetImageId(d *Driver) (string, error) {
func (c *GenericClient) GetImageID(d *Driver) (string, error) {
opts := images.ListOpts{Name: d.ImageName}
pager := images.ListDetail(c.Compute, opts)
imageId := ""
imageID := ""
err := pager.EachPage(func(page pagination.Page) (bool, error) {
imageList, err := images.ExtractImages(page)
@ -262,7 +262,7 @@ func (c *GenericClient) GetImageId(d *Driver) (string, error) {
for _, i := range imageList {
if i.Name == d.ImageName {
imageId = i.ID
imageID = i.ID
return false, nil
}
}
@ -270,7 +270,7 @@ func (c *GenericClient) GetImageId(d *Driver) (string, error) {
return true, nil
})
return imageId, err
return imageID, err
}
func (c *GenericClient) CreateKeyPair(d *Driver, name string, publicKey string) error {
@ -299,49 +299,48 @@ func (c *GenericClient) GetServerDetail(d *Driver) (*servers.Server, error) {
return server, nil
}
func (c *GenericClient) AssignFloatingIP(d *Driver, floatingIp *FloatingIp) error {
func (c *GenericClient) AssignFloatingIP(d *Driver, floatingIP *FloatingIP) error {
if d.ComputeNetwork {
return c.assignNovaFloatingIP(d, floatingIp)
} else {
return c.assignNeutronFloatingIP(d, floatingIp)
return c.assignNovaFloatingIP(d, floatingIP)
}
return c.assignNeutronFloatingIP(d, floatingIP)
}
func (c *GenericClient) assignNovaFloatingIP(d *Driver, floatingIp *FloatingIp) error {
if floatingIp.Ip == "" {
func (c *GenericClient) assignNovaFloatingIP(d *Driver, floatingIP *FloatingIP) error {
if floatingIP.Ip == "" {
f, err := compute_ips.Create(c.Compute, compute_ips.CreateOpts{
Pool: d.FloatingIpPool,
}).Extract()
if err != nil {
return err
}
floatingIp.Ip = f.IP
floatingIp.Pool = f.Pool
floatingIP.Ip = f.IP
floatingIP.Pool = f.Pool
}
return compute_ips.Associate(c.Compute, d.MachineId, floatingIp.Ip).Err
return compute_ips.Associate(c.Compute, d.MachineId, floatingIP.Ip).Err
}
func (c *GenericClient) assignNeutronFloatingIP(d *Driver, floatingIp *FloatingIp) error {
portId, err := c.GetInstancePortId(d)
func (c *GenericClient) assignNeutronFloatingIP(d *Driver, floatingIP *FloatingIP) error {
portID, err := c.GetInstancePortID(d)
if err != nil {
return err
}
if floatingIp.Id == "" {
if floatingIP.Id == "" {
f, err := floatingips.Create(c.Network, floatingips.CreateOpts{
FloatingNetworkID: d.FloatingIpPoolId,
PortID: portId,
PortID: portID,
}).Extract()
if err != nil {
return err
}
floatingIp.Id = f.ID
floatingIp.Ip = f.FloatingIP
floatingIp.NetworkId = f.FloatingNetworkID
floatingIp.PortId = f.PortID
floatingIP.Id = f.ID
floatingIP.Ip = f.FloatingIP
floatingIP.NetworkId = f.FloatingNetworkID
floatingIP.PortId = f.PortID
return nil
}
_, err = floatingips.Update(c.Network, floatingIp.Id, floatingips.UpdateOpts{
PortID: portId,
_, err = floatingips.Update(c.Network, floatingIP.Id, floatingips.UpdateOpts{
PortID: portID,
}).Extract()
if err != nil {
return err
@ -349,25 +348,24 @@ func (c *GenericClient) assignNeutronFloatingIP(d *Driver, floatingIp *FloatingI
return nil
}
func (c *GenericClient) GetFloatingIPs(d *Driver) ([]FloatingIp, error) {
func (c *GenericClient) GetFloatingIPs(d *Driver) ([]FloatingIP, error) {
if d.ComputeNetwork {
return c.getNovaNetworkFloatingIPs(d)
} else {
return c.getNeutronNetworkFloatingIPs(d)
}
return c.getNeutronNetworkFloatingIPs(d)
}
func (c *GenericClient) getNovaNetworkFloatingIPs(d *Driver) ([]FloatingIp, error) {
func (c *GenericClient) getNovaNetworkFloatingIPs(d *Driver) ([]FloatingIP, error) {
pager := compute_ips.List(c.Compute)
ips := []FloatingIp{}
ips := []FloatingIP{}
err := pager.EachPage(func(page pagination.Page) (continue_paging bool, err error) {
continue_paging, err = true, nil
ip_listing, err := compute_ips.ExtractFloatingIPs(page)
ipListing, err := compute_ips.ExtractFloatingIPs(page)
for _, ip := range ip_listing {
for _, ip := range ipListing {
if ip.InstanceID == "" && ip.Pool == d.FloatingIpPool {
ips = append(ips, FloatingIp{
ips = append(ips, FloatingIP{
Id: ip.ID,
Ip: ip.IP,
Pool: ip.Pool,
@ -379,19 +377,19 @@ func (c *GenericClient) getNovaNetworkFloatingIPs(d *Driver) ([]FloatingIp, erro
return ips, err
}
func (c *GenericClient) getNeutronNetworkFloatingIPs(d *Driver) ([]FloatingIp, error) {
func (c *GenericClient) getNeutronNetworkFloatingIPs(d *Driver) ([]FloatingIP, error) {
pager := floatingips.List(c.Network, floatingips.ListOpts{
FloatingNetworkID: d.FloatingIpPoolId,
})
ips := []FloatingIp{}
ips := []FloatingIP{}
err := pager.EachPage(func(page pagination.Page) (bool, error) {
floatingipList, err := floatingips.ExtractFloatingIPs(page)
if err != nil {
return false, err
}
for _, f := range floatingipList {
ips = append(ips, FloatingIp{
ips = append(ips, FloatingIP{
Id: f.ID,
Ip: f.FloatingIP,
NetworkId: f.FloatingNetworkID,
@ -407,20 +405,20 @@ func (c *GenericClient) getNeutronNetworkFloatingIPs(d *Driver) ([]FloatingIp, e
return ips, nil
}
func (c *GenericClient) GetInstancePortId(d *Driver) (string, error) {
func (c *GenericClient) GetInstancePortID(d *Driver) (string, error) {
pager := ports.List(c.Network, ports.ListOpts{
DeviceID: d.MachineId,
NetworkID: d.NetworkId,
})
var portId string
var portID string
err := pager.EachPage(func(page pagination.Page) (bool, error) {
portList, err := ports.ExtractPorts(page)
if err != nil {
return false, err
}
for _, port := range portList {
portId = port.ID
portID = port.ID
return false, nil
}
return true, nil
@ -429,7 +427,7 @@ func (c *GenericClient) GetInstancePortId(d *Driver) (string, error) {
if err != nil {
return "", err
}
return portId, nil
return portID, nil
}
func (c *GenericClient) InitComputeClient(d *Driver) error {

View File

@ -222,6 +222,7 @@ func (d *Driver) SetClient(client Client) {
d.client = client
}
// DriverName returns the name of the driver
func (d *Driver) DriverName() string {
return "openstack"
}
@ -289,7 +290,7 @@ func (d *Driver) GetIP() (string, error) {
// Looking for the IP address in a retry loop to deal with OpenStack latency
for retryCount := 0; retryCount < 200; retryCount++ {
addresses, err := d.client.GetInstanceIpAddresses(d)
addresses, err := d.client.GetInstanceIPAddresses(d)
if err != nil {
return "", err
}
@ -352,11 +353,11 @@ func (d *Driver) Create() error {
return err
}
if d.FloatingIpPool != "" {
if err := d.assignFloatingIp(); err != nil {
if err := d.assignFloatingIP(); err != nil {
return err
}
}
if err := d.lookForIpAddress(); err != nil {
if err := d.lookForIPAddress(); err != nil {
return err
}
return nil
@ -420,7 +421,7 @@ const (
errorMandatoryEnvOrOption string = "%s must be specified either using the environment variable %s or the CLI option %s"
errorMandatoryOption string = "%s must be specified using the CLI option %s"
errorExclusiveOptions string = "Either %s or %s must be specified, not both"
errorMandatoryTenantNameOrId string = "Tenant id or name must be provided either using one of the environment variables OS_TENANT_ID and OS_TENANT_NAME or one of the CLI options --openstack-tenant-id and --openstack-tenant-name"
errorMandatoryTenantNameOrID string = "Tenant id or name must be provided either using one of the environment variables OS_TENANT_ID and OS_TENANT_NAME or one of the CLI options --openstack-tenant-id and --openstack-tenant-name"
errorWrongEndpointType string = "Endpoint type must be 'publicURL', 'adminURL' or 'internalURL'"
errorUnknownFlavorName string = "Unable to find flavor named %s"
errorUnknownImageName string = "Unable to find image named %s"
@ -438,7 +439,7 @@ func (d *Driver) checkConfig() error {
return fmt.Errorf(errorMandatoryEnvOrOption, "Password", "OS_PASSWORD", "--openstack-password")
}
if d.TenantName == "" && d.TenantId == "" {
return fmt.Errorf(errorMandatoryTenantNameOrId)
return fmt.Errorf(errorMandatoryTenantNameOrID)
}
if d.FlavorName == "" && d.FlavorId == "" {
@ -470,17 +471,17 @@ func (d *Driver) resolveIds() error {
return err
}
networkId, err := d.client.GetNetworkId(d)
networkID, err := d.client.GetNetworkID(d)
if err != nil {
return err
}
if networkId == "" {
if networkID == "" {
return fmt.Errorf(errorUnknownNetworkName, d.NetworkName)
}
d.NetworkId = networkId
d.NetworkId = networkID
log.WithFields(log.Fields{
"Name": d.NetworkName,
"ID": d.NetworkId,
@ -491,17 +492,17 @@ func (d *Driver) resolveIds() error {
if err := d.initCompute(); err != nil {
return err
}
flavorId, err := d.client.GetFlavorId(d)
flavorID, err := d.client.GetFlavorID(d)
if err != nil {
return err
}
if flavorId == "" {
if flavorID == "" {
return fmt.Errorf(errorUnknownFlavorName, d.FlavorName)
}
d.FlavorId = flavorId
d.FlavorId = flavorID
log.WithFields(log.Fields{
"Name": d.FlavorName,
"ID": d.FlavorId,
@ -512,17 +513,17 @@ func (d *Driver) resolveIds() error {
if err := d.initCompute(); err != nil {
return err
}
imageId, err := d.client.GetImageId(d)
imageID, err := d.client.GetImageID(d)
if err != nil {
return err
}
if imageId == "" {
if imageID == "" {
return fmt.Errorf(errorUnknownImageName, d.ImageName)
}
d.ImageId = imageId
d.ImageId = imageID
log.WithFields(log.Fields{
"Name": d.ImageName,
"ID": d.ImageId,
@ -533,7 +534,7 @@ func (d *Driver) resolveIds() error {
if err := d.initNetwork(); err != nil {
return err
}
f, err := d.client.GetFloatingIpPoolId(d)
f, err := d.client.GetFloatingIPPoolID(d)
if err != nil {
return err
@ -601,15 +602,15 @@ func (d *Driver) createMachine() error {
if err := d.initCompute(); err != nil {
return err
}
instanceId, err := d.client.CreateInstance(d)
instanceID, err := d.client.CreateInstance(d)
if err != nil {
return err
}
d.MachineId = instanceId
d.MachineId = instanceID
return nil
}
func (d *Driver) assignFloatingIp() error {
func (d *Driver) assignFloatingIP() error {
var err error
if d.ComputeNetwork {
@ -627,7 +628,7 @@ func (d *Driver) assignFloatingIp() error {
return err
}
var floatingIp *FloatingIp
var floatingIP *FloatingIP
log.WithFields(log.Fields{
"MachineId": d.MachineId,
@ -640,22 +641,22 @@ func (d *Driver) assignFloatingIp() error {
"MachineId": d.MachineId,
"IP": ip.Ip,
}).Debugf("Available floating IP found")
floatingIp = &ip
floatingIP = &ip
break
}
}
if floatingIp == nil {
floatingIp = &FloatingIp{}
if floatingIP == nil {
floatingIP = &FloatingIP{}
log.WithField("MachineId", d.MachineId).Debugf("No available floating IP found. Allocating a new one...")
} else {
log.WithField("MachineId", d.MachineId).Debugf("Assigning floating IP to the instance")
}
if err := d.client.AssignFloatingIP(d, floatingIp); err != nil {
if err := d.client.AssignFloatingIP(d, floatingIP); err != nil {
return err
}
d.IPAddress = floatingIp.Ip
d.IPAddress = floatingIP.Ip
return nil
}
@ -667,7 +668,7 @@ func (d *Driver) waitForInstanceActive() error {
return nil
}
func (d *Driver) lookForIpAddress() error {
func (d *Driver) lookForIPAddress() error {
ip, err := d.GetIP()
if err != nil {
return err

View File

@ -63,13 +63,13 @@ func (c *Client) StopInstance(d *openstack.Driver) error {
return unsupportedOpErr("stop")
}
// GetInstanceIpAddresses can be short-circuited with the server's AccessIPv4Addr on Rackspace.
func (c *Client) GetInstanceIpAddresses(d *openstack.Driver) ([]openstack.IpAddress, error) {
// GetInstanceIPAddresses can be short-circuited with the server's AccessIPv4Addr on Rackspace.
func (c *Client) GetInstanceIPAddresses(d *openstack.Driver) ([]openstack.IPAddress, error) {
server, err := c.GetServerDetail(d)
if err != nil {
return nil, err
}
return []openstack.IpAddress{
return []openstack.IPAddress{
{
Network: "public",
Address: server.AccessIPv4,

View File

@ -18,7 +18,7 @@ type Driver struct {
const (
defaultEndpointType = "publicURL"
defaultFlavorId = "general1-1"
defaultFlavorID = "general1-1"
defaultSSHUser = "root"
defaultSSHPort = 22
defaultDockerInstall = "true"
@ -59,7 +59,7 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
mcnflag.StringFlag{
Name: "rackspace-flavor-id",
Usage: "Rackspace flavor ID. Default: General Purpose 1GB",
Value: defaultFlavorId,
Value: defaultFlavorID,
EnvVar: "OS_FLAVOR_ID",
},
mcnflag.StringFlag{
@ -97,7 +97,7 @@ func NewDriver(machineName, storePath string) drivers.Driver {
return driver
}
// DriverName is the user-visible name of this driver.
// DriverName returns the name of the driver
func (d *Driver) DriverName() string {
return "rackspace"
}

View File

@ -15,7 +15,7 @@ import (
)
const (
ApiEndpoint = "https://api.softlayer.com/rest/v3"
APIEndpoint = "https://api.softlayer.com/rest/v3"
)
type Driver struct {
@ -54,7 +54,7 @@ const (
func NewDriver(hostName, storePath string) drivers.Driver {
return &Driver{
Client: &Client{
Endpoint: ApiEndpoint,
Endpoint: APIEndpoint,
},
deviceConfig: &deviceConfig{
HourlyBilling: true,
@ -131,7 +131,7 @@ func (d *Driver) GetCreateFlags() []mcnflag.Flag {
EnvVar: "SOFTLAYER_API_ENDPOINT",
Name: "softlayer-api-endpoint",
Usage: "softlayer api endpoint to use",
Value: ApiEndpoint,
Value: APIEndpoint,
},
mcnflag.BoolFlag{
EnvVar: "SOFTLAYER_HOURLY_BILLING",
@ -252,6 +252,7 @@ func (d *Driver) getClient() *Client {
return d.Client
}
// DriverName returns the name of the driver
func (d *Driver) DriverName() string {
return "softlayer"
}
@ -272,10 +273,9 @@ func (d *Driver) GetIP() (string, error) {
return d.IPAddress, nil
}
if d.deviceConfig != nil && d.deviceConfig.PrivateNet == true {
return d.getClient().VirtualGuest().GetPrivateIp(d.Id)
} else {
return d.getClient().VirtualGuest().GetPublicIp(d.Id)
return d.getClient().VirtualGuest().GetPrivateIP(d.Id)
}
return d.getClient().VirtualGuest().GetPublicIP(d.Id)
}
func (d *Driver) GetState() (state.State, error) {
@ -321,7 +321,7 @@ func (d *Driver) waitForStart() {
}
}
func (d *Driver) getIp() (string, error) {
func (d *Driver) getIP() (string, error) {
log.Infof("Getting Host IP")
for {
var (
@ -329,9 +329,9 @@ func (d *Driver) getIp() (string, error) {
err error
)
if d.deviceConfig.PrivateNet {
ip, err = d.getClient().VirtualGuest().GetPrivateIp(d.Id)
ip, err = d.getClient().VirtualGuest().GetPrivateIP(d.Id)
} else {
ip, err = d.getClient().VirtualGuest().GetPublicIp(d.Id)
ip, err = d.getClient().VirtualGuest().GetPublicIP(d.Id)
}
if err != nil {
time.Sleep(2 * time.Second)
@ -386,14 +386,14 @@ func (d *Driver) Create() error {
log.Infof("SSH key %s (%d) created in SoftLayer", key.Label, key.Id)
d.SSHKeyID = key.Id
spec.SshKeys = []*SshKey{key}
spec.SshKeys = []*SSHKey{key}
id, err := d.getClient().VirtualGuest().Create(spec)
if err != nil {
return fmt.Errorf("Error creating host: %q", err)
}
d.Id = id
d.getIp()
d.getIP()
d.waitForStart()
d.waitForSetupTransactions()
@ -433,7 +433,7 @@ func (d *Driver) buildHostSpec() *HostSpec {
return spec
}
func (d *Driver) createSSHKey() (*SshKey, error) {
func (d *Driver) createSSHKey() (*SSHKey, error) {
if err := ssh.GenerateSSHKey(d.GetSSHKeyPath()); err != nil {
return nil, err
}
@ -443,7 +443,7 @@ func (d *Driver) createSSHKey() (*SshKey, error) {
return nil, err
}
key, err := d.getClient().SshKey().Create(d.deviceConfig.Hostname, string(publicKey))
key, err := d.getClient().SSHKey().Create(d.deviceConfig.Hostname, string(publicKey))
if err != nil {
return nil, err
}
@ -474,7 +474,7 @@ func (d *Driver) Remove() error {
}
log.Infof("Removing SSH Key %d...", d.SSHKeyID)
if err = d.getClient().SshKey().Delete(d.SSHKeyID); err != nil {
if err = d.getClient().SSHKey().Delete(d.SSHKeyID); err != nil {
return err
}

View File

@ -21,7 +21,7 @@ type HostSpec struct {
Cpu int `json:"startCpus"`
Memory int `json:"maxMemory"`
Datacenter Datacenter `json:"datacenter"`
SshKeys []*SshKey `json:"sshKeys"`
SshKeys []*SSHKey `json:"sshKeys"`
BlockDevices []BlockDevice `json:"blockDevices"`
InstallScript string `json:"postInstallScriptUri"`
PrivateNetOnly bool `json:"privateNetworkOnlyFlag"`
@ -40,7 +40,7 @@ type NetworkVLAN struct {
Id int `json:"id"`
}
type SshKey struct {
type SSHKey struct {
Key string `json:"key,omitempty"`
Id int `json:"id,omitempty"`
Label string `json:"label,omitempty"`
@ -63,7 +63,7 @@ type sshKey struct {
*Client
}
type virtualGuest struct {
type VirtualGuest struct {
*Client
}
@ -95,11 +95,11 @@ func (c *Client) newRequest(method, uri string, body interface{}) ([]byte, error
)
if body != nil {
bodyJson, err := json.Marshal(body)
bodyJSON, err := json.Marshal(body)
if err != nil {
return nil, err
}
req, err = http.NewRequest(method, url, bytes.NewBuffer(bodyJson))
req, err = http.NewRequest(method, url, bytes.NewBuffer(bodyJSON))
} else {
req, err = http.NewRequest(method, url, nil)
}
@ -132,7 +132,7 @@ func (c *Client) newRequest(method, uri string, body interface{}) ([]byte, error
return data, nil
}
func (c *Client) SshKey() *sshKey {
func (c *Client) SSHKey() *sshKey {
return &sshKey{c}
}
@ -140,11 +140,11 @@ func (c *sshKey) namespace() string {
return "SoftLayer_Security_Ssh_Key"
}
func (c *sshKey) Create(label, key string) (*SshKey, error) {
func (c *sshKey) Create(label, key string) (*SSHKey, error) {
var (
method = "POST"
uri = c.namespace()
body = SshKey{Key: key, Label: label}
body = SSHKey{Key: key, Label: label}
)
data, err := c.newRequest(method, uri, map[string]interface{}{"parameters": []interface{}{body}})
@ -152,7 +152,7 @@ func (c *sshKey) Create(label, key string) (*SshKey, error) {
return nil, err
}
var k SshKey
var k SSHKey
if err := json.Unmarshal(data, &k); err != nil {
return nil, err
}
@ -173,15 +173,15 @@ func (c *sshKey) Delete(id int) error {
return nil
}
func (c *Client) VirtualGuest() *virtualGuest {
return &virtualGuest{c}
func (c *Client) VirtualGuest() *VirtualGuest {
return &VirtualGuest{c}
}
func (c *virtualGuest) namespace() string {
func (c *VirtualGuest) namespace() string {
return "SoftLayer_Virtual_Guest"
}
func (c *virtualGuest) PowerState(id int) (string, error) {
func (c *VirtualGuest) PowerState(id int) (string, error) {
type state struct {
KeyName string `json:"keyName"`
Name string `json:"name"`
@ -203,7 +203,7 @@ func (c *virtualGuest) PowerState(id int) (string, error) {
return s.Name, nil
}
func (c *virtualGuest) ActiveTransaction(id int) (string, error) {
func (c *VirtualGuest) ActiveTransaction(id int) (string, error) {
type transactionStatus struct {
AverageDuration string `json:"averageDuration"`
FriendlyName string `json:"friendlyName"`
@ -236,7 +236,7 @@ func (c *virtualGuest) ActiveTransaction(id int) (string, error) {
return t.TransactionStatus.Name, nil
}
func (c *virtualGuest) Create(spec *HostSpec) (int, error) {
func (c *VirtualGuest) Create(spec *HostSpec) (int, error) {
var (
method = "POST"
uri = c.namespace() + ".json"
@ -248,7 +248,7 @@ func (c *virtualGuest) Create(spec *HostSpec) (int, error) {
}
type createResp struct {
Id int `json:"id"`
ID int `json:"id"`
}
var r createResp
@ -256,10 +256,10 @@ func (c *virtualGuest) Create(spec *HostSpec) (int, error) {
return -1, err
}
return r.Id, nil
return r.ID, nil
}
func (c *virtualGuest) Cancel(id int) error {
func (c *VirtualGuest) Cancel(id int) error {
var (
method = "DELETE"
uri = fmt.Sprintf("%s/%v", c.namespace(), id)
@ -272,7 +272,7 @@ func (c *virtualGuest) Cancel(id int) error {
return nil
}
func (c *virtualGuest) PowerOn(id int) error {
func (c *VirtualGuest) PowerOn(id int) error {
var (
method = "GET"
uri = fmt.Sprintf("%s/%v/powerOn.json", c.namespace(), id)
@ -285,7 +285,7 @@ func (c *virtualGuest) PowerOn(id int) error {
return nil
}
func (c *virtualGuest) PowerOff(id int) error {
func (c *VirtualGuest) PowerOff(id int) error {
var (
method = "GET"
uri = fmt.Sprintf("%s/%v/powerOff.json", c.namespace(), id)
@ -298,7 +298,7 @@ func (c *virtualGuest) PowerOff(id int) error {
return nil
}
func (c *virtualGuest) Pause(id int) error {
func (c *VirtualGuest) Pause(id int) error {
var (
method = "GET"
uri = fmt.Sprintf("%s/%v/pause.json", c.namespace(), id)
@ -311,7 +311,7 @@ func (c *virtualGuest) Pause(id int) error {
return nil
}
func (c *virtualGuest) Resume(id int) error {
func (c *VirtualGuest) Resume(id int) error {
var (
method = "GET"
uri = fmt.Sprintf("%s/%v/resume.json", c.namespace(), id)
@ -324,7 +324,7 @@ func (c *virtualGuest) Resume(id int) error {
return nil
}
func (c *virtualGuest) Reboot(id int) error {
func (c *VirtualGuest) Reboot(id int) error {
var (
method = "GET"
uri = fmt.Sprintf("%s/%v/rebootSoft.json", c.namespace(), id)
@ -337,7 +337,7 @@ func (c *virtualGuest) Reboot(id int) error {
return nil
}
func (c *virtualGuest) GetPublicIp(id int) (string, error) {
func (c *VirtualGuest) GetPublicIP(id int) (string, error) {
var (
method = "GET"
uri = fmt.Sprintf("%s/%v/getPrimaryIpAddress.json", c.namespace(), id)
@ -350,7 +350,7 @@ func (c *virtualGuest) GetPublicIp(id int) (string, error) {
return strings.Replace(string(data), "\"", "", -1), nil
}
func (c *virtualGuest) GetPrivateIp(id int) (string, error) {
func (c *VirtualGuest) GetPrivateIP(id int) (string, error) {
var (
method = "GET"
uri = fmt.Sprintf("%s/%v/getPrimaryBackendIpAddress.json", c.namespace(), id)

View File

@ -147,6 +147,7 @@ func (d *Driver) GetSSHUsername() string {
return d.SSHUser
}
// DriverName returns the name of the driver
func (d *Driver) DriverName() string {
return "virtualbox"
}
@ -401,7 +402,7 @@ func (d *Driver) Create() error {
return d.Start()
}
func (d *Driver) hostOnlyIpAvailable() bool {
func (d *Driver) hostOnlyIPAvailable() bool {
ip, err := d.GetIP()
if err != nil {
log.Debugf("ERROR getting IP: %s", err)
@ -464,7 +465,7 @@ func (d *Driver) Start() error {
}
// Bail if we don't get an IP from DHCP after a given number of seconds.
if err := mcnutils.WaitForSpecific(d.hostOnlyIpAvailable, 5, 4*time.Second); err != nil {
if err := mcnutils.WaitForSpecific(d.hostOnlyIPAvailable, 5, 4*time.Second); err != nil {
return err
}

View File

@ -7,12 +7,12 @@ import (
"strings"
)
type VirtualBoxVM struct {
type VM struct {
CPUs int
Memory int
}
func (d *Driver) getVMInfo(name string) (*VirtualBoxVM, error) {
func (d *Driver) getVMInfo(name string) (*VM, error) {
out, err := d.vbmOut("showvminfo", name, "--machinereadable")
if err != nil {
return nil, err
@ -22,9 +22,9 @@ func (d *Driver) getVMInfo(name string) (*VirtualBoxVM, error) {
return parseVMInfo(r)
}
func parseVMInfo(r io.Reader) (*VirtualBoxVM, error) {
func parseVMInfo(r io.Reader) (*VM, error) {
s := bufio.NewScanner(r)
vm := &VirtualBoxVM{}
vm := &VM{}
for s.Scan() {
line := s.Text()
if line == "" {

View File

@ -131,6 +131,7 @@ func (d *Driver) GetSSHUsername() string {
return d.SSHUser
}
// DriverName returns the name of the driver
func (d *Driver) DriverName() string {
return "vmwarefusion"
}

View File

@ -142,7 +142,7 @@ func (d *Driver) GetSSHHostname() (string, error) {
return d.GetIP()
}
// Driver interface implementation
// DriverName returns the name of the driver
func (d *Driver) DriverName() string {
return "vmwarevcloudair"
}

View File

@ -147,6 +147,7 @@ func (d *Driver) GetSSHUsername() string {
return d.SSHUser
}
// DriverName returns the name of the driver
func (d *Driver) DriverName() string {
return "vmwarevsphere"
}
@ -212,7 +213,7 @@ func (d *Driver) GetState() (state.State, error) {
return state.None, nil
}
// the current implementation does the following:
// Create has the following implementation:
// 1. check whether the docker directory contains the boot2docker ISO
// 2. generate an SSH keypair and bundle it in a tar.
// 3. create a virtual machine with the boot2docker ISO mounted;

View File

@ -10,7 +10,7 @@ import (
func TestIP(t *testing.T) {
cases := []struct {
baseDriver *BaseDriver
expectedIp string
expectedIP string
expectedErr error
}{
{&BaseDriver{}, "", errors.New("IP address is not set")},
@ -22,7 +22,7 @@ func TestIP(t *testing.T) {
for _, c := range cases {
ip, err := c.baseDriver.GetIP()
assert.Equal(t, c.expectedIp, ip)
assert.Equal(t, c.expectedIP, ip)
assert.Equal(t, c.expectedErr, err)
}
}

View File

@ -15,7 +15,7 @@ type Driver interface {
// Create a host using the driver's config
Create() error
// DriverName returns the name of the driver as it is registered
// DriverName returns the name of the driver
DriverName() string
// GetCreateFlags returns the mcnflag.Flag slice representing the flags

View File

@ -62,7 +62,7 @@ type DriverPlugin interface {
PluginStreamer
}
type LocalBinaryPlugin struct {
type Plugin struct {
Executor McnBinaryExecutor
Addr string
MachineName string
@ -70,7 +70,7 @@ type LocalBinaryPlugin struct {
stopCh chan bool
}
type LocalBinaryExecutor struct {
type Executor struct {
pluginStdout, pluginStderr io.ReadCloser
DriverName string
binaryPath string
@ -84,7 +84,7 @@ func (e ErrPluginBinaryNotFound) Error() string {
return fmt.Sprintf("Driver %q not found. Do you have the plugin binary accessible in your PATH?", e.driverName)
}
func NewLocalBinaryPlugin(driverName string) (*LocalBinaryPlugin, error) {
func NewPlugin(driverName string) (*Plugin, error) {
binaryPath, err := exec.LookPath(fmt.Sprintf("docker-machine-driver-%s", driverName))
if err != nil {
return nil, ErrPluginBinaryNotFound{driverName}
@ -92,17 +92,17 @@ func NewLocalBinaryPlugin(driverName string) (*LocalBinaryPlugin, error) {
log.Debugf("Found binary path at %s", binaryPath)
return &LocalBinaryPlugin{
return &Plugin{
stopCh: make(chan bool),
addrCh: make(chan string, 1),
Executor: &LocalBinaryExecutor{
Executor: &Executor{
DriverName: driverName,
binaryPath: binaryPath,
},
}, nil
}
func (lbe *LocalBinaryExecutor) Start() (*bufio.Scanner, *bufio.Scanner, error) {
func (lbe *Executor) Start() (*bufio.Scanner, *bufio.Scanner, error) {
var err error
log.Debugf("Launching plugin server for driver %s", lbe.DriverName)
@ -131,7 +131,7 @@ func (lbe *LocalBinaryExecutor) Start() (*bufio.Scanner, *bufio.Scanner, error)
return outScanner, errScanner, nil
}
func (lbe *LocalBinaryExecutor) Close() error {
func (lbe *Executor) Close() error {
if err := lbe.pluginStdout.Close(); err != nil {
return err
}
@ -164,14 +164,14 @@ func stream(scanner *bufio.Scanner, streamOutCh chan<- string, stopCh <-chan boo
}
}
func (lbp *LocalBinaryPlugin) AttachStream(scanner *bufio.Scanner) (<-chan string, chan<- bool) {
func (lbp *Plugin) AttachStream(scanner *bufio.Scanner) (<-chan string, chan<- bool) {
streamOutCh := make(chan string)
stopCh := make(chan bool)
go stream(scanner, streamOutCh, stopCh)
return streamOutCh, stopCh
}
func (lbp *LocalBinaryPlugin) execServer() error {
func (lbp *Plugin) execServer() error {
outScanner, errScanner, err := lbp.Executor.Start()
if err != nil {
return err
@ -207,11 +207,11 @@ func (lbp *LocalBinaryPlugin) execServer() error {
}
}
func (lbp *LocalBinaryPlugin) Serve() error {
func (lbp *Plugin) Serve() error {
return lbp.execServer()
}
func (lbp *LocalBinaryPlugin) Address() (string, error) {
func (lbp *Plugin) Address() (string, error) {
if lbp.Addr == "" {
select {
case lbp.Addr = <-lbp.addrCh:
@ -225,7 +225,7 @@ func (lbp *LocalBinaryPlugin) Address() (string, error) {
return lbp.Addr, nil
}
func (lbp *LocalBinaryPlugin) Close() error {
func (lbp *Plugin) Close() error {
lbp.stopCh <- true
return nil
}

View File

@ -26,7 +26,7 @@ func (fe *FakeExecutor) Close() error {
}
func TestLocalBinaryPluginAddress(t *testing.T) {
lbp := &LocalBinaryPlugin{}
lbp := &Plugin{}
expectedAddr := "127.0.0.1:12345"
lbp.addrCh = make(chan string, 1)
@ -55,7 +55,7 @@ func TestLocalBinaryPluginAddressTimeout(t *testing.T) {
if testing.Short() {
t.Skip("Skipping timeout test")
}
lbp := &LocalBinaryPlugin{}
lbp := &Plugin{}
lbp.addrCh = make(chan string, 1)
go func() {
_, err := lbp.Address()
@ -67,7 +67,7 @@ func TestLocalBinaryPluginAddressTimeout(t *testing.T) {
}
func TestLocalBinaryPluginClose(t *testing.T) {
lbp := &LocalBinaryPlugin{}
lbp := &Plugin{}
lbp.stopCh = make(chan bool, 1)
go lbp.Close()
stopped := <-lbp.stopCh
@ -99,7 +99,7 @@ func TestExecServer(t *testing.T) {
stderr: stderrReader,
}
lbp := &LocalBinaryPlugin{
lbp := &Plugin{
MachineName: machineName,
Executor: fe,
addrCh: make(chan string, 1),

View File

@ -31,7 +31,7 @@ Please use this plugin through the main 'docker-machine' binary.
libmachine.SetDebug(true)
rpcd := rpcdriver.NewRpcServerDriver(d)
rpcd := rpcdriver.NewRPCServerDriver(d)
rpc.Register(rpcd)
rpc.HandleHTTP()

View File

@ -17,13 +17,13 @@ var (
heartbeatInterval = 200 * time.Millisecond
)
type RpcClientDriver struct {
type RPCClientDriver struct {
plugin localbinary.DriverPlugin
heartbeatDoneCh chan bool
Client *InternalClient
}
type RpcCall struct {
type RPCCall struct {
ServiceMethod string
Args interface{}
Reply interface{}
@ -31,26 +31,26 @@ type RpcCall struct {
type InternalClient struct {
MachineName string
RpcClient *rpc.Client
RPCClient *rpc.Client
}
func (ic *InternalClient) Call(serviceMethod string, args interface{}, reply interface{}) error {
if serviceMethod != "RpcServerDriver.Heartbeat" {
if serviceMethod != "RPCServerDriver.Heartbeat" {
log.Debugf("(%s) Calling %+v", ic.MachineName, serviceMethod)
}
return ic.RpcClient.Call(serviceMethod, args, reply)
return ic.RPCClient.Call(serviceMethod, args, reply)
}
func NewInternalClient(rpcclient *rpc.Client) *InternalClient {
return &InternalClient{
RpcClient: rpcclient,
RPCClient: rpcclient,
}
}
func NewRpcClientDriver(rawDriverData []byte, driverName string) (*RpcClientDriver, error) {
func NewRPCClientDriver(rawDriverData []byte, driverName string) (*RPCClientDriver, error) {
mcnName := ""
p, err := localbinary.NewLocalBinaryPlugin(driverName)
p, err := localbinary.NewPlugin(driverName)
if err != nil {
return nil, err
}
@ -73,18 +73,18 @@ func NewRpcClientDriver(rawDriverData []byte, driverName string) (*RpcClientDriv
return nil, err
}
c := &RpcClientDriver{
c := &RPCClientDriver{
Client: NewInternalClient(rpcclient),
heartbeatDoneCh: make(chan bool),
}
go func(c *RpcClientDriver) {
go func(c *RPCClientDriver) {
for {
select {
case <-c.heartbeatDoneCh:
return
default:
if err := c.Client.Call("RpcServerDriver.Heartbeat", struct{}{}, nil); err != nil {
if err := c.Client.Call("RPCServerDriver.Heartbeat", struct{}{}, nil); err != nil {
log.Warnf("Error attempting heartbeat call to plugin server: %s", err)
c.Close()
return
@ -95,7 +95,7 @@ func NewRpcClientDriver(rawDriverData []byte, driverName string) (*RpcClientDriv
}(c)
var serverVersion int
if err := c.Client.Call("RpcServerDriver.GetVersion", struct{}{}, &serverVersion); err != nil {
if err := c.Client.Call("RPCServerDriver.GetVersion", struct{}{}, &serverVersion); err != nil {
return nil, err
}
@ -116,15 +116,15 @@ func NewRpcClientDriver(rawDriverData []byte, driverName string) (*RpcClientDriv
return c, nil
}
func (c *RpcClientDriver) MarshalJSON() ([]byte, error) {
func (c *RPCClientDriver) MarshalJSON() ([]byte, error) {
return c.GetConfigRaw()
}
func (c *RpcClientDriver) UnmarshalJSON(data []byte) error {
func (c *RPCClientDriver) UnmarshalJSON(data []byte) error {
return c.SetConfigRaw(data)
}
func (c *RpcClientDriver) Close() error {
func (c *RPCClientDriver) Close() error {
c.heartbeatDoneCh <- true
close(c.heartbeatDoneCh)
@ -136,7 +136,7 @@ func (c *RpcClientDriver) Close() error {
log.Debug("Making call to close driver server")
if err := c.Client.Call("RpcServerDriver.Close", struct{}{}, nil); err != nil {
if err := c.Client.Call("RPCServerDriver.Close", struct{}{}, nil); err != nil {
return err
}
@ -147,7 +147,7 @@ func (c *RpcClientDriver) Close() error {
// Helper method to make requests which take no arguments and return simply a
// string, e.g. "GetIP".
func (c *RpcClientDriver) rpcStringCall(method string) (string, error) {
func (c *RPCClientDriver) rpcStringCall(method string) (string, error) {
var info string
if err := c.Client.Call(method, struct{}{}, &info); err != nil {
@ -157,32 +157,33 @@ func (c *RpcClientDriver) rpcStringCall(method string) (string, error) {
return info, nil
}
func (c *RpcClientDriver) GetCreateFlags() []mcnflag.Flag {
func (c *RPCClientDriver) GetCreateFlags() []mcnflag.Flag {
var flags []mcnflag.Flag
if err := c.Client.Call("RpcServerDriver.GetCreateFlags", struct{}{}, &flags); err != nil {
if err := c.Client.Call("RPCServerDriver.GetCreateFlags", struct{}{}, &flags); err != nil {
log.Warnf("Error attempting call to get create flags: %s", err)
}
return flags
}
func (c *RpcClientDriver) SetConfigRaw(data []byte) error {
return c.Client.Call("RpcServerDriver.SetConfigRaw", data, nil)
func (c *RPCClientDriver) SetConfigRaw(data []byte) error {
return c.Client.Call("RPCServerDriver.SetConfigRaw", data, nil)
}
func (c *RpcClientDriver) GetConfigRaw() ([]byte, error) {
func (c *RPCClientDriver) GetConfigRaw() ([]byte, error) {
var data []byte
if err := c.Client.Call("RpcServerDriver.GetConfigRaw", struct{}{}, &data); err != nil {
if err := c.Client.Call("RPCServerDriver.GetConfigRaw", struct{}{}, &data); err != nil {
return nil, err
}
return data, nil
}
func (c *RpcClientDriver) DriverName() string {
driverName, err := c.rpcStringCall("RpcServerDriver.DriverName")
// DriverName returns the name of the driver
func (c *RPCClientDriver) DriverName() string {
driverName, err := c.rpcStringCall("RPCServerDriver.DriverName")
if err != nil {
log.Warnf("Error attempting call to get driver name: %s", err)
}
@ -190,16 +191,16 @@ func (c *RpcClientDriver) DriverName() string {
return driverName
}
func (c *RpcClientDriver) SetConfigFromFlags(flags drivers.DriverOptions) error {
return c.Client.Call("RpcServerDriver.SetConfigFromFlags", &flags, nil)
func (c *RPCClientDriver) SetConfigFromFlags(flags drivers.DriverOptions) error {
return c.Client.Call("RPCServerDriver.SetConfigFromFlags", &flags, nil)
}
func (c *RpcClientDriver) GetURL() (string, error) {
return c.rpcStringCall("RpcServerDriver.GetURL")
func (c *RPCClientDriver) GetURL() (string, error) {
return c.rpcStringCall("RPCServerDriver.GetURL")
}
func (c *RpcClientDriver) GetMachineName() string {
name, err := c.rpcStringCall("RpcServerDriver.GetMachineName")
func (c *RPCClientDriver) GetMachineName() string {
name, err := c.rpcStringCall("RPCServerDriver.GetMachineName")
if err != nil {
log.Warnf("Error attempting call to get machine name: %s", err)
}
@ -207,17 +208,18 @@ func (c *RpcClientDriver) GetMachineName() string {
return name
}
func (c *RpcClientDriver) GetIP() (string, error) {
return c.rpcStringCall("RpcServerDriver.GetIP")
func (c *RPCClientDriver) GetIP() (string, error) {
return c.rpcStringCall("RPCServerDriver.GetIP")
}
func (c *RpcClientDriver) GetSSHHostname() (string, error) {
return c.rpcStringCall("RpcServerDriver.GetSSHHostname")
func (c *RPCClientDriver) GetSSHHostname() (string, error) {
return c.rpcStringCall("RPCServerDriver.GetSSHHostname")
}
// GetSSHKeyPath returns the key path
// TODO: This method doesn't even make sense to have with RPC.
func (c *RpcClientDriver) GetSSHKeyPath() string {
path, err := c.rpcStringCall("RpcServerDriver.GetSSHKeyPath")
func (c *RPCClientDriver) GetSSHKeyPath() string {
path, err := c.rpcStringCall("RPCServerDriver.GetSSHKeyPath")
if err != nil {
log.Warnf("Error attempting call to get SSH key path: %s", err)
}
@ -225,18 +227,18 @@ func (c *RpcClientDriver) GetSSHKeyPath() string {
return path
}
func (c *RpcClientDriver) GetSSHPort() (int, error) {
func (c *RPCClientDriver) GetSSHPort() (int, error) {
var port int
if err := c.Client.Call("RpcServerDriver.GetSSHPort", struct{}{}, &port); err != nil {
if err := c.Client.Call("RPCServerDriver.GetSSHPort", struct{}{}, &port); err != nil {
return 0, err
}
return port, nil
}
func (c *RpcClientDriver) GetSSHUsername() string {
username, err := c.rpcStringCall("RpcServerDriver.GetSSHUsername")
func (c *RPCClientDriver) GetSSHUsername() string {
username, err := c.rpcStringCall("RPCServerDriver.GetSSHUsername")
if err != nil {
log.Warnf("Error attempting call to get SSH username: %s", err)
}
@ -244,56 +246,56 @@ func (c *RpcClientDriver) GetSSHUsername() string {
return username
}
func (c *RpcClientDriver) GetState() (state.State, error) {
func (c *RPCClientDriver) GetState() (state.State, error) {
var s state.State
if err := c.Client.Call("RpcServerDriver.GetState", struct{}{}, &s); err != nil {
if err := c.Client.Call("RPCServerDriver.GetState", struct{}{}, &s); err != nil {
return state.Error, err
}
return s, nil
}
func (c *RpcClientDriver) PreCreateCheck() error {
return c.Client.Call("RpcServerDriver.PreCreateCheck", struct{}{}, nil)
func (c *RPCClientDriver) PreCreateCheck() error {
return c.Client.Call("RPCServerDriver.PreCreateCheck", struct{}{}, nil)
}
func (c *RpcClientDriver) Create() error {
return c.Client.Call("RpcServerDriver.Create", struct{}{}, nil)
func (c *RPCClientDriver) Create() error {
return c.Client.Call("RPCServerDriver.Create", struct{}{}, nil)
}
func (c *RpcClientDriver) Remove() error {
return c.Client.Call("RpcServerDriver.Remove", struct{}{}, nil)
func (c *RPCClientDriver) Remove() error {
return c.Client.Call("RPCServerDriver.Remove", struct{}{}, nil)
}
func (c *RpcClientDriver) Start() error {
return c.Client.Call("RpcServerDriver.Start", struct{}{}, nil)
func (c *RPCClientDriver) Start() error {
return c.Client.Call("RPCServerDriver.Start", struct{}{}, nil)
}
func (c *RpcClientDriver) Stop() error {
return c.Client.Call("RpcServerDriver.Stop", struct{}{}, nil)
func (c *RPCClientDriver) Stop() error {
return c.Client.Call("RPCServerDriver.Stop", struct{}{}, nil)
}
func (c *RpcClientDriver) Restart() error {
return c.Client.Call("RpcServerDriver.Restart", struct{}{}, nil)
func (c *RPCClientDriver) Restart() error {
return c.Client.Call("RPCServerDriver.Restart", struct{}{}, nil)
}
func (c *RpcClientDriver) Kill() error {
return c.Client.Call("RpcServerDriver.Kill", struct{}{}, nil)
func (c *RPCClientDriver) Kill() error {
return c.Client.Call("RPCServerDriver.Kill", struct{}{}, nil)
}
func (c *RpcClientDriver) LocalArtifactPath(file string) string {
func (c *RPCClientDriver) LocalArtifactPath(file string) string {
var path string
if err := c.Client.Call("RpcServerDriver.LocalArtifactPath", file, &path); err != nil {
if err := c.Client.Call("RPCServerDriver.LocalArtifactPath", file, &path); err != nil {
log.Warnf("Error attempting call to get LocalArtifactPath: %s", err)
}
return path
}
func (c *RpcClientDriver) GlobalArtifactPath() string {
globalArtifactPath, err := c.rpcStringCall("RpcServerDriver.GlobalArtifactPath")
func (c *RPCClientDriver) GlobalArtifactPath() string {
globalArtifactPath, err := c.rpcStringCall("RPCServerDriver.GlobalArtifactPath")
if err != nil {
log.Warnf("Error attempting call to get GlobalArtifactPath: %s", err)
}
@ -301,6 +303,6 @@ func (c *RpcClientDriver) GlobalArtifactPath() string {
return globalArtifactPath
}
func (c *RpcClientDriver) Upgrade() error {
return c.Client.Call("RpcServerDriver.Upgrade", struct{}{}, nil)
func (c *RPCClientDriver) Upgrade() error {
return c.Client.Call("RPCServerDriver.Upgrade", struct{}{}, nil)
}

View File

@ -12,18 +12,18 @@ import (
)
func init() {
gob.Register(new(RpcFlags))
gob.Register(new(RPCFlags))
gob.Register(new(mcnflag.IntFlag))
gob.Register(new(mcnflag.StringFlag))
gob.Register(new(mcnflag.StringSliceFlag))
gob.Register(new(mcnflag.BoolFlag))
}
type RpcFlags struct {
type RPCFlags struct {
Values map[string]interface{}
}
func (r RpcFlags) Get(key string) interface{} {
func (r RPCFlags) Get(key string) interface{} {
val, ok := r.Values[key]
if !ok {
log.Warnf("Trying to access option %s which does not exist", key)
@ -32,7 +32,7 @@ func (r RpcFlags) Get(key string) interface{} {
return val
}
func (r RpcFlags) String(key string) string {
func (r RPCFlags) String(key string) string {
val, ok := r.Get(key).(string)
if !ok {
log.Warnf("Type assertion did not go smoothly to string for key %s", key)
@ -40,7 +40,7 @@ func (r RpcFlags) String(key string) string {
return val
}
func (r RpcFlags) StringSlice(key string) []string {
func (r RPCFlags) StringSlice(key string) []string {
val, ok := r.Get(key).([]string)
if !ok {
log.Warnf("Type assertion did not go smoothly to string slice for key %s", key)
@ -48,7 +48,7 @@ func (r RpcFlags) StringSlice(key string) []string {
return val
}
func (r RpcFlags) Int(key string) int {
func (r RPCFlags) Int(key string) int {
val, ok := r.Get(key).(int)
if !ok {
log.Warnf("Type assertion did not go smoothly to int for key %s", key)
@ -56,7 +56,7 @@ func (r RpcFlags) Int(key string) int {
return val
}
func (r RpcFlags) Bool(key string) bool {
func (r RPCFlags) Bool(key string) bool {
val, ok := r.Get(key).(bool)
if !ok {
log.Warnf("Type assertion did not go smoothly to bool for key %s", key)
@ -64,31 +64,31 @@ func (r RpcFlags) Bool(key string) bool {
return val
}
type RpcServerDriver struct {
type RPCServerDriver struct {
ActualDriver drivers.Driver
CloseCh chan bool
HeartbeatCh chan bool
}
func NewRpcServerDriver(d drivers.Driver) *RpcServerDriver {
return &RpcServerDriver{
func NewRPCServerDriver(d drivers.Driver) *RPCServerDriver {
return &RPCServerDriver{
ActualDriver: d,
CloseCh: make(chan bool),
HeartbeatCh: make(chan bool),
}
}
func (r *RpcServerDriver) Close(_, _ *struct{}) error {
func (r *RPCServerDriver) Close(_, _ *struct{}) error {
r.CloseCh <- true
return nil
}
func (r *RpcServerDriver) GetVersion(_ *struct{}, reply *int) error {
func (r *RPCServerDriver) GetVersion(_ *struct{}, reply *int) error {
*reply = version.APIVersion
return nil
}
func (r *RpcServerDriver) GetConfigRaw(_ *struct{}, reply *[]byte) error {
func (r *RPCServerDriver) GetConfigRaw(_ *struct{}, reply *[]byte) error {
driverData, err := json.Marshal(r.ActualDriver)
if err != nil {
return err
@ -99,99 +99,99 @@ func (r *RpcServerDriver) GetConfigRaw(_ *struct{}, reply *[]byte) error {
return nil
}
func (r *RpcServerDriver) GetCreateFlags(_ *struct{}, reply *[]mcnflag.Flag) error {
func (r *RPCServerDriver) GetCreateFlags(_ *struct{}, reply *[]mcnflag.Flag) error {
*reply = r.ActualDriver.GetCreateFlags()
return nil
}
func (r *RpcServerDriver) SetConfigRaw(data []byte, _ *struct{}) error {
func (r *RPCServerDriver) SetConfigRaw(data []byte, _ *struct{}) error {
return json.Unmarshal(data, &r.ActualDriver)
}
func (r *RpcServerDriver) Create(_, _ *struct{}) error {
func (r *RPCServerDriver) Create(_, _ *struct{}) error {
return r.ActualDriver.Create()
}
func (r *RpcServerDriver) DriverName(_ *struct{}, reply *string) error {
func (r *RPCServerDriver) DriverName(_ *struct{}, reply *string) error {
*reply = r.ActualDriver.DriverName()
return nil
}
func (r *RpcServerDriver) GetIP(_ *struct{}, reply *string) error {
func (r *RPCServerDriver) GetIP(_ *struct{}, reply *string) error {
ip, err := r.ActualDriver.GetIP()
*reply = ip
return err
}
func (r *RpcServerDriver) GetMachineName(_ *struct{}, reply *string) error {
func (r *RPCServerDriver) GetMachineName(_ *struct{}, reply *string) error {
*reply = r.ActualDriver.GetMachineName()
return nil
}
func (r *RpcServerDriver) GetSSHHostname(_ *struct{}, reply *string) error {
func (r *RPCServerDriver) GetSSHHostname(_ *struct{}, reply *string) error {
hostname, err := r.ActualDriver.GetSSHHostname()
*reply = hostname
return err
}
func (r *RpcServerDriver) GetSSHKeyPath(_ *struct{}, reply *string) error {
func (r *RPCServerDriver) GetSSHKeyPath(_ *struct{}, reply *string) error {
*reply = r.ActualDriver.GetSSHKeyPath()
return nil
}
// GetSSHPort returns port for use with ssh
func (r *RpcServerDriver) GetSSHPort(_ *struct{}, reply *int) error {
func (r *RPCServerDriver) GetSSHPort(_ *struct{}, reply *int) error {
port, err := r.ActualDriver.GetSSHPort()
*reply = port
return err
}
func (r *RpcServerDriver) GetSSHUsername(_ *struct{}, reply *string) error {
func (r *RPCServerDriver) GetSSHUsername(_ *struct{}, reply *string) error {
*reply = r.ActualDriver.GetSSHUsername()
return nil
}
func (r *RpcServerDriver) GetURL(_ *struct{}, reply *string) error {
func (r *RPCServerDriver) GetURL(_ *struct{}, reply *string) error {
info, err := r.ActualDriver.GetURL()
*reply = info
return err
}
func (r *RpcServerDriver) GetState(_ *struct{}, reply *state.State) error {
func (r *RPCServerDriver) GetState(_ *struct{}, reply *state.State) error {
s, err := r.ActualDriver.GetState()
*reply = s
return err
}
func (r *RpcServerDriver) Kill(_ *struct{}, _ *struct{}) error {
func (r *RPCServerDriver) Kill(_ *struct{}, _ *struct{}) error {
return r.ActualDriver.Kill()
}
func (r *RpcServerDriver) PreCreateCheck(_ *struct{}, _ *struct{}) error {
func (r *RPCServerDriver) PreCreateCheck(_ *struct{}, _ *struct{}) error {
return r.ActualDriver.PreCreateCheck()
}
func (r *RpcServerDriver) Remove(_ *struct{}, _ *struct{}) error {
func (r *RPCServerDriver) Remove(_ *struct{}, _ *struct{}) error {
return r.ActualDriver.Remove()
}
func (r *RpcServerDriver) Restart(_ *struct{}, _ *struct{}) error {
func (r *RPCServerDriver) Restart(_ *struct{}, _ *struct{}) error {
return r.ActualDriver.Restart()
}
func (r *RpcServerDriver) SetConfigFromFlags(flags *drivers.DriverOptions, _ *struct{}) error {
func (r *RPCServerDriver) SetConfigFromFlags(flags *drivers.DriverOptions, _ *struct{}) error {
return r.ActualDriver.SetConfigFromFlags(*flags)
}
func (r *RpcServerDriver) Start(_ *struct{}, _ *struct{}) error {
func (r *RPCServerDriver) Start(_ *struct{}, _ *struct{}) error {
return r.ActualDriver.Start()
}
func (r *RpcServerDriver) Stop(_ *struct{}, _ *struct{}) error {
func (r *RPCServerDriver) Stop(_ *struct{}, _ *struct{}) error {
return r.ActualDriver.Stop()
}
func (r *RpcServerDriver) Heartbeat(_ *struct{}, _ *struct{}) error {
func (r *RPCServerDriver) Heartbeat(_ *struct{}, _ *struct{}) error {
r.HeartbeatCh <- true
return nil
}

View File

@ -9,11 +9,11 @@ import (
var stdLock = &sync.Mutex{}
// SerialDriver is a wrapper struct which is used to ensure that RPC calls
// to a driver only occur one at a time.
// Some providers, e.g. virtualbox, should not run driver operations at the
// same time as other driver instances of the same type. Otherwise, we scrape
// up against VirtualBox's own locking mechanisms. Therefore this is a wrapper
// struct which is used to ensure that RPC calls to these drivers only occur
// one at a time.
// same time as other driver instances of the same type. Otherwise, we scrape
// up against VirtualBox's own locking mechanisms.
//
// It would be preferable to simply have a lock around, say, the VBoxManage
// command, but with our current one-server-process-per-machine model it is

View File

@ -45,7 +45,7 @@ func (s Filestore) Save(host *host.Host) error {
}
// TODO: Does this belong here?
if rpcClientDriver, ok := host.Driver.(*rpcdriver.RpcClientDriver); ok {
if rpcClientDriver, ok := host.Driver.(*rpcdriver.RPCClientDriver); ok {
data, err := rpcClientDriver.GetConfigRaw()
if err != nil {
return fmt.Errorf("Error getting raw config for driver: %s", err)

View File

@ -20,4 +20,4 @@ vet: build
lint:
$(if $(GOLINT), , \
$(error Please install golint: go get -u github.com/golang/lint/golint))
@test -z "$$($(GOLINT) ./... 2>&1 | grep -v vendor/ | grep -v drivers/ | grep -v cli/ | grep -v "should have comment" | tee /dev/stderr)"
@test -z "$$($(GOLINT) ./... 2>&1 | grep -v vendor/ | grep -v "cli/" | grep -v "amazonec2/" |grep -v "openstack/" |grep -v "softlayer/" | grep -v "should have comment" | tee /dev/stderr)"