func (cloud GCECloud) GetPublicIPAddress(name string, zone string) (string, error) {
	instance, err := cloud.service.Instances.Get(cloud.projectId, zone, name).Do()
	if err != nil {
		return "", err
	}
	return instance.NetworkInterfaces[0].AccessConfigs[0].NatIP, nil
}
Implementation of the Cloud interface
package dockercloud
import (
	"encoding/json"
	"errors"
	"flag"
	"fmt"
	"io/ioutil"
	"log"
	"net/http"
	"os"
	"os/exec"
	"os/user"
	"path"
	"strings"
	"time"
	"code.google.com/p/goauth2/oauth"
	compute "code.google.com/p/google-api-go-client/compute/v1"
)
var (
	gceDefaultClientID     = "676599397109-0te3n95co16j9mkinnq6vdhphp4nnd06.apps.googleusercontent.com"
	gceDefaultClientSecret = "JnMnI5z9iH7YItv_jy_TZ1Hg"
	gceDefaultScope        = "https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/compute https://www.googleapis.com/auth/devstorage.read_write"
	gceInstanceType = flag.String("instancetype",
		"/zones/us-central1-a/machineTypes/n1-standard-1",
		"The reference to the instance type to create.")
	gceImage = flag.String("image",
		"https://www.googleapis.com/compute/v1/projects/debian-cloud/global/images/backports-debian-7-wheezy-v20131127",
		"The GCE image to boot from.")
	gceDiskName   = flag.String("diskname", "docker-root", "Name of the instance root disk")
	gceDiskSizeGb = flag.Int64("disksize", 100, "Size of the root disk in GB")
)
const startup = `#!/bin/bash
sysctl -w net.ipv4.ip_forward=1
wget -qO- https: 
until test -f /var/run/docker.pid; do sleep 1 && echo waiting; done
grep mtu /etc/default/docker || (echo 'DOCKER_OPTS="-H :8000 -mtu 1460"' >> /etc/default/docker)
service docker restart
until echo 'GET /' >/dev/tcp/localhost/8000; do sleep 1 && echo waiting; done
`
type GCECloud struct {
	service   *compute.Service
	projectId string
}
type gcloudCredentialsCache struct {
	Data []gceConfig
}
type gceConfig struct {
	Credential gceCredential
	Key        gceKey
	ProjectId  string `json:"projectId"`
}
type gceCredential struct {
	ClientId     string `json:"Client_Id"`
	ClientSecret string `json:"Client_Secret"`
	RefreshToken string `json:"Refresh_Token"`
}
type gceKey struct {
	Scope string
}
func gceConfAbsPath() (string, error) {
	usr, err := user.Current()
	if err != nil {
		return "", err
	}
	return path.Join(usr.HomeDir, "docker-cloud.json"), nil
}
func gcloudConfAbsPath() (string, error) {
	usr, err := user.Current()
	if err != nil {
		return "", err
	}
	return path.Join(usr.HomeDir, ".config/gcloud/credentials"), nil
}
func (conf *gceConfig) Read() (err error) {
	if err = conf.readDockerCloud(); err == nil {
		return
	}
	if err = conf.readGCloud(); err == nil {
		return
	}
	return
}
func (conf *gceConfig) readDockerCloud() (err error) {
	confPath, err := gceConfAbsPath()
	if err != nil {
		return
	}
	var data []byte
	if data, err = ioutil.ReadFile(confPath); err != nil {
		return
	}
	err = json.Unmarshal(data, conf)
	return
}
func (conf *gceConfig) readGCloud() error {
	confPath, err := gcloudConfAbsPath()
	if err != nil {
		return err
	}
	f, err := os.Open(confPath)
	if err != nil {
		return fmt.Errorf("unable to load gcloud credentials: %q", confPath)
	}
	defer f.Close()
	cache := &gcloudCredentialsCache{}
	if err := json.NewDecoder(f).Decode(cache); err != nil {
		return err
	}
	if len(cache.Data) == 0 {
		return fmt.Errorf("no gcloud credentials cached in: %q", confPath)
	}
	*conf = cache.Data[0]
	return nil
}
func (conf *gceConfig) Write() error {
	confPath, err := gceConfAbsPath()
	if err != nil {
		return err
	}
	var data []byte
	if data, err = json.Marshal(conf); err != nil {
		return err
	}
	return ioutil.WriteFile(confPath, data, 0644)
}
func NewCloudGCE(projectId string) (cloud *GCECloud, err error) {
	conf := &gceConfig{}
	if err = conf.Read(); err != nil || conf.Credential.RefreshToken == "" {
		return nil, errors.New("Did you authorize the client? Run `docker-cloud auth`.")
	}
	if projectId == "" {
		if conf.ProjectId == "" {
			return nil, errors.New("Did you define project id? Run `docker-cloud start -project=<project-id>`")
		}
		projectId = conf.ProjectId
	}
	oAuth2Conf := newGCEOAuth2Config(conf.Credential.ClientId, conf.Credential.ClientSecret, conf.Key.Scope)
	transport := &oauth.Transport{
		Config: oAuth2Conf,
		Token:     &oauth.Token{RefreshToken: conf.Credential.RefreshToken},
		Transport: http.DefaultTransport,
	}
	err = transport.Refresh()
	if err != nil {
		return
	}
	svc, err := compute.New(transport.Client())
	if err != nil {
		return
	}
	return &GCECloud{
		service:   svc,
		projectId: projectId,
	}, nil
}