Add google-scopes option to specify Compute Engine scopes

Signed-off-by: Ray Tsang <saturnism@gmail.com>
This commit is contained in:
Ray Tsang 2015-02-21 17:21:12 -05:00
parent 75e3e8e956
commit 64544bd1c0
3 changed files with 16 additions and 2 deletions

View File

@ -195,6 +195,7 @@ Options:
- `--google-username`: The username to use for the instance. Default: `docker-user` - `--google-username`: The username to use for the instance. Default: `docker-user`
- `--google-instance-name`: The name of the instance. Default: `docker-machine` - `--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-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 ### VMware Fusion

View File

@ -37,8 +37,6 @@ const (
dockerStopCommand = "sudo service docker stop" dockerStopCommand = "sudo service docker stop"
) )
const ()
// NewComputeUtil creates and initializes a ComputeUtil. // NewComputeUtil creates and initializes a ComputeUtil.
func newComputeUtil(driver *Driver) (*ComputeUtil, error) { func newComputeUtil(driver *Driver) (*ComputeUtil, error) {
service, err := newGCEService(driver.storePath) service, err := newGCEService(driver.storePath)
@ -167,6 +165,12 @@ func (c *ComputeUtil) createInstance(d *Driver) error {
firewallTargetTag, firewallTargetTag,
}, },
}, },
ServiceAccounts: []*raw.ServiceAccount{
{
Email: "default",
Scopes: strings.Split(d.Scopes, ","),
},
},
} }
disk, err := c.disk() disk, err := c.disk()
if disk == nil || err != nil { if disk == nil || err != nil {

View File

@ -23,6 +23,7 @@ type Driver struct {
MachineName string MachineName string
Zone string Zone string
MachineType string MachineType string
Scopes string
DiskSize int DiskSize int
storePath string storePath string
UserName string UserName string
@ -42,6 +43,7 @@ type CreateFlags struct {
MachineType *string MachineType *string
UserName *string UserName *string
Project *string Project *string
Scopes *string
DiskSize *int DiskSize *int
} }
@ -79,6 +81,12 @@ func GetCreateFlags() []cli.Flag {
Usage: "GCE Project", Usage: "GCE Project",
EnvVar: "GOOGLE_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{ cli.IntFlag{
Name: "google-disk-size", Name: "google-disk-size",
Usage: "GCE Instance Disk Size (in GB)", 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.DiskSize = flags.Int("google-disk-size")
driver.UserName = flags.String("google-username") driver.UserName = flags.String("google-username")
driver.Project = flags.String("google-project") driver.Project = flags.String("google-project")
driver.Scopes = flags.String("google-scopes")
driver.SwarmMaster = flags.Bool("swarm-master") driver.SwarmMaster = flags.Bool("swarm-master")
driver.SwarmHost = flags.String("swarm-host") driver.SwarmHost = flags.String("swarm-host")
driver.SwarmDiscovery = flags.String("swarm-discovery") driver.SwarmDiscovery = flags.String("swarm-discovery")