Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
Signed-off-by: Billy Zha <[email protected]>
  • Loading branch information
qweeah committed Jan 29, 2024
1 parent 8be4221 commit 5ef94fc
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
24 changes: 13 additions & 11 deletions cmd/oras/internal/display/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ func (ph *PullHandler) printOnce(s ocispec.Descriptor, msg string) error {
if ph.trackedGraphTarget != nil {
// TTY
return ph.trackedGraphTarget.Prompt(s, msg)

} else if ph.needTextOutput {
// none TTY
return PrintStatus(s, msg, ph.verbose)
Expand Down Expand Up @@ -225,23 +224,26 @@ func (ph *PullHandler) PostCopy(ctx context.Context, desc ocispec.Descriptor) er
name = desc.MediaType
}
ph.printed.Store(generateContentKey(desc), true)
if ph.trackedGraphTarget != nil {
if ph.needTextOutput {
// none TTY, print status log for downloaded
return Print(ph.promptDownloaded, ShortDigest(desc), name)
}
// TTY
return nil
}

// PostPull is called after pulling.
func (ph *PullHandler) PostPull(root ocispec.Descriptor) error {
// suggest oras copy for pulling layers without annotation
if ph.result.layerSkipped {
Print("Skipped pulling layers without file name in", ocispec.AnnotationTitle)
Print("Use 'oras copy", ph.target.RawReference, "--to-oci-layout <layout-dir>' to pull all layers.")
} else {
Print("Pulled", ph.target.AnnotatedReference())
Print("Digest:", root.Digest)
if ph.template != "" {
return option.WriteMetadata(ph.template, os.Stdout, metadata.NewPull(fmt.Sprintf("%s@%s", ph.target.Path, root.Digest), ph.result.files))
} else if ph.needTextOutput {
// suggest oras copy for pulling layers without annotation
if ph.result.layerSkipped {
Print("Skipped pulling layers without file name in", ocispec.AnnotationTitle)

Check failure on line 241 in cmd/oras/internal/display/pull.go

View workflow job for this annotation

GitHub Actions / lint (1.21)

Error return value is not checked (errcheck)
Print("Use 'oras copy", ph.target.RawReference, "--to-oci-layout <layout-dir>' to pull all layers.")

Check failure on line 242 in cmd/oras/internal/display/pull.go

View workflow job for this annotation

GitHub Actions / lint (1.21)

Error return value is not checked (errcheck)
} else {
Print("Pulled", ph.target.AnnotatedReference())

Check failure on line 244 in cmd/oras/internal/display/pull.go

View workflow job for this annotation

GitHub Actions / lint (1.21)

Error return value is not checked (errcheck)
Print("Digest:", root.Digest)
}
}
return option.WriteMetadata(ph.template, os.Stdout, metadata.NewPull(fmt.Sprintf("%s@%s", ph.target.Path, root.Digest), ph.result.files))
return nil
}
2 changes: 1 addition & 1 deletion cmd/oras/root/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func runPull(cmd *cobra.Command, opts *pullOptions) error {
}
ph := display.NewPullHandler(opts.Template, opts.TTY, tracked, opts.Verbose, opts.IncludeSubject, configPath, configMediaType, opts.Output, &opts.Target)
copyOptions.FindSuccessors = ph.FindSuccessors
copyOptions.PreCopy = ph.PostCopy
copyOptions.PreCopy = ph.PreCopy
copyOptions.PostCopy = ph.PostCopy

root, err := doPull(ctx, src, tracked, copyOptions, opts)
Expand Down

0 comments on commit 5ef94fc

Please sign in to comment.