Skip to content

Commit

Permalink
feat: oras discover should show a placeholder of artifactType if it's…
Browse files Browse the repository at this point in the history
… not presented (#1336)

Signed-off-by: Xiaoxuan Wang <[email protected]>
  • Loading branch information
wangxiaoxuan273 authored Apr 12, 2024
1 parent 91268a2 commit 9732d14
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
3 changes: 3 additions & 0 deletions cmd/oras/internal/display/metadata/tree/discover.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ func (h *discoverHandler) OnDiscovered(referrer, subject ocispec.Descriptor) err
if !ok {
return fmt.Errorf("unexpected subject descriptor: %v", subject)
}
if referrer.ArtifactType == "" {
referrer.ArtifactType = "<unknown>"
}
referrerNode := node.AddPath(referrer.ArtifactType, referrer.Digest)
if h.verbose {
for k, v := range referrer.Annotations {
Expand Down
6 changes: 6 additions & 0 deletions test/e2e/suite/command/discover.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@ var _ = Describe("1.1 registry users:", func() {
MatchKeyWords(append(discoverKeyWords(true, referrers...), RegistryRef(ZOTHost, ArtifactRepo, foobar.Digest))...).
Exec()
})

It("should display <unknown> if a referrer has an empty artifact type", func() {
ORAS("discover", RegistryRef(ZOTHost, ArtifactRepo, "multi"), "--format", format).
MatchKeyWords("<unknown>").
Exec()
})
})
When("running discover command with table output", func() {
format := "table"
Expand Down

0 comments on commit 9732d14

Please sign in to comment.