同步操作将从 mirrors_back/docker-cli 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
package imageimport ("context""fmt""strings""github.com/distribution/reference""github.com/docker/cli/cli""github.com/docker/cli/cli/command""github.com/docker/cli/cli/command/completion""github.com/docker/cli/cli/trust""github.com/pkg/errors""github.com/spf13/cobra")// PullOptions defines what and how to pulltype PullOptions struct {remote stringall boolplatform stringquiet booluntrusted bool}// NewPullCommand creates a new `docker pull` commandfunc NewPullCommand(dockerCli command.Cli) *cobra.Command {var opts PullOptionscmd := &cobra.Command{Use: "pull [OPTIONS] NAME[:TAG|@DIGEST]",Short: "Download an image from a registry",Args: cli.ExactArgs(1),RunE: func(cmd *cobra.Command, args []string) error {opts.remote = args[0]return RunPull(cmd.Context(), dockerCli, opts)},Annotations: map[string]string{"category-top": "5","aliases": "docker image pull, docker pull",},ValidArgsFunction: completion.NoComplete,}flags := cmd.Flags()flags.BoolVarP(&opts.all, "all-tags", "a", false, "Download all tagged images in the repository")flags.BoolVarP(&opts.quiet, "quiet", "q", false, "Suppress verbose output")command.AddPlatformFlag(flags, &opts.platform)command.AddTrustVerificationFlags(flags, &opts.untrusted, dockerCli.ContentTrustEnabled())_ = cmd.RegisterFlagCompletionFunc("platform", completion.Platforms)return cmd}// RunPull performs a pull against the engine based on the specified optionsfunc RunPull(ctx context.Context, dockerCLI command.Cli, opts PullOptions) error {distributionRef, err := reference.ParseNormalizedNamed(opts.remote)switch {case err != nil:return errcase opts.all && !reference.IsNameOnly(distributionRef):return errors.New("tag can't be used with --all-tags/-a")case !opts.all && reference.IsNameOnly(distributionRef):distributionRef = reference.TagNameOnly(distributionRef)if tagged, ok := distributionRef.(reference.Tagged); ok && !opts.quiet {fmt.Fprintf(dockerCLI.Out(), "Using default tag: %s\n", tagged.Tag())}}imgRefAndAuth, err := trust.GetImageReferencesAndAuth(ctx, AuthResolver(dockerCLI), distributionRef.String())if err != nil {return err}// Check if reference has a digest_, isCanonical := distributionRef.(reference.Canonical)if !opts.untrusted && !isCanonical {err = trustedPull(ctx, dockerCLI, imgRefAndAuth, opts)} else {err = imagePullPrivileged(ctx, dockerCLI, imgRefAndAuth, opts)}if err != nil {if strings.Contains(err.Error(), "when fetching 'plugin'") {return errors.New(err.Error() + " - Use `docker plugin install`")}return err}fmt.Fprintln(dockerCLI.Out(), imgRefAndAuth.Reference().String())return nil}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。