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-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

View File

@ -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 {

View File

@ -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")