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 (oras-project#1336)

Signed-off-by: Xiaoxuan Wang <[email protected]>
  • Loading branch information
wangxiaoxuan273 authored and FeynmanZhou committed May 11, 2024
1 parent 6dea74c commit 0291003
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 0291003

Please sign in to comment.