mirror of https://github.com/docker/docs.git
Fix #1972 Google drive is broken because of tags
Signed-off-by: David Gageot <david@gageot.net>
This commit is contained in:
parent
6a5219b879
commit
264ca68902
|
@ -177,8 +177,6 @@ func (c *ComputeUtil) createInstance(d *Driver) error {
|
|||
}
|
||||
}
|
||||
|
||||
tags := append(d.Tags, firewallTargetTag)
|
||||
|
||||
instance := &raw.Instance{
|
||||
Name: c.instanceName,
|
||||
Description: "docker host vm",
|
||||
|
@ -200,7 +198,7 @@ func (c *ComputeUtil) createInstance(d *Driver) error {
|
|||
},
|
||||
},
|
||||
Tags: &raw.Tags{
|
||||
Items: tags,
|
||||
Items: parseTags(d),
|
||||
},
|
||||
ServiceAccounts: []*raw.ServiceAccount{
|
||||
{
|
||||
|
@ -277,6 +275,17 @@ func (c *ComputeUtil) createInstance(d *Driver) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// parseTags computes the tags for the instance.
|
||||
func parseTags(d *Driver) []string {
|
||||
tags := []string{firewallTargetTag}
|
||||
|
||||
if d.Tags != "" {
|
||||
tags = append(tags, strings.Split(d.Tags, ",")...)
|
||||
}
|
||||
|
||||
return tags
|
||||
}
|
||||
|
||||
// deleteInstance deletes the instance, leaving the persistent disk.
|
||||
func (c *ComputeUtil) deleteInstance() error {
|
||||
log.Infof("Deleting instance.")
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
package google
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func TestDefaultTag(t *testing.T) {
|
||||
tags := parseTags(&Driver{Tags: ""})
|
||||
|
||||
assert.Equal(t, []string{"docker-machine"}, tags)
|
||||
}
|
||||
|
||||
func TestAdditionalTag(t *testing.T) {
|
||||
tags := parseTags(&Driver{Tags: "tag1"})
|
||||
|
||||
assert.Equal(t, []string{"docker-machine", "tag1"}, tags)
|
||||
}
|
||||
|
||||
func TestAdditionalTags(t *testing.T) {
|
||||
tags := parseTags(&Driver{Tags: "tag1,tag2"})
|
||||
|
||||
assert.Equal(t, []string{"docker-machine", "tag1", "tag2"}, tags)
|
||||
}
|
|
@ -23,7 +23,7 @@ type Driver struct {
|
|||
DiskSize int
|
||||
AuthTokenPath string
|
||||
Project string
|
||||
Tags []string
|
||||
Tags string
|
||||
}
|
||||
|
||||
const (
|
||||
|
@ -154,7 +154,7 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
|
|||
d.AuthTokenPath = flags.String("google-auth-token")
|
||||
d.Project = flags.String("google-project")
|
||||
d.Scopes = flags.String("google-scopes")
|
||||
d.Tags = flags.StringSlice("google-tags")
|
||||
d.Tags = flags.String("google-tags")
|
||||
d.SwarmMaster = flags.Bool("swarm-master")
|
||||
d.SwarmHost = flags.String("swarm-host")
|
||||
d.SwarmDiscovery = flags.String("swarm-discovery")
|
||||
|
|
Loading…
Reference in New Issue