Skip to content

Commit

Permalink
push image instead of commiting sidecar for img deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
andrestc committed Apr 16, 2018
1 parent d2542ee commit e5c4c40
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
10 changes: 5 additions & 5 deletions deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
7 changes: 7 additions & 0 deletions internal/tsuru/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down
15 changes: 9 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,21 +64,24 @@ 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
// destination images based on the sidecar container.
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{
Expand Down

0 comments on commit e5c4c40

Please sign in to comment.