Skip to content

Commit

Permalink
Use reference.WithTag instead of manual string manipulation in Pull
Browse files Browse the repository at this point in the history
Should not change behavior, except possibly failing early if the server
returns an invalid tag name.

Signed-off-by: Miloslav Trmač <[email protected]>

Closes: #1361
Approved by: rhatdan
  • Loading branch information
mtrmac authored and rh-atomic-bot committed Feb 27, 2019
1 parent 20a7f63 commit 62b5b0d
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ func Pull(ctx context.Context, imageName string, options PullOptions) error {
return errors.New("Non-docker transport is not supported, for --all-tags pulling")
}

repo := storageRef.DockerReference().Name()
dockerRef, err := alltransports.ParseImageName(transport + repo)
repo := reference.TrimNamed(storageRef.DockerReference())
dockerRef, err := alltransports.ParseImageName(transport + repo.Name())
if err != nil {
return errors.Wrapf(err, "error getting repository tags")
}
Expand All @@ -185,11 +185,15 @@ func Pull(ctx context.Context, imageName string, options PullOptions) error {
return errors.Wrapf(err, "error getting repository tags")
}
for _, tag := range tags {
name := repo + ":" + tag
tagged, err := reference.WithTag(repo, tag)
if err != nil {
errs = multierror.Append(errs, err)
continue
}
if options.ReportWriter != nil {
options.ReportWriter.Write([]byte("Pulling " + name + "\n"))
options.ReportWriter.Write([]byte("Pulling " + tagged.String() + "\n"))
}
ref, err := pullImage(ctx, options.Store, transport, name, options, systemContext)
ref, err := pullImage(ctx, options.Store, transport, tagged.String(), options, systemContext)
if err != nil {
errs = multierror.Append(errs, err)
continue
Expand Down

0 comments on commit 62b5b0d

Please sign in to comment.