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 <github@gone.nl>
This commit is contained in:
@ -84,7 +84,7 @@ func runPull(ctx context.Context, dockerCLI command.Cli, opts pullOptions) error
|
||||
return err
|
||||
}
|
||||
} else {
|
||||
if err := imagePullPrivileged(ctx, dockerCLI, imgRefAndAuth, opts); err != nil {
|
||||
if err := imagePullPrivileged(ctx, dockerCLI, imgRefAndAuth.Reference(), imgRefAndAuth.AuthConfig(), opts); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,7 +81,7 @@ func trustedPull(ctx context.Context, cli command.Cli, imgRefAndAuth trust.Image
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err := imagePullPrivileged(ctx, cli, updatedImgRefAndAuth, pullOptions{
|
||||
if err := imagePullPrivileged(ctx, cli, updatedImgRefAndAuth.Reference(), updatedImgRefAndAuth.AuthConfig(), pullOptions{
|
||||
all: false,
|
||||
platform: opts.platform,
|
||||
quiet: opts.quiet,
|
||||
@ -156,12 +156,12 @@ func getTrustedPullTargets(cli command.Cli, imgRefAndAuth trust.ImageRefAndAuth)
|
||||
}
|
||||
|
||||
// imagePullPrivileged pulls the image and displays it to the output
|
||||
func imagePullPrivileged(ctx context.Context, cli command.Cli, imgRefAndAuth trust.ImageRefAndAuth, opts pullOptions) error {
|
||||
encodedAuth, err := authconfig.Encode(*imgRefAndAuth.AuthConfig())
|
||||
func imagePullPrivileged(ctx context.Context, cli command.Cli, ref reference.Named, authConfig *registrytypes.AuthConfig, opts pullOptions) error {
|
||||
encodedAuth, err := authconfig.Encode(*authConfig)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
responseBody, err := cli.Client().ImagePull(ctx, reference.FamiliarString(imgRefAndAuth.Reference()), client.ImagePullOptions{
|
||||
responseBody, err := cli.Client().ImagePull(ctx, reference.FamiliarString(ref), client.ImagePullOptions{
|
||||
RegistryAuth: encodedAuth,
|
||||
PrivilegeFunc: nil,
|
||||
All: opts.all,
|
||||
|
||||
Reference in New Issue
Block a user