cli/command/image: deprecate RunPull and make internal

This function was exported in 812f1136850f6c18bbe3f1b2a960a8ff8a8413f3
for use in other parts of the CLI, but it's now only used locally.

Make it internal again, as it was never designed to be exported. There
are no known external consumers of this function, but deprecating it
first, in case there are.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
Sebastiaan van Stijn 2025-03-31 19:31:31 +02:00
parent b557e37a49
commit 2328745f92
No known key found for this signature in database
GPG Key ID: 76698F39D527CE8C
2 changed files with 14 additions and 6 deletions

View File

@ -15,7 +15,10 @@ import (
) )
// PullOptions defines what and how to pull // PullOptions defines what and how to pull
type PullOptions struct { type PullOptions = pullOptions
// pullOptions defines what and how to pull.
type pullOptions struct {
remote string remote string
all bool all bool
platform string platform string
@ -25,7 +28,7 @@ type PullOptions struct {
// NewPullCommand creates a new `docker pull` command // NewPullCommand creates a new `docker pull` command
func NewPullCommand(dockerCli command.Cli) *cobra.Command { func NewPullCommand(dockerCli command.Cli) *cobra.Command {
var opts PullOptions var opts pullOptions
cmd := &cobra.Command{ cmd := &cobra.Command{
Use: "pull [OPTIONS] NAME[:TAG|@DIGEST]", Use: "pull [OPTIONS] NAME[:TAG|@DIGEST]",
@ -33,7 +36,7 @@ func NewPullCommand(dockerCli command.Cli) *cobra.Command {
Args: cli.ExactArgs(1), Args: cli.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
opts.remote = args[0] opts.remote = args[0]
return RunPull(cmd.Context(), dockerCli, opts) return runPull(cmd.Context(), dockerCli, opts)
}, },
Annotations: map[string]string{ Annotations: map[string]string{
"category-top": "5", "category-top": "5",
@ -57,6 +60,11 @@ func NewPullCommand(dockerCli command.Cli) *cobra.Command {
// RunPull performs a pull against the engine based on the specified options // RunPull performs a pull against the engine based on the specified options
func RunPull(ctx context.Context, dockerCLI command.Cli, opts PullOptions) error { func RunPull(ctx context.Context, dockerCLI command.Cli, opts PullOptions) error {
return runPull(ctx, dockerCLI, opts)
}
// runPull performs a pull against the engine based on the specified options
func runPull(ctx context.Context, dockerCLI command.Cli, opts pullOptions) error {
distributionRef, err := reference.ParseNormalizedNamed(opts.remote) distributionRef, err := reference.ParseNormalizedNamed(opts.remote)
switch { switch {
case err != nil: case err != nil:

View File

@ -47,7 +47,7 @@ func pushTrustedReference(ctx context.Context, ioStreams command.Streams, repoIn
} }
// trustedPull handles content trust pulling of an image // trustedPull handles content trust pulling of an image
func trustedPull(ctx context.Context, cli command.Cli, imgRefAndAuth trust.ImageRefAndAuth, opts PullOptions) error { func trustedPull(ctx context.Context, cli command.Cli, imgRefAndAuth trust.ImageRefAndAuth, opts pullOptions) error {
refs, err := getTrustedPullTargets(cli, imgRefAndAuth) refs, err := getTrustedPullTargets(cli, imgRefAndAuth)
if err != nil { if err != nil {
return err return err
@ -69,7 +69,7 @@ func trustedPull(ctx context.Context, cli command.Cli, imgRefAndAuth trust.Image
if err != nil { if err != nil {
return err return err
} }
if err := imagePullPrivileged(ctx, cli, updatedImgRefAndAuth, PullOptions{ if err := imagePullPrivileged(ctx, cli, updatedImgRefAndAuth, pullOptions{
all: false, all: false,
platform: opts.platform, platform: opts.platform,
quiet: opts.quiet, quiet: opts.quiet,
@ -144,7 +144,7 @@ func getTrustedPullTargets(cli command.Cli, imgRefAndAuth trust.ImageRefAndAuth)
} }
// imagePullPrivileged pulls the image and displays it to the output // imagePullPrivileged pulls the image and displays it to the output
func imagePullPrivileged(ctx context.Context, cli command.Cli, imgRefAndAuth trust.ImageRefAndAuth, opts PullOptions) error { func imagePullPrivileged(ctx context.Context, cli command.Cli, imgRefAndAuth trust.ImageRefAndAuth, opts pullOptions) error {
encodedAuth, err := registrytypes.EncodeAuthConfig(*imgRefAndAuth.AuthConfig()) encodedAuth, err := registrytypes.EncodeAuthConfig(*imgRefAndAuth.AuthConfig())
if err != nil { if err != nil {
return err return err