fix linting and formatting

This commit is contained in:
Simon Aronsson 2020-04-24 13:45:24 +02:00
parent 00715e4633
commit 4672811983
7 changed files with 30 additions and 31 deletions

View file

@ -8,8 +8,8 @@ import (
"github.com/containrrr/watchtower/pkg/container" "github.com/containrrr/watchtower/pkg/container"
"github.com/containrrr/watchtower/pkg/container/mocks" "github.com/containrrr/watchtower/pkg/container/mocks"
cli "github.com/docker/docker/client"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
cli "github.com/docker/docker/client"
. "github.com/containrrr/watchtower/internal/actions/mocks" . "github.com/containrrr/watchtower/internal/actions/mocks"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"

View file

@ -56,6 +56,7 @@ func (client MockClient) StopContainer(c container.Container, d time.Duration) e
func (client MockClient) StartContainer(c container.Container) (string, error) { func (client MockClient) StartContainer(c container.Container) (string, error) {
return "", nil return "", nil
} }
// RenameContainer is a mock method // RenameContainer is a mock method
func (client MockClient) RenameContainer(c container.Container, s string) error { func (client MockClient) RenameContainer(c container.Container, s string) error {
return nil return nil
@ -81,4 +82,3 @@ func (client MockClient) ExecuteCommand(containerID string, command string, time
func (client MockClient) IsContainerStale(c container.Container) (bool, error) { func (client MockClient) IsContainerStale(c container.Container) (bool, error) {
return true, nil return true, nil
} }

View file

@ -13,7 +13,6 @@ import (
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
) )
var _ = Describe("the update action", func() { var _ = Describe("the update action", func() {
var dockerClient cli.CommonAPIClient var dockerClient cli.CommonAPIClient
var client MockClient var client MockClient
@ -25,7 +24,6 @@ var _ = Describe("the update action", func() {
cli.WithHTTPClient(server.Client())) cli.WithHTTPClient(server.Client()))
}) })
When("watchtower has been instructed to clean up", func() { When("watchtower has been instructed to clean up", func() {
BeforeEach(func() { BeforeEach(func() {
pullImages := false pullImages := false

View file

@ -1,11 +1,12 @@
package api package api
import ( import (
"os"
"net/http"
"errors" "errors"
log "github.com/sirupsen/logrus"
"io" "io"
"net/http"
"os"
log "github.com/sirupsen/logrus"
) )
var ( var (
@ -17,9 +18,10 @@ func init() {
lock <- true lock <- true
} }
// SetupHTTPUpdates configures the endopint needed for triggering updates via http
func SetupHTTPUpdates(apiToken string, updateFunction func()) error { func SetupHTTPUpdates(apiToken string, updateFunction func()) error {
if apiToken == "" { if apiToken == "" {
return errors.New("API token is empty or has not been set. Not starting API.") return errors.New("api token is empty or has not been set. not starting api")
} }
log.Println("Watchtower HTTP API started.") log.Println("Watchtower HTTP API started.")
@ -48,12 +50,12 @@ func SetupHTTPUpdates(apiToken string, updateFunction func()) error {
log.Debug("Skipped. Another update already running.") log.Debug("Skipped. Another update already running.")
} }
}) })
return nil return nil
} }
// WaitForHTTPUpdates starts the http server and listens for requests.
func WaitForHTTPUpdates() error { func WaitForHTTPUpdates() error {
log.Fatal(http.ListenAndServe(":8080", nil)) log.Fatal(http.ListenAndServe(":8080", nil))
os.Exit(0) os.Exit(0)

View file

@ -88,4 +88,3 @@ func ExecutePostUpdateCommand(client container.Client, newContainerID string) {
log.Error(err) log.Error(err)
} }
} }