diff --git a/README.md b/README.md index e3d7350f6f..266414c110 100644 --- a/README.md +++ b/README.md @@ -195,6 +195,7 @@ Options: - `--google-username`: The username to use for the instance. Default: `docker-user` - `--google-instance-name`: The name of the instance. Default: `docker-machine` - `--google-project`: The name of your project to use when launching the instance. + - `--google-scopes`: The scopes associated to the instance. Comma-separated if multiple scopes. Default: `https://www.googleapis.com/auth/devstorage.read_only,https://www.googleapis.com/auth/logging.write`` ### VMware Fusion diff --git a/drivers/google/compute_util.go b/drivers/google/compute_util.go index d9f5f7092f..156610b04d 100644 --- a/drivers/google/compute_util.go +++ b/drivers/google/compute_util.go @@ -37,8 +37,6 @@ const ( dockerStopCommand = "sudo service docker stop" ) -const () - // NewComputeUtil creates and initializes a ComputeUtil. func newComputeUtil(driver *Driver) (*ComputeUtil, error) { service, err := newGCEService(driver.storePath) @@ -167,6 +165,12 @@ func (c *ComputeUtil) createInstance(d *Driver) error { firewallTargetTag, }, }, + ServiceAccounts: []*raw.ServiceAccount{ + { + Email: "default", + Scopes: strings.Split(d.Scopes, ","), + }, + }, } disk, err := c.disk() if disk == nil || err != nil { diff --git a/drivers/google/google.go b/drivers/google/google.go index 30e80a6aaf..72389a8318 100644 --- a/drivers/google/google.go +++ b/drivers/google/google.go @@ -23,6 +23,7 @@ type Driver struct { MachineName string Zone string MachineType string + Scopes string DiskSize int storePath string UserName string @@ -42,6 +43,7 @@ type CreateFlags struct { MachineType *string UserName *string Project *string + Scopes *string DiskSize *int } @@ -79,6 +81,12 @@ func GetCreateFlags() []cli.Flag { Usage: "GCE Project", EnvVar: "GOOGLE_PROJECT", }, + cli.StringFlag{ + Name: "google-scopes", + Usage: "GCE Scopes (comma-separated if multiple scopes)", + Value: "https://www.googleapis.com/auth/devstorage.read_only,https://www.googleapis.com/auth/logging.write", + EnvVar: "GOOGLE_SCOPES", + }, cli.IntFlag{ Name: "google-disk-size", Usage: "GCE Instance Disk Size (in GB)", @@ -112,6 +120,7 @@ func (driver *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error { driver.DiskSize = flags.Int("google-disk-size") driver.UserName = flags.String("google-username") driver.Project = flags.String("google-project") + driver.Scopes = flags.String("google-scopes") driver.SwarmMaster = flags.Bool("swarm-master") driver.SwarmHost = flags.String("swarm-host") driver.SwarmDiscovery = flags.String("swarm-discovery")