mirror of
https://github.com/containrrr/watchtower.git
synced 2025-09-22 05:40:50 +02:00
some linting
This commit is contained in:
parent
1f10817b4b
commit
d0ac9f14ab
5 changed files with 23 additions and 35 deletions
|
@ -216,10 +216,9 @@ func (client dockerClient) IsContainerStale(c Container) (bool, error) {
|
||||||
if newImageInfo.ID != oldImageInfo.ID {
|
if newImageInfo.ID != oldImageInfo.ID {
|
||||||
log.Infof("Found new %s image (%s)", imageName, newImageInfo.ID)
|
log.Infof("Found new %s image (%s)", imageName, newImageInfo.ID)
|
||||||
return true, nil
|
return true, nil
|
||||||
} 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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -155,7 +155,7 @@ func (c Container) runtimeConfig() *dockercontainer.Config {
|
||||||
config.Volumes = structMapSubtract(config.Volumes, imageConfig.Volumes)
|
config.Volumes = structMapSubtract(config.Volumes, imageConfig.Volumes)
|
||||||
|
|
||||||
// subtract ports exposed in image from container
|
// subtract ports exposed in image from container
|
||||||
for k, _ := range config.ExposedPorts {
|
for k := range config.ExposedPorts {
|
||||||
if _, ok := imageConfig.ExposedPorts[k]; ok {
|
if _, ok := imageConfig.ExposedPorts[k]; ok {
|
||||||
delete(config.ExposedPorts, k)
|
delete(config.ExposedPorts, k)
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,10 +26,11 @@ func TestNoFilter(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFilterByNames(t *testing.T) {
|
func TestFilterByNames(t *testing.T) {
|
||||||
filter := filterByNames(make([]string, 0), nil)
|
var names []string
|
||||||
|
|
||||||
|
filter := filterByNames(names, nil)
|
||||||
assert.Nil(t, filter)
|
assert.Nil(t, filter)
|
||||||
|
|
||||||
names := make([]string, 0)
|
|
||||||
names = append(names, "test")
|
names = append(names, "test")
|
||||||
|
|
||||||
filter = filterByNames(names, noFilter)
|
filter = filterByNames(names, noFilter)
|
||||||
|
@ -87,7 +88,7 @@ func TestFilterByDisabledLabel(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBuildFilter(t *testing.T) {
|
func TestBuildFilter(t *testing.T) {
|
||||||
names := make([]string, 0)
|
var names []string
|
||||||
names = append(names, "test")
|
names = append(names, "test")
|
||||||
|
|
||||||
filter := BuildFilter(names, false)
|
filter := BuildFilter(names, false)
|
||||||
|
@ -123,7 +124,7 @@ func TestBuildFilter(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestBuildFilterEnableLabel(t *testing.T) {
|
func TestBuildFilterEnableLabel(t *testing.T) {
|
||||||
names := make([]string, 0)
|
var names []string
|
||||||
names = append(names, "test")
|
names = append(names, "test")
|
||||||
|
|
||||||
filter := BuildFilter(names, true)
|
filter := BuildFilter(names, true)
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
// Code generated by mockery v1.0.0
|
|
||||||
package mocks
|
package mocks
|
||||||
|
|
||||||
import mock "github.com/stretchr/testify/mock"
|
import mock "github.com/stretchr/testify/mock"
|
||||||
|
|
|
@ -5,20 +5,18 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"github.com/docker/docker/api/types"
|
"github.com/docker/docker/api/types"
|
||||||
"github.com/docker/docker/api/types/reference"
|
"github.com/docker/docker/api/types/reference"
|
||||||
"github.com/docker/docker/cli/command"
|
"github.com/docker/docker/cli/command"
|
||||||
"github.com/docker/docker/cliconfig"
|
"github.com/docker/docker/cliconfig"
|
||||||
"github.com/docker/docker/cliconfig/configfile"
|
"github.com/docker/docker/cliconfig/configfile"
|
||||||
"github.com/docker/docker/cliconfig/credentials"
|
"github.com/docker/docker/cliconfig/credentials"
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
/**
|
// EncodedAuth returns an encoded auth config for the given registry
|
||||||
* Return an encoded auth config for the given registry
|
// loaded from environment variables or docker config
|
||||||
* loaded from environment variables or docker config
|
// as available in that order
|
||||||
* as available in that order
|
|
||||||
*/
|
|
||||||
func EncodedAuth(ref string) (string, error) {
|
func EncodedAuth(ref string) (string, error) {
|
||||||
auth, err := EncodedEnvAuth(ref)
|
auth, err := EncodedEnvAuth(ref)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -27,11 +25,9 @@ func EncodedAuth(ref string) (string, error) {
|
||||||
return auth, err
|
return auth, err
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// EncodedEnvAuth returns an encoded auth config for the given registry
|
||||||
* Return an encoded auth config for the given registry
|
// loaded from environment variables
|
||||||
* loaded from environment variables
|
// Returns an error if authentication environment variables have not been set
|
||||||
* Returns an error if authentication environment variables have not been set
|
|
||||||
*/
|
|
||||||
func EncodedEnvAuth(ref string) (string, error) {
|
func EncodedEnvAuth(ref string) (string, error) {
|
||||||
username := os.Getenv("REPO_USER")
|
username := os.Getenv("REPO_USER")
|
||||||
password := os.Getenv("REPO_PASS")
|
password := os.Getenv("REPO_PASS")
|
||||||
|
@ -42,17 +38,14 @@ func EncodedEnvAuth(ref string) (string, error) {
|
||||||
}
|
}
|
||||||
log.Debugf("Loaded auth credentials %s for %s", auth, ref)
|
log.Debugf("Loaded auth credentials %s for %s", auth, ref)
|
||||||
return EncodeAuth(auth)
|
return EncodeAuth(auth)
|
||||||
} else {
|
|
||||||
return "", errors.New("Registry auth environment variables (REPO_USER, REPO_PASS) not set")
|
|
||||||
}
|
}
|
||||||
|
return "", errors.New("Registry auth environment variables (REPO_USER, REPO_PASS) not set")
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// EncodedConfigAuth returns an encoded auth config for the given registry
|
||||||
* Return an encoded auth config for the given registry
|
// loaded from the docker config
|
||||||
* loaded from the docker config
|
// Returns an empty string if credentials cannot be found for the referenced server
|
||||||
* Returns an empty string if credentials cannot be found for the referenced server
|
// The docker config must be mounted on the container
|
||||||
* The docker config must be mounted on the container
|
|
||||||
*/
|
|
||||||
func EncodedConfigAuth(ref string) (string, error) {
|
func EncodedConfigAuth(ref string) (string, error) {
|
||||||
server, err := ParseServerAddress(ref)
|
server, err := ParseServerAddress(ref)
|
||||||
configDir := os.Getenv("DOCKER_CONFIG")
|
configDir := os.Getenv("DOCKER_CONFIG")
|
||||||
|
@ -92,18 +85,14 @@ func CredentialsStore(configFile configfile.ConfigFile) credentials.Store {
|
||||||
return credentials.NewFileStore(&configFile)
|
return credentials.NewFileStore(&configFile)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
// EncodeAuth Base64 encode an AuthConfig struct for transmission over HTTP
|
||||||
* Base64 encode an AuthConfig struct for transmission over HTTP
|
|
||||||
*/
|
|
||||||
func EncodeAuth(auth types.AuthConfig) (string, error) {
|
func EncodeAuth(auth types.AuthConfig) (string, error) {
|
||||||
return command.EncodeAuthToBase64(auth)
|
return command.EncodeAuthToBase64(auth)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// DefaultAuthHandler will be invoked if an AuthConfig is rejected
|
||||||
* This function will be invoked if an AuthConfig is rejected
|
// It could be used to return a new value for the "X-Registry-Auth" authentication header,
|
||||||
* It could be used to return a new value for the "X-Registry-Auth" authentication header,
|
// but there's no point trying again with the same value as used in AuthConfig
|
||||||
* but there's no point trying again with the same value as used in AuthConfig
|
|
||||||
*/
|
|
||||||
func DefaultAuthHandler() (string, error) {
|
func DefaultAuthHandler() (string, error) {
|
||||||
log.Debug("Authentication request was rejected. Trying again without authentication")
|
log.Debug("Authentication request was rejected. Trying again without authentication")
|
||||||
return "", nil
|
return "", nil
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue