go fmt...

pull/40/head^2
Fabrizio Steiner 8 years ago
parent 6a72ba24c9
commit eda5391d0a

@ -4,8 +4,8 @@ import (
"math/rand" "math/rand"
"time" "time"
"github.com/v2tec/watchtower/container"
log "github.com/Sirupsen/logrus" log "github.com/Sirupsen/logrus"
"github.com/v2tec/watchtower/container"
) )
var ( var (

@ -2,12 +2,12 @@ package container
import ( import (
"fmt" "fmt"
"time"
"io/ioutil" "io/ioutil"
"time"
log "github.com/Sirupsen/logrus" log "github.com/Sirupsen/logrus"
dockerclient "github.com/docker/docker/client"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
dockerclient "github.com/docker/docker/client"
"golang.org/x/net/context" "golang.org/x/net/context"
) )
@ -76,7 +76,7 @@ func (client dockerClient) ListContainers(fn Filter) ([]Container, error) {
} }
c := Container{containerInfo: &containerInfo, imageInfo: &imageInfo} c := Container{containerInfo: &containerInfo, imageInfo: &imageInfo}
if (fn(c)) { if fn(c) {
cs = append(cs, c) cs = append(cs, c)
} }
} }
@ -115,7 +115,7 @@ func (client dockerClient) StopContainer(c Container, timeout time.Duration) err
} }
func (client dockerClient) StartContainer(c Container) error { func (client dockerClient) StartContainer(c Container) error {
bg := context.Background(); bg := context.Background()
config := c.runtimeConfig() config := c.runtimeConfig()
hostConfig := c.hostConfig() hostConfig := c.hostConfig()
name := c.Name() name := c.Name()
@ -144,7 +144,7 @@ func (client dockerClient) IsContainerStale(c Container) (bool, error) {
if client.pullImages { if client.pullImages {
log.Debugf("Pulling %s for %s", imageName, c.Name()) log.Debugf("Pulling %s for %s", imageName, c.Name())
var opts types.ImagePullOptions // ImagePullOptions can take a RegistryAuth arg to authenticate against a private registry var opts types.ImagePullOptions // ImagePullOptions can take a RegistryAuth arg to authenticate against a private registry
auth, err := EncodedAuth(imageName) auth, err := EncodedAuth(imageName)
if err != nil { if err != nil {
@ -163,7 +163,7 @@ func (client dockerClient) IsContainerStale(c Container) (bool, error) {
return false, err return false, err
} }
defer response.Close() defer response.Close()
// the pull request will be aborted prematurely unless the response is read // the pull request will be aborted prematurely unless the response is read
_, err = ioutil.ReadAll(response) _, err = ioutil.ReadAll(response)
} }
@ -179,7 +179,6 @@ func (client dockerClient) IsContainerStale(c Container) (bool, error) {
} else { } else {
log.Debugf("No new images found for %s", c.Name()) log.Debugf("No new images found for %s", c.Name())
} }
return false, nil return false, nil
} }

@ -3,8 +3,8 @@ package mockclient
import ( import (
"time" "time"
"github.com/v2tec/watchtower/container"
"github.com/stretchr/testify/mock" "github.com/stretchr/testify/mock"
"github.com/v2tec/watchtower/container"
) )
type MockClient struct { type MockClient struct {

@ -1,8 +1,5 @@
package container package container
import (
)
func sliceEqual(s1, s2 []string) bool { func sliceEqual(s1, s2 []string) bool {
if len(s1) != len(s2) { if len(s1) != len(s2) {
return false return false
@ -65,4 +62,3 @@ func structMapSubtract(m1, m2 map[string]struct{}) map[string]struct{} {
return m return m
} }

@ -63,4 +63,3 @@ func TestStructMapSubtract(t *testing.T) {
assert.Equal(t, map[string]struct{}{"a": x, "b": x, "c": x}, m1) assert.Equal(t, map[string]struct{}{"a": x, "b": x, "c": x}, m1)
assert.Equal(t, map[string]struct{}{"a": x, "c": x}, m2) assert.Equal(t, map[string]struct{}{"a": x, "c": x}, m2)
} }

Loading…
Cancel
Save