client: use types/registry.AuthConfig

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2022-03-03 10:27:23 +01:00
parent d8a43399a8
commit eaf1a604f2
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
3 changed files with 4 additions and 4 deletions

View File

@ -12,6 +12,7 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container" "github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/registry"
"github.com/docker/docker/errdefs" "github.com/docker/docker/errdefs"
units "github.com/docker/go-units" units "github.com/docker/go-units"
) )
@ -144,7 +145,7 @@ func TestImageBuild(t *testing.T) {
}, },
{ {
buildOptions: types.ImageBuildOptions{ buildOptions: types.ImageBuildOptions{
AuthConfigs: map[string]types.AuthConfig{ AuthConfigs: map[string]registry.AuthConfig{
"https://index.docker.io/v1/": { "https://index.docker.io/v1/": {
Auth: "dG90bwo=", Auth: "dG90bwo=",
}, },

View File

@ -166,7 +166,7 @@ type SwarmAPIClient interface {
type SystemAPIClient interface { type SystemAPIClient interface {
Events(ctx context.Context, options types.EventsOptions) (<-chan events.Message, <-chan error) Events(ctx context.Context, options types.EventsOptions) (<-chan events.Message, <-chan error)
Info(ctx context.Context) (types.Info, error) Info(ctx context.Context) (types.Info, error)
RegistryLogin(ctx context.Context, auth types.AuthConfig) (registry.AuthenticateOKBody, error) RegistryLogin(ctx context.Context, auth registry.AuthConfig) (registry.AuthenticateOKBody, error)
DiskUsage(ctx context.Context, options types.DiskUsageOptions) (types.DiskUsage, error) DiskUsage(ctx context.Context, options types.DiskUsageOptions) (types.DiskUsage, error)
Ping(ctx context.Context) (types.Ping, error) Ping(ctx context.Context) (types.Ping, error)
} }

View File

@ -5,13 +5,12 @@ import (
"encoding/json" "encoding/json"
"net/url" "net/url"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/registry" "github.com/docker/docker/api/types/registry"
) )
// RegistryLogin authenticates the docker server with a given docker registry. // RegistryLogin authenticates the docker server with a given docker registry.
// It returns unauthorizedError when the authentication fails. // It returns unauthorizedError when the authentication fails.
func (cli *Client) RegistryLogin(ctx context.Context, auth types.AuthConfig) (registry.AuthenticateOKBody, error) { func (cli *Client) RegistryLogin(ctx context.Context, auth registry.AuthConfig) (registry.AuthenticateOKBody, error) {
resp, err := cli.post(ctx, "/auth", url.Values{}, auth, nil) resp, err := cli.post(ctx, "/auth", url.Values{}, auth, nil)
defer ensureReaderClosed(resp) defer ensureReaderClosed(resp)