From f2c8b9dfd3553b377102fabf494b59422571abbd Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 26 Aug 2025 16:42:34 +0200 Subject: [PATCH] cli/command/plugin: simplify auth Now that 3f5b1bdd3240d390f48290c75dd724788eddfb6f removed DCT, which needed some of the intermediate types (indexInfo), we can simplify the auth code further and just get the base64-encoded AuthConfig to be set as header. Signed-off-by: Sebastiaan van Stijn --- cli/command/plugin/install.go | 5 +---- cli/command/plugin/push.go | 5 +---- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/cli/command/plugin/install.go b/cli/command/plugin/install.go index 9cb93b3b2702..da86dba9ddb5 100644 --- a/cli/command/plugin/install.go +++ b/cli/command/plugin/install.go @@ -10,9 +10,7 @@ import ( "github.com/docker/cli/cli/command" "github.com/docker/cli/internal/jsonstream" "github.com/docker/cli/internal/prompt" - "github.com/docker/cli/internal/registry" "github.com/moby/moby/api/types/plugin" - registrytypes "github.com/moby/moby/api/types/registry" "github.com/moby/moby/client" "github.com/pkg/errors" "github.com/spf13/cobra" @@ -60,8 +58,7 @@ func buildPullConfig(dockerCLI command.Cli, opts pluginOptions) (client.PluginIn return client.PluginInstallOptions{}, err } - authConfig := command.ResolveAuthConfig(dockerCLI.ConfigFile(), registry.NewIndexInfo(ref)) - encodedAuth, err := registrytypes.EncodeAuthConfig(authConfig) + encodedAuth, err := command.RetrieveAuthTokenFromImage(dockerCLI.ConfigFile(), ref.String()) if err != nil { return client.PluginInstallOptions{}, err } diff --git a/cli/command/plugin/push.go b/cli/command/plugin/push.go index 37bf997f6a09..a4a830f41ef1 100644 --- a/cli/command/plugin/push.go +++ b/cli/command/plugin/push.go @@ -8,8 +8,6 @@ import ( "github.com/docker/cli/cli" "github.com/docker/cli/cli/command" "github.com/docker/cli/internal/jsonstream" - "github.com/docker/cli/internal/registry" - registrytypes "github.com/moby/moby/api/types/registry" "github.com/spf13/cobra" ) @@ -40,8 +38,7 @@ func runPush(ctx context.Context, dockerCli command.Cli, name string) error { } named = reference.TagNameOnly(named) - authConfig := command.ResolveAuthConfig(dockerCli.ConfigFile(), registry.NewIndexInfo(named)) - encodedAuth, err := registrytypes.EncodeAuthConfig(authConfig) + encodedAuth, err := command.RetrieveAuthTokenFromImage(dockerCli.ConfigFile(), named.String()) if err != nil { return err }