mirror of https://github.com/docker/docs.git
Remove dead code and other cosmetic changes
Signed-off-by: David Gageot <david@gageot.net>
This commit is contained in:
parent
95bd94da62
commit
58b4cce392
|
|
@ -9,7 +9,6 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/docker/machine/libmachine/log"
|
"github.com/docker/machine/libmachine/log"
|
||||||
"github.com/docker/machine/libmachine/ssh"
|
|
||||||
raw "google.golang.org/api/compute/v1"
|
raw "google.golang.org/api/compute/v1"
|
||||||
|
|
||||||
"errors"
|
"errors"
|
||||||
|
|
@ -82,7 +81,7 @@ func (c *ComputeUtil) diskType() string {
|
||||||
return apiURL + c.project + "/zones/" + c.zone + "/diskTypes/" + c.diskTypeURL
|
return apiURL + c.project + "/zones/" + c.zone + "/diskTypes/" + c.diskTypeURL
|
||||||
}
|
}
|
||||||
|
|
||||||
// disk returns the gce Disk.
|
// disk returns the persistent disk attached to the vm.
|
||||||
func (c *ComputeUtil) disk() (*raw.Disk, error) {
|
func (c *ComputeUtil) disk() (*raw.Disk, error) {
|
||||||
return c.service.Disks.Get(c.project, c.zone, c.diskName()).Do()
|
return c.service.Disks.Get(c.project, c.zone, c.diskName()).Do()
|
||||||
}
|
}
|
||||||
|
|
@ -94,6 +93,7 @@ func (c *ComputeUtil) deleteDisk() error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Infof("Waiting for disk to delete.")
|
log.Infof("Waiting for disk to delete.")
|
||||||
return c.waitForRegionalOp(op.Name)
|
return c.waitForRegionalOp(op.Name)
|
||||||
}
|
}
|
||||||
|
|
@ -130,12 +130,9 @@ func (c *ComputeUtil) firewallRule() (*raw.Firewall, error) {
|
||||||
func (c *ComputeUtil) createFirewallRule() error {
|
func (c *ComputeUtil) createFirewallRule() error {
|
||||||
log.Infof("Creating firewall rule.")
|
log.Infof("Creating firewall rule.")
|
||||||
allowed := []*raw.FirewallAllowed{
|
allowed := []*raw.FirewallAllowed{
|
||||||
|
|
||||||
{
|
{
|
||||||
IPProtocol: "tcp",
|
IPProtocol: "tcp",
|
||||||
Ports: []string{
|
Ports: []string{port},
|
||||||
port,
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -149,25 +146,22 @@ func (c *ComputeUtil) createFirewallRule() error {
|
||||||
swarmPort := parts[1]
|
swarmPort := parts[1]
|
||||||
allowed = append(allowed, &raw.FirewallAllowed{
|
allowed = append(allowed, &raw.FirewallAllowed{
|
||||||
IPProtocol: "tcp",
|
IPProtocol: "tcp",
|
||||||
Ports: []string{
|
Ports: []string{swarmPort},
|
||||||
swarmPort,
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
rule := &raw.Firewall{
|
rule := &raw.Firewall{
|
||||||
Allowed: allowed,
|
Allowed: allowed,
|
||||||
SourceRanges: []string{
|
SourceRanges: []string{"0.0.0.0/0"},
|
||||||
"0.0.0.0/0",
|
TargetTags: []string{firewallTargetTag},
|
||||||
},
|
|
||||||
TargetTags: []string{
|
|
||||||
firewallTargetTag,
|
|
||||||
},
|
|
||||||
Name: firewallRule,
|
Name: firewallRule,
|
||||||
}
|
}
|
||||||
|
|
||||||
op, err := c.service.Firewalls.Insert(c.project, rule).Do()
|
op, err := c.service.Firewalls.Insert(c.project, rule).Do()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
return c.waitForGlobalOp(op.Name)
|
return c.waitForGlobalOp(op.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -179,6 +173,7 @@ func (c *ComputeUtil) instance() (*raw.Instance, error) {
|
||||||
// createInstance creates a GCE VM instance.
|
// createInstance creates a GCE VM instance.
|
||||||
func (c *ComputeUtil) createInstance(d *Driver) error {
|
func (c *ComputeUtil) createInstance(d *Driver) error {
|
||||||
log.Infof("Creating instance.")
|
log.Infof("Creating instance.")
|
||||||
|
|
||||||
// The rule will either exist or be nil in case of an error.
|
// The rule will either exist or be nil in case of an error.
|
||||||
if rule, _ := c.firewallRule(); rule == nil {
|
if rule, _ := c.firewallRule(); rule == nil {
|
||||||
if err := c.createFirewallRule(); err != nil {
|
if err := c.createFirewallRule(); err != nil {
|
||||||
|
|
@ -329,30 +324,13 @@ func (c *ComputeUtil) startInstance() error {
|
||||||
return c.waitForRegionalOp(op.Name)
|
return c.waitForRegionalOp(op.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ComputeUtil) executeCommands(commands []string, ip, sshKeyPath string) error {
|
|
||||||
for _, command := range commands {
|
|
||||||
auth := &ssh.Auth{
|
|
||||||
Keys: []string{sshKeyPath},
|
|
||||||
}
|
|
||||||
|
|
||||||
client, err := ssh.NewClient(c.userName, ip, 22, auth)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if _, err := client.Output(command); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *ComputeUtil) waitForOp(opGetter func() (*raw.Operation, error)) error {
|
func (c *ComputeUtil) waitForOp(opGetter func() (*raw.Operation, error)) error {
|
||||||
for {
|
for {
|
||||||
op, err := opGetter()
|
op, err := opGetter()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debugf("operation %q status: %s", op.Name, op.Status)
|
log.Debugf("operation %q status: %s", op.Name, op.Status)
|
||||||
if op.Status == "DONE" {
|
if op.Status == "DONE" {
|
||||||
if op.Error != nil {
|
if op.Error != nil {
|
||||||
|
|
@ -365,13 +343,14 @@ func (c *ComputeUtil) waitForOp(opGetter func() (*raw.Operation, error)) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// waitForOp waits for the GCE Operation to finish.
|
// waitForOp waits for the operation to finish.
|
||||||
func (c *ComputeUtil) waitForRegionalOp(name string) error {
|
func (c *ComputeUtil) waitForRegionalOp(name string) error {
|
||||||
return c.waitForOp(func() (*raw.Operation, error) {
|
return c.waitForOp(func() (*raw.Operation, error) {
|
||||||
return c.service.ZoneOperations.Get(c.project, c.zone, name).Do()
|
return c.service.ZoneOperations.Get(c.project, c.zone, name).Do()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// waitForGlobalOp waits for the global operation to finish.
|
||||||
func (c *ComputeUtil) waitForGlobalOp(name string) error {
|
func (c *ComputeUtil) waitForGlobalOp(name string) error {
|
||||||
return c.waitForOp(func() (*raw.Operation, error) {
|
return c.waitForOp(func() (*raw.Operation, error) {
|
||||||
return c.service.GlobalOperations.Get(c.project, name).Do()
|
return c.service.GlobalOperations.Get(c.project, name).Do()
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestSetConfigFromFlags(t *testing.T) {
|
func TestSetConfigFromFlags(t *testing.T) {
|
||||||
driver := NewDriver("default", "path")
|
driver := NewDriver("", "")
|
||||||
|
|
||||||
checkFlags := &drivers.CheckDriverOptions{
|
checkFlags := &drivers.CheckDriverOptions{
|
||||||
FlagsValues: map[string]interface{}{
|
FlagsValues: map[string]interface{}{
|
||||||
|
|
|
||||||
|
|
@ -141,7 +141,7 @@ func (provisioner *UbuntuSystemdProvisioner) Provision(swarmOptions swarm.Option
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Debug("installing docker")
|
log.Info("Installing Docker...")
|
||||||
if err := installDockerGeneric(provisioner, engineOptions.InstallURL); err != nil {
|
if err := installDockerGeneric(provisioner, engineOptions.InstallURL); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue