cli/command/plugin: simplify auth

Now that 3f5b1bdd32 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 <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn
2025-08-26 16:42:34 +02:00
parent cfd7e543fc
commit f2c8b9dfd3
2 changed files with 2 additions and 8 deletions

View File

@ -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
}

View File

@ -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
}