diff --git a/deploy.go b/deploy.go index dee63a8..4eba255 100644 --- a/deploy.go +++ b/deploy.go @@ -139,14 +139,14 @@ func inspect(dockerClient *docker.Client, image string, filesystem Filesystem, w } break } - m := map[string]interface{}{ - "image": imgInspect, - "tsuruYaml": tsuruYaml, - "procfile": procfile, + m := tsuru.InspectData{ + TsuruYaml: tsuruYaml, + Image: imgInspect, + Procfile: procfile, } err = json.NewEncoder(w).Encode(m) if err != nil { - return fmt.Errorf("failed to encode inspected data: %v", err) + return fmt.Errorf("failed to encode inspected data %v: %v", m, err) } return nil } diff --git a/internal/tsuru/client.go b/internal/tsuru/client.go index 7e92541..4365589 100644 --- a/internal/tsuru/client.go +++ b/internal/tsuru/client.go @@ -15,9 +15,16 @@ import ( "strings" "time" + "github.com/tsuru/deploy-agent/internal/docker" "github.com/tsuru/tsuru/app/bind" ) +type InspectData struct { + Image docker.ImageInspect + TsuruYaml interface{} + Procfile string +} + type TsuruYaml struct { Hooks Hook `json:"hooks,omitempty"` Processes map[string]string `json:"processes,omitempty"` diff --git a/main.go b/main.go index 04ba346..bd51c18 100644 --- a/main.go +++ b/main.go @@ -64,12 +64,6 @@ func main() { } executor = sideCar filesystem = &executorFS{executor: sideCar} - - // we defer the call to pushSidecar so the normal build/deploy steps are executed - // by the sidecar executor. This will only be executed if those steps finish without - // any error since the call to fatal() exits. - defer pushSidecar(dockerClient, sideCar, config, os.Stdout) - if config.SourceImage != "" { // build/deploy/deploy-only is not required since this is an image deploy // all we need to do is return the inspected files and image and push the @@ -77,8 +71,17 @@ func main() { if err := inspect(dockerClient, config.SourceImage, filesystem, os.Stdout, os.Stderr); err != nil { fatalf("error inspecting sidecar: %v", err) } + + if err := tagAndPushDestinations(dockerClient, config.SourceImage, config, os.Stdout); err != nil { + fatalf("error pushing images: %v", err) + } return } + + // we defer the call to pushSidecar so the normal build/deploy steps are executed + // by the sidecar executor. This will only be executed if those steps finish without + // any error since the call to fatal() exits. + defer pushSidecar(dockerClient, sideCar, config, os.Stdout) } c := tsuru.Client{