Skip to content

fix: should not print copy hint for manifest in verbose mode#1165

Merged
qweeah merged 1 commit into
oras-project:mainfrom
qweeah:qweeah/fix-copy-hint
Nov 3, 2023
Merged

fix: should not print copy hint for manifest in verbose mode#1165
qweeah merged 1 commit into
oras-project:mainfrom
qweeah:qweeah/fix-copy-hint

Conversation

@qweeah

@qweeah qweeah commented Nov 3, 2023

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:
This PR avoids wrong hinting on unnamed manifest/index in verbose mode.

Suppose we have below manifest stored in registry

$ oras manifest fetch --pretty localhost:5000/test:config                                                         
{
  "schemaVersion": 2,
  "mediaType": "application/vnd.oci.image.manifest.v1+json",
  "artifactType": "my.test/example",
  "config": {
    "mediaType": "bar/test",
    "digest": "sha256:2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae",
    "size": 3
  },
  "layers": [
    {
      "mediaType": "application/vnd.oci.image.layer.v1.tar",
      "digest": "sha256:2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae",
      "size": 3,
      "annotations": {
        "org.opencontainers.image.title": "foo"
      }
    }
  ],
  "annotations": {
    "org.opencontainers.image.created": "2023-11-03T01:20:50Z"
  }
}

Before the change, the verbose output will always hint user to use oras copy to copy unnamed layer. But actually only the manifest is unnamed

$ oras pull localhost:5000/test:config -o pulled --config my.config -v
✓ Pulled      my.config                                                                                                                                                                       3/3  B 100.00%    3ms
  └─ sha256:2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae 
✓ Pulled      foo                                                                                                                                                                             3/3  B 100.00%  706µs
  └─ sha256:2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae 
✓ Pulled      application/vnd.oci.image.manifest.v1+json                                                                                                                                  522/522  B 100.00%  262µs
  └─ sha256:007fa1a84c35baf14b14698b8f2f4b3eb99200b496be446e6ea6c478029d75b9 
Skipped pulling layers without file name in "org.opencontainers.image.title"
Use 'oras copy localhost:5000/test:config --to-oci-layout <layout-dir>' to pull all layers.

After the change, the verbose output will not do that

oras pull localhost:5000/test:config -o pulled --config my.config 
✓ Pulled      my.config                                                                                                                                                                       3/3  B 100.00%    1ms
  └─ sha256:2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae 
✓ Pulled      foo                                                                                                                                                                             3/3  B 100.00%    4ms
  └─ sha256:2c26b46b68ffc68ff99b453c1d30413413422d706483bfa0f98a5e886266e7ae 
✓ Pulled      application/vnd.oci.image.manifest.v1+json                                                                                                                                  522/522  B 100.00%     0s
  └─ sha256:007fa1a84c35baf14b14698b8f2f4b3eb99200b496be446e6ea6c478029d75b9 
Pulled [registry] localhost:5000/test:config
Digest: sha256:007fa1a84c35baf14b14698b8f2f4b3eb99200b496be446e6ea6c478029d75b9

Signed-off-by: Billy Zha <jinzha1@microsoft.com>
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

Merging #1165 (cf5d282) into main (f41d56d) will decrease coverage by 0.01%.
The diff coverage is n/a.

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

@@            Coverage Diff             @@
##             main    #1165      +/-   ##
==========================================
- Coverage   79.94%   79.93%   -0.01%     
==========================================
  Files          65       65              
  Lines        3520     3519       -1     
==========================================
- Hits         2814     2813       -1     
  Misses        492      492              
  Partials      214      214              
Files Coverage Δ
cmd/oras/root/pull.go 73.78% <ø> (-0.13%) ⬇️

@shizhMSFT shizhMSFT left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

shizhMSFT

This comment was marked as outdated.

@qweeah qweeah merged commit 5d95881 into oras-project:main Nov 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants