Skip to content

Commit

Permalink
fix e2e
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 4878351 commit 068d9c2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 24 deletions.
7 changes: 3 additions & 4 deletions cmd/oras/internal/display/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ import (
)

type pullResult struct {
files []metadata.File
layerSkipped bool
filesLock sync.Mutex
files []metadata.File
filesLock sync.Mutex
}

// PullHandler provides display handler for pulling.
Expand Down Expand Up @@ -237,7 +236,7 @@ func (ph *PullHandler) PostPull(root ocispec.Descriptor) error {
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 {
if ph.layerSkipped.Load() {
Print("Skipped pulling layers without file name in", ocispec.AnnotationTitle)

Check failure on line 240 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 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)
} else {
Expand Down
20 changes: 0 additions & 20 deletions cmd/oras/root/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"context"
"errors"
"fmt"
"sync"

ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -170,22 +169,3 @@ func doPull(ctx context.Context, src oras.ReadOnlyTarget, dst oras.GraphTarget,
// Copy
return oras.Copy(ctx, src, po.Reference, dst, po.Reference, opts)
}

// generateContentKey generates a unique key for each content descriptor, using
// its digest and name if applicable.
func generateContentKey(desc ocispec.Descriptor) string {
return desc.Digest.String() + desc.Annotations[ocispec.AnnotationTitle]
}

func printOnce(printed *sync.Map, s ocispec.Descriptor, msg string, verbose bool, dst any) error {
if _, loaded := printed.LoadOrStore(generateContentKey(s), true); loaded {
return nil
}
if tracked, ok := dst.(track.GraphTarget); ok {
// TTY
return tracked.Prompt(s, msg)

}
// none TTY
return display.PrintStatus(s, msg, verbose)
}

0 comments on commit 068d9c2

Please sign in to comment.