some linting

pull/173/head
Fabrizio Steiner 6 years ago
parent 1f10817b4b
commit d0ac9f14ab

@ -216,10 +216,9 @@ func (client dockerClient) IsContainerStale(c Container) (bool, error) {
if newImageInfo.ID != oldImageInfo.ID {
log.Infof("Found new %s image (%s)", imageName, newImageInfo.ID)
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
}

@ -155,7 +155,7 @@ func (c Container) runtimeConfig() *dockercontainer.Config {
config.Volumes = structMapSubtract(config.Volumes, imageConfig.Volumes)
// subtract ports exposed in image from container
for k, _ := range config.ExposedPorts {
for k := range config.ExposedPorts {
if _, ok := imageConfig.ExposedPorts[k]; ok {
delete(config.ExposedPorts, k)
}

@ -26,10 +26,11 @@ func TestNoFilter(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)
names := make([]string, 0)
names = append(names, "test")
filter = filterByNames(names, noFilter)
@ -87,7 +88,7 @@ func TestFilterByDisabledLabel(t *testing.T) {
}
func TestBuildFilter(t *testing.T) {
names := make([]string, 0)
var names []string
names = append(names, "test")
filter := BuildFilter(names, false)
@ -123,7 +124,7 @@ func TestBuildFilter(t *testing.T) {
}
func TestBuildFilterEnableLabel(t *testing.T) {
names := make([]string, 0)
var names []string
names = append(names, "test")
filter := BuildFilter(names, true)

@ -1,4 +1,3 @@
// Code generated by mockery v1.0.0
package mocks
import mock "github.com/stretchr/testify/mock"

@ -5,20 +5,18 @@ import (
"os"
"strings"
log "github.com/sirupsen/logrus"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/reference"
"github.com/docker/docker/cli/command"
"github.com/docker/docker/cliconfig"
"github.com/docker/docker/cliconfig/configfile"
"github.com/docker/docker/cliconfig/credentials"
log "github.com/sirupsen/logrus"
)
/**
* Return an encoded auth config for the given registry
* loaded from environment variables or docker config
* as available in that order
*/
// EncodedAuth returns an encoded auth config for the given registry
// loaded from environment variables or docker config
// as available in that order
func EncodedAuth(ref string) (string, error) {
auth, err := EncodedEnvAuth(ref)
if err != nil {
@ -27,11 +25,9 @@ func EncodedAuth(ref string) (string, error) {
return auth, err
}
/*
* Return an encoded auth config for the given registry
* loaded from environment variables
* Returns an error if authentication environment variables have not been set
*/
// EncodedEnvAuth returns an encoded auth config for the given registry
// loaded from environment variables
// Returns an error if authentication environment variables have not been set
func EncodedEnvAuth(ref string) (string, error) {
username := os.Getenv("REPO_USER")
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)
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")
}
/*
* Return an encoded auth config for the given registry
* loaded from the docker config
* Returns an empty string if credentials cannot be found for the referenced server
* The docker config must be mounted on the container
*/
// EncodedConfigAuth returns an encoded auth config for the given registry
// loaded from the docker config
// Returns an empty string if credentials cannot be found for the referenced server
// The docker config must be mounted on the container
func EncodedConfigAuth(ref string) (string, error) {
server, err := ParseServerAddress(ref)
configDir := os.Getenv("DOCKER_CONFIG")
@ -92,18 +85,14 @@ func CredentialsStore(configFile configfile.ConfigFile) credentials.Store {
return credentials.NewFileStore(&configFile)
}
/*
* Base64 encode an AuthConfig struct for transmission over HTTP
*/
// EncodeAuth Base64 encode an AuthConfig struct for transmission over HTTP
func EncodeAuth(auth types.AuthConfig) (string, error) {
return command.EncodeAuthToBase64(auth)
}
/**
* 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,
* but there's no point trying again with the same value as used in AuthConfig
*/
// DefaultAuthHandler will be invoked if an AuthConfig is rejected
// 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
func DefaultAuthHandler() (string, error) {
log.Debug("Authentication request was rejected. Trying again without authentication")
return "", nil

Loading…
Cancel
Save