Merge pull request #1522 from dave-tucker/gce-gcp

Use GCP everywhere for consistency
This commit is contained in:
Justin Cormack 2017-04-06 17:27:15 +01:00 committed by GitHub
commit dc1818147c
9 changed files with 22 additions and 21 deletions

View File

@ -73,7 +73,7 @@ files:
contents: '{"debug": true}' contents: '{"debug": true}'
outputs: outputs:
- format: kernel+initrd - format: kernel+initrd
- format: gce - format: gcp
project: moby project: moby
bucket: mobytestjustin bucket: mobytestjustin
family: moby-dev family: moby-dev

View File

@ -122,7 +122,7 @@ func (g GCPClient) UploadFile(filename, bucketName string, public bool) error {
return nil return nil
} }
// CreateImage creates a GCE image using the a source from Google Storage // CreateImage creates a GCP image using the a source from Google Storage
func (g GCPClient) CreateImage(filename, storageURL, family string, replace bool) error { func (g GCPClient) CreateImage(filename, storageURL, family string, replace bool) error {
if replace { if replace {
if err := g.DeleteImage(filename); err != nil { if err := g.DeleteImage(filename); err != nil {
@ -174,7 +174,7 @@ func (g GCPClient) DeleteImage(filename string) error {
return nil return nil
} }
// CreateInstance creates and starts an instance on GCE // CreateInstance creates and starts an instance on GCP
func (g GCPClient) CreateInstance(image, zone, machineType string, replace bool) error { func (g GCPClient) CreateInstance(image, zone, machineType string, replace bool) error {
if replace { if replace {
if err := g.DeleteInstance(image, zone, true); err != nil { if err := g.DeleteInstance(image, zone, true); err != nil {

View File

@ -13,7 +13,7 @@ import (
const ( const (
bios = "mobylinux/mkimage-iso-bios:489b1f054a77a8f379d0bfc6cd91639b4db6b67c@sha256:0f058951aac4367d132682aa19eeb5cdcb05600a5d51fe5d0fcbd97b03ae4f87" bios = "mobylinux/mkimage-iso-bios:489b1f054a77a8f379d0bfc6cd91639b4db6b67c@sha256:0f058951aac4367d132682aa19eeb5cdcb05600a5d51fe5d0fcbd97b03ae4f87"
efi = "mobylinux/mkimage-iso-efi:1b0ea6b8a7956e67e903876be5baf476e9a5cc40@sha256:a026cd9e9d0146503274e575a165039c67b853bde0013ade78df80d9280ffa7c" efi = "mobylinux/mkimage-iso-efi:1b0ea6b8a7956e67e903876be5baf476e9a5cc40@sha256:a026cd9e9d0146503274e575a165039c67b853bde0013ade78df80d9280ffa7c"
gce = "mobylinux/mkimage-gce:2039be4e39e855d1845aee188e266bba3f1d2eed@sha256:e12f76003fd9eaa0c6f39f149db5998cf56de42539b989c994893c8344ca69c0" gcp = "mobylinux/mkimage-gcp:bd1197356ca69a4b79999cc56cb6d7dbac96723c@sha256:2a8c90214318f8da7f02066cc142add279a2e4772b26023961991d5fae3155ec"
qcow = "mobylinux/mkimage-qcow:9b3632f111675898ed3a22ac71897e735b5a8364@sha256:2132cf3fb593d65f09c8d109d40e1fad138d81485d4750fc29a7f54611d78d35" qcow = "mobylinux/mkimage-qcow:9b3632f111675898ed3a22ac71897e735b5a8364@sha256:2132cf3fb593d65f09c8d109d40e1fad138d81485d4750fc29a7f54611d78d35"
vhd = "mobylinux/mkimage-vhd:73c80e433bf717578c507621a84fd58cec27fe95@sha256:0ae1eda2d6592f309977dc4b25cca120cc4e2ee2cc786e88fdc2761c0d49cb14" vhd = "mobylinux/mkimage-vhd:73c80e433bf717578c507621a84fd58cec27fe95@sha256:0ae1eda2d6592f309977dc4b25cca120cc4e2ee2cc786e88fdc2761c0d49cb14"
vmdk = "mobylinux/mkimage-vmdk:1de360a30f3ac6a91d4eae1ae4611cea4b82f22a@sha256:d7e65edc6dd88f6e12dcb0d749d4c7e5793d1250e548b58c105dbfd082940787" vmdk = "mobylinux/mkimage-vmdk:1de360a30f3ac6a91d4eae1ae4611cea4b82f22a@sha256:d7e65edc6dd88f6e12dcb0d749d4c7e5793d1250e548b58c105dbfd082940787"
@ -38,18 +38,18 @@ func outputs(m *Moby, base string, bzimage []byte, initrd []byte) error {
if err != nil { if err != nil {
return fmt.Errorf("Error writing %s output: %v", o.Format, err) return fmt.Errorf("Error writing %s output: %v", o.Format, err)
} }
case "gce-img": case "gcp-img":
err := outputImg(gce, base+".img.tar.gz", bzimage, initrd, m.Kernel.Cmdline) err := outputImg(gcp, base+".img.tar.gz", bzimage, initrd, m.Kernel.Cmdline)
if err != nil { if err != nil {
return fmt.Errorf("Error writing %s output: %v", o.Format, err) return fmt.Errorf("Error writing %s output: %v", o.Format, err)
} }
case "gce-storage": case "gcp-storage":
err := outputImg(gce, base+".img.tar.gz", bzimage, initrd, m.Kernel.Cmdline) err := outputImg(gcp, base+".img.tar.gz", bzimage, initrd, m.Kernel.Cmdline)
if err != nil { if err != nil {
return fmt.Errorf("Error writing %s output: %v", o.Format, err) return fmt.Errorf("Error writing %s output: %v", o.Format, err)
} }
if o.Bucket == "" { if o.Bucket == "" {
return fmt.Errorf("No bucket specified for GCE output") return fmt.Errorf("No bucket specified for GCP output")
} }
gClient, err := NewGCPClient(o.Keys, o.Project) gClient, err := NewGCPClient(o.Keys, o.Project)
if err != nil { if err != nil {
@ -59,13 +59,13 @@ func outputs(m *Moby, base string, bzimage []byte, initrd []byte) error {
if err != nil { if err != nil {
return fmt.Errorf("Error copying to Google Storage: %v", err) return fmt.Errorf("Error copying to Google Storage: %v", err)
} }
case "gce": case "gcp":
err := outputImg(gce, base+".img.tar.gz", bzimage, initrd, m.Kernel.Cmdline) err := outputImg(gcp, base+".img.tar.gz", bzimage, initrd, m.Kernel.Cmdline)
if err != nil { if err != nil {
return fmt.Errorf("Error writing %s output: %v", o.Format, err) return fmt.Errorf("Error writing %s output: %v", o.Format, err)
} }
if o.Bucket == "" { if o.Bucket == "" {
return fmt.Errorf("No bucket specified for GCE output") return fmt.Errorf("No bucket specified for GCP output")
} }
gClient, err := NewGCPClient(o.Keys, o.Project) gClient, err := NewGCPClient(o.Keys, o.Project)
if err != nil { if err != nil {

View File

@ -14,6 +14,7 @@ func runUsage() {
fmt.Printf("'backend' specifies the run backend.\n") fmt.Printf("'backend' specifies the run backend.\n")
fmt.Printf("If not specified the platform specific default will be used\n") fmt.Printf("If not specified the platform specific default will be used\n")
fmt.Printf("Supported backends are (default platform in brackets):\n") fmt.Printf("Supported backends are (default platform in brackets):\n")
fmt.Printf(" gcp\n")
fmt.Printf(" hyperkit [macOS]\n") fmt.Printf(" hyperkit [macOS]\n")
fmt.Printf(" vmware\n") fmt.Printf(" vmware\n")
fmt.Printf("\n") fmt.Printf("\n")

View File

@ -15,18 +15,18 @@ func runGcp(args []string) {
gcpCmd.Usage = func() { gcpCmd.Usage = func() {
fmt.Printf("USAGE: %s run gcp [options] [name]\n\n", os.Args[0]) fmt.Printf("USAGE: %s run gcp [options] [name]\n\n", os.Args[0])
fmt.Printf("'name' specifies either the name of an already uploaded\n") fmt.Printf("'name' specifies either the name of an already uploaded\n")
fmt.Printf("GCE image or the full path to a image file which will be\n") fmt.Printf("GCP image or the full path to a image file which will be\n")
fmt.Printf("uploaded before it is run.\n\n") fmt.Printf("uploaded before it is run.\n\n")
fmt.Printf("Options:\n\n") fmt.Printf("Options:\n\n")
gcpCmd.PrintDefaults() gcpCmd.PrintDefaults()
} }
zone := gcpCmd.String("zone", "europe-west1-d", "GCP Zone") zone := gcpCmd.String("zone", "europe-west1-d", "GCP Zone")
machine := gcpCmd.String("machine", "g1-small", "GCE Machine Type") machine := gcpCmd.String("machine", "g1-small", "GCP Machine Type")
keys := gcpCmd.String("keys", "", "Path to Service Account JSON key file") keys := gcpCmd.String("keys", "", "Path to Service Account JSON key file")
project := gcpCmd.String("project", "", "GCP Project Name") project := gcpCmd.String("project", "", "GCP Project Name")
bucket := gcpCmd.String("bucket", "", "GS Bucket to upload to. *Required* when 'prefix' is a filename") bucket := gcpCmd.String("bucket", "", "GS Bucket to upload to. *Required* when 'prefix' is a filename")
public := gcpCmd.Bool("public", false, "Select if file on GS should be public. *Optional* when 'prefix' is a filename") public := gcpCmd.Bool("public", false, "Select if file on GS should be public. *Optional* when 'prefix' is a filename")
family := gcpCmd.String("family", "", "GCE Image Family. A group of images where the family name points to the most recent image. *Optional* when 'prefix' is a filename") family := gcpCmd.String("family", "", "GCP Image Family. A group of images where the family name points to the most recent image. *Optional* when 'prefix' is a filename")
gcpCmd.Parse(args) gcpCmd.Parse(args)
remArgs := gcpCmd.Args() remArgs := gcpCmd.Args()

View File

@ -30,4 +30,4 @@ outputs:
- format: kernel+initrd - format: kernel+initrd
- format: iso-bios - format: iso-bios
- format: iso-efi - format: iso-efi
- format: gce-img - format: gcp-img

View File

@ -2,4 +2,4 @@ FROM mobylinux/guestfs:69698aca5bfcb8c4d3a3bbe6d8656be155bf8cd6@sha256:703a7372a
COPY . . COPY . .
ENTRYPOINT [ "/make-gce" ] ENTRYPOINT [ "/make-gcp" ]

View File

@ -1,10 +1,10 @@
.PHONY: tag push .PHONY: tag push
IMAGE=mkimage-gce IMAGE=mkimage-gcp
default: push default: push
hash: Dockerfile make-gce hash: Dockerfile make-gcp
tar cf - $^ | docker build --no-cache -t $(IMAGE):build - tar cf - $^ | docker build --no-cache -t $(IMAGE):build -
docker run --entrypoint sh --rm $(IMAGE):build -c "(cat $^; apt list --installed 2>/dev/null) | sha1sum" | sed 's/ .*//' > hash docker run --entrypoint sh --rm $(IMAGE):build -c "(cat $^; apt list --installed 2>/dev/null) | sha1sum" | sed 's/ .*//' > hash

View File

@ -26,8 +26,8 @@ CMDLINE="$*"
# clean up subdirectories # clean up subdirectories
find . -mindepth 1 -maxdepth 1 -type d | xargs rm -rf find . -mindepth 1 -maxdepth 1 -type d | xargs rm -rf
# should be externally provided as GCE specific # should be externally provided as GCP specific
GCE_CONFIG="earlyprintk=ttyS0,115200 console=ttyS0,115200 mobyplatform=gcp vsyscall=emulate page_poison=1" GCP_CONFIG="earlyprintk=ttyS0,115200 console=ttyS0,115200 vsyscall=emulate page_poison=1"
CFG="DEFAULT linux CFG="DEFAULT linux
LABEL linux LABEL linux