Skip to content

Commit 1c54b0b

Browse files
authored
Merge pull request #5975 from thaJeztah/internalize_image_runsave
cli/command/image: deprecate RunPull and make internal
2 parents 2b84421 + 2328745 commit 1c54b0b

4 files changed

Lines changed: 20 additions & 12 deletions

File tree

cli/command/image/pull.go

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,10 @@ import (
1515
)
1616

1717
// PullOptions defines what and how to pull
18-
type PullOptions struct {
18+
type PullOptions = pullOptions
19+
20+
// pullOptions defines what and how to pull.
21+
type pullOptions struct {
1922
remote string
2023
all bool
2124
platform string
@@ -25,15 +28,15 @@ type PullOptions struct {
2528

2629
// NewPullCommand creates a new `docker pull` command
2730
func NewPullCommand(dockerCli command.Cli) *cobra.Command {
28-
var opts PullOptions
31+
var opts pullOptions
2932

3033
cmd := &cobra.Command{
3134
Use: "pull [OPTIONS] NAME[:TAG|@DIGEST]",
3235
Short: "Download an image from a registry",
3336
Args: cli.ExactArgs(1),
3437
RunE: func(cmd *cobra.Command, args []string) error {
3538
opts.remote = args[0]
36-
return RunPull(cmd.Context(), dockerCli, opts)
39+
return runPull(cmd.Context(), dockerCli, opts)
3740
},
3841
Annotations: map[string]string{
3942
"category-top": "5",
@@ -57,6 +60,11 @@ func NewPullCommand(dockerCli command.Cli) *cobra.Command {
5760

5861
// RunPull performs a pull against the engine based on the specified options
5962
func RunPull(ctx context.Context, dockerCLI command.Cli, opts PullOptions) error {
63+
return runPull(ctx, dockerCLI, opts)
64+
}
65+
66+
// runPull performs a pull against the engine based on the specified options
67+
func runPull(ctx context.Context, dockerCLI command.Cli, opts pullOptions) error {
6068
distributionRef, err := reference.ParseNormalizedNamed(opts.remote)
6169
switch {
6270
case err != nil:

cli/command/image/push.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func NewPushCommand(dockerCli command.Cli) *cobra.Command {
4545
Args: cli.ExactArgs(1),
4646
RunE: func(cmd *cobra.Command, args []string) error {
4747
opts.remote = args[0]
48-
return RunPush(cmd.Context(), dockerCli, opts)
48+
return runPush(cmd.Context(), dockerCli, opts)
4949
},
5050
Annotations: map[string]string{
5151
"category-top": "6",
@@ -73,8 +73,8 @@ Image index won't be pushed, meaning that other manifests, including attestation
7373
return cmd
7474
}
7575

76-
// RunPush performs a push against the engine based on the specified options
77-
func RunPush(ctx context.Context, dockerCli command.Cli, opts pushOptions) error {
76+
// runPush performs a push against the engine based on the specified options.
77+
func runPush(ctx context.Context, dockerCli command.Cli, opts pushOptions) error {
7878
var platform *ocispec.Platform
7979
out := tui.NewOutput(dockerCli.Out())
8080
if opts.platform != "" {

cli/command/image/save.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ func NewSaveCommand(dockerCli command.Cli) *cobra.Command {
2929
Args: cli.RequiresMinArgs(1),
3030
RunE: func(cmd *cobra.Command, args []string) error {
3131
opts.images = args
32-
return RunSave(cmd.Context(), dockerCli, opts)
32+
return runSave(cmd.Context(), dockerCli, opts)
3333
},
3434
Annotations: map[string]string{
3535
"aliases": "docker image save, docker save",
@@ -47,8 +47,8 @@ func NewSaveCommand(dockerCli command.Cli) *cobra.Command {
4747
return cmd
4848
}
4949

50-
// RunSave performs a save against the engine based on the specified options
51-
func RunSave(ctx context.Context, dockerCli command.Cli, opts saveOptions) error {
50+
// runSave performs a save against the engine based on the specified options
51+
func runSave(ctx context.Context, dockerCli command.Cli, opts saveOptions) error {
5252
if opts.output == "" && dockerCli.Out().IsTerminal() {
5353
return errors.New("cowardly refusing to save to a terminal. Use the -o flag or redirect")
5454
}

cli/command/image/trust.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func pushTrustedReference(ctx context.Context, ioStreams command.Streams, repoIn
4747
}
4848

4949
// trustedPull handles content trust pulling of an image
50-
func trustedPull(ctx context.Context, cli command.Cli, imgRefAndAuth trust.ImageRefAndAuth, opts PullOptions) error {
50+
func trustedPull(ctx context.Context, cli command.Cli, imgRefAndAuth trust.ImageRefAndAuth, opts pullOptions) error {
5151
refs, err := getTrustedPullTargets(cli, imgRefAndAuth)
5252
if err != nil {
5353
return err
@@ -69,7 +69,7 @@ func trustedPull(ctx context.Context, cli command.Cli, imgRefAndAuth trust.Image
6969
if err != nil {
7070
return err
7171
}
72-
if err := imagePullPrivileged(ctx, cli, updatedImgRefAndAuth, PullOptions{
72+
if err := imagePullPrivileged(ctx, cli, updatedImgRefAndAuth, pullOptions{
7373
all: false,
7474
platform: opts.platform,
7575
quiet: opts.quiet,
@@ -144,7 +144,7 @@ func getTrustedPullTargets(cli command.Cli, imgRefAndAuth trust.ImageRefAndAuth)
144144
}
145145

146146
// imagePullPrivileged pulls the image and displays it to the output
147-
func imagePullPrivileged(ctx context.Context, cli command.Cli, imgRefAndAuth trust.ImageRefAndAuth, opts PullOptions) error {
147+
func imagePullPrivileged(ctx context.Context, cli command.Cli, imgRefAndAuth trust.ImageRefAndAuth, opts pullOptions) error {
148148
encodedAuth, err := registrytypes.EncodeAuthConfig(*imgRefAndAuth.AuthConfig())
149149
if err != nil {
150150
return err

0 commit comments

Comments
 (0)