Skip to content

Commit c97482f

Browse files
committed
cli/command/image: imagePullPrivileged: don't use ImageRefAndAuth
This function is a wrapper around apiClient.ImagePull; the use of trust.ImageRefAndAuth was out of convenience because it's also called when using content trust (through the trustedPull utility). Let's pull away the layers to separate it from trust code. Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent f9339ff commit c97482f

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

cli/command/image/pull.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func runPull(ctx context.Context, dockerCLI command.Cli, opts pullOptions) error
8484
return err
8585
}
8686
} else {
87-
if err := imagePullPrivileged(ctx, dockerCLI, imgRefAndAuth, opts); err != nil {
87+
if err := imagePullPrivileged(ctx, dockerCLI, imgRefAndAuth.Reference(), imgRefAndAuth.AuthConfig(), opts); err != nil {
8888
return err
8989
}
9090
}

cli/command/image/trust.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ func trustedPull(ctx context.Context, cli command.Cli, imgRefAndAuth trust.Image
8181
if err != nil {
8282
return err
8383
}
84-
if err := imagePullPrivileged(ctx, cli, updatedImgRefAndAuth, pullOptions{
84+
if err := imagePullPrivileged(ctx, cli, updatedImgRefAndAuth.Reference(), updatedImgRefAndAuth.AuthConfig(), pullOptions{
8585
all: false,
8686
platform: opts.platform,
8787
quiet: opts.quiet,
@@ -156,12 +156,12 @@ func getTrustedPullTargets(cli command.Cli, imgRefAndAuth trust.ImageRefAndAuth)
156156
}
157157

158158
// imagePullPrivileged pulls the image and displays it to the output
159-
func imagePullPrivileged(ctx context.Context, cli command.Cli, imgRefAndAuth trust.ImageRefAndAuth, opts pullOptions) error {
160-
encodedAuth, err := authconfig.Encode(*imgRefAndAuth.AuthConfig())
159+
func imagePullPrivileged(ctx context.Context, cli command.Cli, ref reference.Named, authConfig *registrytypes.AuthConfig, opts pullOptions) error {
160+
encodedAuth, err := authconfig.Encode(*authConfig)
161161
if err != nil {
162162
return err
163163
}
164-
responseBody, err := cli.Client().ImagePull(ctx, reference.FamiliarString(imgRefAndAuth.Reference()), client.ImagePullOptions{
164+
responseBody, err := cli.Client().ImagePull(ctx, reference.FamiliarString(ref), client.ImagePullOptions{
165165
RegistryAuth: encodedAuth,
166166
PrivilegeFunc: nil,
167167
All: opts.all,

0 commit comments

Comments
 (0)