Skip to content

Commit

Permalink
Export pull as a public function
Browse files Browse the repository at this point in the history
It will be helpful to expose the pull implementation which supports
pulling private images for other CLI commands that rely on helper images.

Signed-off-by: Daniel Hiltgen <daniel.hiltgen@docker.com>
  • Loading branch information
Daniel Hiltgen committed Apr 27, 2018
1 parent 99bd7ed commit 812f113
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions cli/command/image/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ import (
"golang.org/x/net/context"
)

type pullOptions struct {
// PullOptions defines what and how to pull
type PullOptions struct {
remote string
all bool
platform string
Expand All @@ -22,15 +23,15 @@ type pullOptions struct {

// NewPullCommand creates a new `docker pull` command
func NewPullCommand(dockerCli command.Cli) *cobra.Command {
var opts pullOptions
var opts PullOptions

cmd := &cobra.Command{
Use: "pull [OPTIONS] NAME[:TAG|@DIGEST]",
Short: "Pull an image or a repository from a registry",
Args: cli.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {
opts.remote = args[0]
return runPull(dockerCli, opts)
return RunPull(dockerCli, opts)
},
}

Expand All @@ -44,7 +45,8 @@ func NewPullCommand(dockerCli command.Cli) *cobra.Command {
return cmd
}

func runPull(cli command.Cli, opts pullOptions) error {
// RunPull performs a pull against the engine based on the specified options
func RunPull(cli command.Cli, opts PullOptions) error {
distributionRef, err := reference.ParseNormalizedNamed(opts.remote)
switch {
case err != nil:
Expand Down

0 comments on commit 812f113

Please sign in to comment.