mirror of https://github.com/docker/docs.git
Merge pull request #687 from zchee/google-disk-type
Support --google-disk-type flag for google driver
This commit is contained in:
commit
1668f97ba4
|
@ -18,6 +18,7 @@ type ComputeUtil struct {
|
|||
instanceName string
|
||||
userName string
|
||||
project string
|
||||
diskTypeURL string
|
||||
service *raw.Service
|
||||
zoneURL string
|
||||
authTokenPath string
|
||||
|
@ -49,6 +50,7 @@ func newComputeUtil(driver *Driver) (*ComputeUtil, error) {
|
|||
instanceName: driver.MachineName,
|
||||
userName: driver.SSHUser,
|
||||
project: driver.Project,
|
||||
diskTypeURL: driver.DiskType,
|
||||
service: service,
|
||||
zoneURL: apiURL + driver.Project + "/zones/" + driver.Zone,
|
||||
globalURL: apiURL + driver.Project + "/global",
|
||||
|
@ -62,6 +64,10 @@ func (c *ComputeUtil) diskName() string {
|
|||
return c.instanceName + "-disk"
|
||||
}
|
||||
|
||||
func (c *ComputeUtil) diskType() string {
|
||||
return apiURL + c.project + "/zones/" + c.zone + "/diskTypes/" + c.diskTypeURL
|
||||
}
|
||||
|
||||
// disk returns the gce Disk.
|
||||
func (c *ComputeUtil) disk() (*raw.Disk, error) {
|
||||
return c.service.Disks.Get(c.project, c.zone, c.diskName()).Do()
|
||||
|
@ -180,6 +186,7 @@ func (c *ComputeUtil) createInstance(d *Driver) error {
|
|||
SourceImage: imageName,
|
||||
// The maximum supported disk size is 1000GB, the cast should be fine.
|
||||
DiskSizeGb: int64(d.DiskSize),
|
||||
DiskType: c.diskType(),
|
||||
}
|
||||
} else {
|
||||
instance.Disks[0].Source = c.zoneURL + "/disks/" + c.instanceName + "-disk"
|
||||
|
|
|
@ -19,6 +19,7 @@ type Driver struct {
|
|||
SSHPort int
|
||||
Zone string
|
||||
MachineType string
|
||||
DiskType string
|
||||
Scopes string
|
||||
DiskSize int
|
||||
AuthTokenPath string
|
||||
|
@ -82,6 +83,12 @@ func GetCreateFlags() []cli.Flag {
|
|||
Value: 10,
|
||||
EnvVar: "GOOGLE_DISK_SIZE",
|
||||
},
|
||||
cli.StringFlag{
|
||||
Name: "google-disk-type",
|
||||
Usage: "GCE Instance Disk type",
|
||||
Value: "pd-standard",
|
||||
EnvVar: "GOOGLE_DISK_TYPE",
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -145,6 +152,7 @@ func (d *Driver) SetConfigFromFlags(flags drivers.DriverOptions) error {
|
|||
d.Zone = flags.String("google-zone")
|
||||
d.MachineType = flags.String("google-machine-type")
|
||||
d.DiskSize = flags.Int("google-disk-size")
|
||||
d.DiskType = flags.String("google-disk-type")
|
||||
d.AuthTokenPath = flags.String("google-auth-token")
|
||||
d.Project = flags.String("google-project")
|
||||
d.Scopes = flags.String("google-scopes")
|
||||
|
|
Loading…
Reference in New Issue