Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: check if configPath is empty before writing to Annotations #509

Merged
merged 2 commits into from
Aug 19, 2022
Merged

fix: check if configPath is empty before writing to Annotations #509

merged 2 commits into from
Aug 19, 2022

Conversation

wangxiaoxuan273
Copy link
Contributor

@wangxiaoxuan273 wangxiaoxuan273 commented Aug 19, 2022

This pr adds empty string check before writing configPath to Annotations, so that if a config only specifies the type but not name, oras cli should not fetch the content of this config.

Part of issue #415
Signed-off-by: wangxiaoxuan273 wangxiaoxuan119@gmail.com

Signed-off-by: wangxiaoxuan273 <wangxiaoxuan119@gmail.com>
Copy link
Contributor

@qweeah qweeah left a comment

Choose a reason for hiding this comment

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

LGTM

cmd/oras/pull.go Outdated
@@ -120,6 +120,9 @@ func runPull(opts pullOptions) error {
// Note: For a manifest, the 0th indexed element is always a
// manifest config.
if s.MediaType == configMediaType || (configMediaType == "" && i == 0 && isManifestMediaType(desc.MediaType)) {
if configPath == "" {
Copy link
Contributor

Choose a reason for hiding this comment

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

What if a config is named but configPath is empty? In that case, we should download it, shouldn’t we?

Signed-off-by: wangxiaoxuan273 <wangxiaoxuan119@gmail.com>
Copy link
Contributor

@shizhMSFT shizhMSFT left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@lizMSFT lizMSFT left a comment

Choose a reason for hiding this comment

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

LGTM

@codecov-commenter
Copy link

Codecov Report

Merging #509 (9421414) into main (a6a360e) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main     #509   +/-   ##
=======================================
  Coverage   72.68%   72.68%           
=======================================
  Files           9        9           
  Lines         388      388           
=======================================
  Hits          282      282           
  Misses         85       85           
  Partials       21       21           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@shizhMSFT shizhMSFT merged commit 27e9834 into oras-project:main Aug 19, 2022
@qweeah
Copy link
Contributor

qweeah commented Aug 19, 2022

Below command should download demo.config, foo and bar:

oras pull localhost:5000/oras:test

Manifest content of localhost:5000/oras:test:

{
  "schemaVersion": 2,
  "mediaType": "application/vnd.oci.image.manifest.v1+json",
  "config": {
    "mediaType": "application/vnd.unknown.config.v1+json",
    "digest": "sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a",
    "size": 2,
    "annotations": {
      "org.opencontainers.image.title": "demo.config"
    }
  },
  "layers": [
    {
      "mediaType": "application/vnd.oci.image.layer.v1.tar",
      "digest": "sha256:b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c",
      "size": 4
      "annotations": {
        "org.opencontainers.image.title": "foo"
      }
    },
    {
      "mediaType": "application/vnd.oci.image.layer.v1.tar",
      "digest": "sha256:7d865e959b2466918c9863afca942d0fb89d7c9ac0c99bafc3749504ded97730",
      "size": 4,
      "annotations": {
        "org.opencontainers.image.title": "bar"
      }
    }
  ]
}

@wangxiaoxuan273 wangxiaoxuan273 deleted the unnamed branch August 19, 2022 03:23
TerryHowe pushed a commit to TerryHowe/oras that referenced this pull request Feb 2, 2023
…-project#509)

Signed-off-by: wangxiaoxuan273 <wangxiaoxuan119@gmail.com>
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.

5 participants