Go fmt the cloud backend

Docker-DCO-1.1-Signed-off-by: Ben Firshman <ben@firshman.co.uk> (github: bfirsh)
This commit is contained in:
Ben Firshman 2014-05-23 16:28:12 +01:00
parent a3f701dbf6
commit fd9c7c9cfa
2 changed files with 25 additions and 25 deletions

View File

@ -52,19 +52,19 @@ type cloud struct {
}
type Container struct {
Id string
Id string
Image string
Tty bool
Tty bool
}
// returns true, if the connection was successful, false otherwise
type Tunnel struct {
url.URL
url.URL
}
func (t Tunnel) isActive() bool {
_, err := http.Get(t.String())
return err == nil
_, err := http.Get(t.String())
return err == nil
}
func (s *cloud) Install(eng *engine.Engine) error {
@ -91,7 +91,7 @@ func (s *cloud) Install(eng *engine.Engine) error {
ip, err := cloud.GetPublicIPAddress(instance, zone)
instanceRunning := len(ip) > 0
if !instanceRunning {
log.Print("Instance doesn't exist, creating....");
log.Print("Instance doesn't exist, creating....")
_, err = cloud.CreateInstance(instance, zone)
}
if err != nil {
@ -101,17 +101,17 @@ func (s *cloud) Install(eng *engine.Engine) error {
localPort := 8001
apiVersion := "v1.10"
tunnelUrl, err := url.Parse(fmt.Sprintf("http://localhost:%d/%s/containers/json", localPort, apiVersion))
if err != nil {
return job.Errorf("Unexpected error: %#v", err)
}
tunnel := Tunnel{*tunnelUrl}
if err != nil {
return job.Errorf("Unexpected error: %#v", err)
}
tunnel := Tunnel{*tunnelUrl}
if !tunnel.isActive() {
fmt.Printf("Creating tunnel")
_, err = cloud.OpenSecureTunnel(instance, zone, localPort, remotePort)
if err != nil {
job.Errorf("Failed to open tunnel: %#v", err)
}
if !tunnel.isActive() {
fmt.Printf("Creating tunnel")
_, err = cloud.OpenSecureTunnel(instance, zone, localPort, remotePort)
if err != nil {
job.Errorf("Failed to open tunnel: %#v", err)
}
}
host := fmt.Sprintf("tcp://localhost:%d", localPort)
client, err := newClient(host, apiVersion)
@ -123,7 +123,7 @@ func (s *cloud) Install(eng *engine.Engine) error {
job.Eng.Register("create", func(job *engine.Job) engine.Status {
container := Container{
Image: job.Getenv("Image"),
Tty: job.Getenv("Tty") == "true",
Tty: job.Getenv("Tty") == "true",
}
data, err := json.Marshal(container)
resp, err := client.call("POST", "/containers/create", string(data))