From b9b98aee5dc96a8b6cafd72578b06227dd0ddfc9 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Tue, 11 Apr 2023 20:26:43 +0200 Subject: [PATCH] cli/command/container/create: pullImage(): use RetrieveAuthTokenFromImage replace the local code with RetrieveAuthTokenFromImage, which does exactly the same; https://github.com/docker/cli/blob/623356001f6310fef7a8cca0b9ba0ac1b735bb38/cli/command/registry.go#L163-L188 Signed-off-by: Sebastiaan van Stijn --- cli/command/container/create.go | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/cli/command/container/create.go b/cli/command/container/create.go index 05ac2fe0e0..7f66b96e59 100644 --- a/cli/command/container/create.go +++ b/cli/command/container/create.go @@ -16,11 +16,9 @@ import ( "github.com/docker/distribution/reference" "github.com/docker/docker/api/types" "github.com/docker/docker/api/types/container" - registrytypes "github.com/docker/docker/api/types/registry" "github.com/docker/docker/api/types/versions" apiclient "github.com/docker/docker/client" "github.com/docker/docker/pkg/jsonmessage" - "github.com/docker/docker/registry" specs "github.com/opencontainers/image-spec/specs-go/v1" "github.com/pkg/errors" "github.com/spf13/cobra" @@ -114,19 +112,7 @@ func runCreate(dockerCli command.Cli, flags *pflag.FlagSet, options *createOptio } func pullImage(ctx context.Context, dockerCli command.Cli, image string, platform string, out io.Writer) error { - ref, err := reference.ParseNormalizedNamed(image) - if err != nil { - return err - } - - // Resolve the Repository name from fqn to RepositoryInfo - repoInfo, err := registry.ParseRepositoryInfo(ref) - if err != nil { - return err - } - - authConfig := command.ResolveAuthConfig(ctx, dockerCli, repoInfo.Index) - encodedAuth, err := registrytypes.EncodeAuthConfig(authConfig) + encodedAuth, err := command.RetrieveAuthTokenFromImage(ctx, dockerCli, image) if err != nil { return err }