Add upload to Google Cloud Storage and Google Compute Image creation

- the image upload uses the cloud API
- currently auth and image creation need the `gcloud` CLI tool.

Signed-off-by: Justin Cormack <justin.cormack@docker.com>
This commit is contained in:
Justin Cormack
2017-03-14 14:45:05 +00:00
parent 1b31c5582d
commit 37c6169ab7
170 changed files with 51069 additions and 26 deletions

View File

@@ -39,6 +39,34 @@ func outputs(m *Moby, base string, bzimage []byte, initrd []byte) error {
if err != nil {
return fmt.Errorf("Error writing %s output: %v", o.Format, err)
}
case "gce-storage":
err := outputImg(gce, base+".img.tar.gz", bzimage, initrd, m.Kernel.Cmdline)
if err != nil {
return fmt.Errorf("Error writing %s output: %v", o.Format, err)
}
if o.Bucket == "" {
return fmt.Errorf("No bucket specified for GCE output")
}
err = uploadGS(base+".img.tar.gz", o.Project, o.Bucket, o.Public)
if err != nil {
return fmt.Errorf("Error copying to Google Storage: %v", err)
}
case "gce":
err := outputImg(gce, base+".img.tar.gz", bzimage, initrd, m.Kernel.Cmdline)
if err != nil {
return fmt.Errorf("Error writing %s output: %v", o.Format, err)
}
if o.Bucket == "" {
return fmt.Errorf("No bucket specified for GCE output")
}
err = uploadGS(base+".img.tar.gz", o.Project, o.Bucket, o.Public)
if err != nil {
return fmt.Errorf("Error copying to Google Storage: %v", err)
}
err = imageGS(base, o.Project, "https://storage.googleapis.com/"+o.Bucket+"/"+base+".img.tar.gz")
if err != nil {
return fmt.Errorf("Error creating Google Compute Image: %v", err)
}
case "qcow", "qcow2":
err := outputImg(qcow, base+".qcow2", bzimage, initrd, m.Kernel.Cmdline)
if err != nil {