summaryrefslogtreecommitdiff
path: root/vendor/github.com/fsouza/go-dockerclient/auth.go
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2019-06-24 11:29:13 +0200
committerValentin Rothberg <rothberg@redhat.com>2019-06-24 13:20:59 +0200
commitd697456dc90adbaf68224ed7c115b38d5855e582 (patch)
tree5fd88c48b34e7bead0028fa97e39f43f03880642 /vendor/github.com/fsouza/go-dockerclient/auth.go
parenta3211b73c62a9fcc13f09305bf629ef507b26d34 (diff)
downloadpodman-d697456dc90adbaf68224ed7c115b38d5855e582.tar.gz
podman-d697456dc90adbaf68224ed7c115b38d5855e582.tar.bz2
podman-d697456dc90adbaf68224ed7c115b38d5855e582.zip
migrate to go-modules
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'vendor/github.com/fsouza/go-dockerclient/auth.go')
-rw-r--r--vendor/github.com/fsouza/go-dockerclient/auth.go28
1 files changed, 26 insertions, 2 deletions
diff --git a/vendor/github.com/fsouza/go-dockerclient/auth.go b/vendor/github.com/fsouza/go-dockerclient/auth.go
index 4335d6e06..e7de97701 100644
--- a/vendor/github.com/fsouza/go-dockerclient/auth.go
+++ b/vendor/github.com/fsouza/go-dockerclient/auth.go
@@ -18,7 +18,7 @@ import (
)
// ErrCannotParseDockercfg is the error returned by NewAuthConfigurations when the dockercfg cannot be parsed.
-var ErrCannotParseDockercfg = errors.New("Failed to read authentication from dockercfg")
+var ErrCannotParseDockercfg = errors.New("failed to read authentication from dockercfg")
// AuthConfiguration represents authentication options to use in the PushImage
// method. It represents the authentication in the Docker index server.
@@ -37,16 +37,40 @@ type AuthConfiguration struct {
RegistryToken string `json:"registrytoken,omitempty"`
}
+func (c AuthConfiguration) isEmpty() bool {
+ return c == AuthConfiguration{}
+}
+
+func (c AuthConfiguration) headerKey() string {
+ return "X-Registry-Auth"
+}
+
// AuthConfigurations represents authentication options to use for the
// PushImage method accommodating the new X-Registry-Config header
type AuthConfigurations struct {
Configs map[string]AuthConfiguration `json:"configs"`
}
+func (c AuthConfigurations) isEmpty() bool {
+ return len(c.Configs) == 0
+}
+
+func (c AuthConfigurations) headerKey() string {
+ return "X-Registry-Config"
+}
+
// AuthConfigurations119 is used to serialize a set of AuthConfigurations
// for Docker API >= 1.19.
type AuthConfigurations119 map[string]AuthConfiguration
+func (c AuthConfigurations119) isEmpty() bool {
+ return len(c) == 0
+}
+
+func (c AuthConfigurations119) headerKey() string {
+ return "X-Registry-Config"
+}
+
// dockerConfig represents a registry authentation configuration from the
// .dockercfg file.
type dockerConfig struct {
@@ -84,7 +108,7 @@ func cfgPaths(dockerConfigEnv string, homeEnv string) []string {
// - $HOME/.docker/config.json
// - $HOME/.dockercfg
func NewAuthConfigurationsFromDockerCfg() (*AuthConfigurations, error) {
- err := fmt.Errorf("No docker configuration found")
+ err := fmt.Errorf("no docker configuration found")
var auths *AuthConfigurations
pathsToTry := cfgPaths(os.Getenv("DOCKER_CONFIG"), os.Getenv("HOME"))