Skip to content

Commit

Permalink
Merge pull request #17 from wharfr/env-create
Browse files Browse the repository at this point in the history
Ensure containers are running when creating environments
  • Loading branch information
qur committed Oct 5, 2019
2 parents d4a9526 + 8a2c007 commit 758a2a5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 3 additions & 1 deletion lib/cmd/wharfrat/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"wharfr.at/wharfrat/lib/docker"
"wharfr.at/wharfrat/lib/docker/label"
"wharfr.at/wharfrat/lib/vc"
"wharfr.at/wharfrat/lib/version"
)

type List struct {
Expand Down Expand Up @@ -131,6 +132,7 @@ func (l *List) Execute(args []string) error {
crateName := container.Labels[label.Crate]
cfg := container.Labels[label.Config]
branch := container.Labels[label.Branch]
commit := container.Labels[label.Commit]

name := container.Names[0]
if strings.HasPrefix(name, "/") {
Expand Down Expand Up @@ -179,7 +181,7 @@ func (l *List) Execute(args []string) error {
crateState := green
if crate == nil {
crateState = red
} else if crate.Json() != cfg {
} else if crate.Json() != cfg || version.Commit() != commit {
crateState = amber
}

Expand Down
10 changes: 4 additions & 6 deletions lib/venv/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,12 @@ func newState(path, project string, crates []string, c *docker.Connection) (*sta
return nil, fmt.Errorf("Config error: %s", err)
}
log.Printf("Crate: %#v", crate)
container, err := c.GetContainer(crate.ContainerName())
id, err := c.EnsureRunning(crate, false, true)
if err != nil {
return nil, fmt.Errorf("Failed to get docker container: %s", err)
return nil, fmt.Errorf("Failed to get running container: %s", err)
}
if container != nil {
if err := s.Update(c, container.ID, crate, "", "", nil); err != nil {
return nil, fmt.Errorf("failed to update exported binaries: %s", err)
}
if err := s.Update(c, id, crate, "", "", nil); err != nil {
return nil, fmt.Errorf("failed to update exported binaries: %s", err)
}
}
return s, nil
Expand Down

0 comments on commit 758a2a5

Please sign in to comment.