From 818ee962196d668b6d405835c88c1ac6cdab7423 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Thu, 3 Mar 2022 10:21:06 +0100 Subject: [PATCH] api/types: move AuthConfig to registry types Making the api types more focused per API type, and the general api/types package somewhat smaller. Signed-off-by: Sebastiaan van Stijn --- api/types/auth.go | 25 +++++-------------------- api/types/backend/build.go | 3 ++- api/types/client.go | 3 ++- api/types/registry/authconfig.go | 21 +++++++++++++++++++++ 4 files changed, 30 insertions(+), 22 deletions(-) diff --git a/api/types/auth.go b/api/types/auth.go index ddf15bb182..9ee329a2fb 100644 --- a/api/types/auth.go +++ b/api/types/auth.go @@ -1,22 +1,7 @@ package types // import "github.com/docker/docker/api/types" +import "github.com/docker/docker/api/types/registry" -// AuthConfig contains authorization information for connecting to a Registry -type AuthConfig struct { - Username string `json:"username,omitempty"` - Password string `json:"password,omitempty"` - Auth string `json:"auth,omitempty"` - - // Email is an optional value associated with the username. - // This field is deprecated and will be removed in a later - // version of docker. - Email string `json:"email,omitempty"` - - ServerAddress string `json:"serveraddress,omitempty"` - - // IdentityToken is used to authenticate the user and get - // an access token for the registry. - IdentityToken string `json:"identitytoken,omitempty"` - - // RegistryToken is a bearer token to be sent to a registry - RegistryToken string `json:"registrytoken,omitempty"` -} +// AuthConfig contains authorization information for connecting to a Registry. +// +// Deprecated: use github.com/docker/docker/api/types/registry.AuthConfig +type AuthConfig = registry.AuthConfig diff --git a/api/types/backend/build.go b/api/types/backend/build.go index 1a2e59f2f7..9f1348e12c 100644 --- a/api/types/backend/build.go +++ b/api/types/backend/build.go @@ -4,6 +4,7 @@ import ( "io" "github.com/docker/docker/api/types" + "github.com/docker/docker/api/types/registry" "github.com/docker/docker/pkg/streamformatter" specs "github.com/opencontainers/image-spec/specs-go/v1" ) @@ -39,7 +40,7 @@ type BuildConfig struct { // GetImageAndLayerOptions are the options supported by GetImageAndReleasableLayer type GetImageAndLayerOptions struct { PullOption PullOption - AuthConfig map[string]types.AuthConfig + AuthConfig map[string]registry.AuthConfig Output io.Writer Platform *specs.Platform } diff --git a/api/types/client.go b/api/types/client.go index 97aca02306..d8cd306135 100644 --- a/api/types/client.go +++ b/api/types/client.go @@ -7,6 +7,7 @@ import ( "github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/filters" + "github.com/docker/docker/api/types/registry" units "github.com/docker/go-units" ) @@ -180,7 +181,7 @@ type ImageBuildOptions struct { // at all (nil). See the parsing of buildArgs in // api/server/router/build/build_routes.go for even more info. BuildArgs map[string]*string - AuthConfigs map[string]AuthConfig + AuthConfigs map[string]registry.AuthConfig Context io.Reader Labels map[string]string // squash the resulting image's layers to the parent diff --git a/api/types/registry/authconfig.go b/api/types/registry/authconfig.go index d61cefb20e..1e3f89b9de 100644 --- a/api/types/registry/authconfig.go +++ b/api/types/registry/authconfig.go @@ -3,3 +3,24 @@ package registry // import "github.com/docker/docker/api/types/registry" // AuthHeader is the name of the header used to send encoded registry // authorization credentials for registry operations (push/pull). const AuthHeader = "X-Registry-Auth" + +// AuthConfig contains authorization information for connecting to a Registry. +type AuthConfig struct { + Username string `json:"username,omitempty"` + Password string `json:"password,omitempty"` + Auth string `json:"auth,omitempty"` + + // Email is an optional value associated with the username. + // This field is deprecated and will be removed in a later + // version of docker. + Email string `json:"email,omitempty"` + + ServerAddress string `json:"serveraddress,omitempty"` + + // IdentityToken is used to authenticate the user and get + // an access token for the registry. + IdentityToken string `json:"identitytoken,omitempty"` + + // RegistryToken is a bearer token to be sent to a registry + RegistryToken string `json:"registrytoken,omitempty"` +}