Skip to content

Commit b9b98ae

Browse files
committed
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 <github@gone.nl>
1 parent a27acd6 commit b9b98ae

1 file changed

Lines changed: 1 addition & 15 deletions

File tree

cli/command/container/create.go

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@ import (
1616
"github.com/docker/distribution/reference"
1717
"github.com/docker/docker/api/types"
1818
"github.com/docker/docker/api/types/container"
19-
registrytypes "github.com/docker/docker/api/types/registry"
2019
"github.com/docker/docker/api/types/versions"
2120
apiclient "github.com/docker/docker/client"
2221
"github.com/docker/docker/pkg/jsonmessage"
23-
"github.com/docker/docker/registry"
2422
specs "github.com/opencontainers/image-spec/specs-go/v1"
2523
"github.com/pkg/errors"
2624
"github.com/spf13/cobra"
@@ -114,19 +112,7 @@ func runCreate(dockerCli command.Cli, flags *pflag.FlagSet, options *createOptio
114112
}
115113

116114
func pullImage(ctx context.Context, dockerCli command.Cli, image string, platform string, out io.Writer) error {
117-
ref, err := reference.ParseNormalizedNamed(image)
118-
if err != nil {
119-
return err
120-
}
121-
122-
// Resolve the Repository name from fqn to RepositoryInfo
123-
repoInfo, err := registry.ParseRepositoryInfo(ref)
124-
if err != nil {
125-
return err
126-
}
127-
128-
authConfig := command.ResolveAuthConfig(ctx, dockerCli, repoInfo.Index)
129-
encodedAuth, err := registrytypes.EncodeAuthConfig(authConfig)
115+
encodedAuth, err := command.RetrieveAuthTokenFromImage(ctx, dockerCli, image)
130116
if err != nil {
131117
return err
132118
}

0 commit comments

Comments
 (0)