-
Notifications
You must be signed in to change notification settings - Fork 181
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
feat: add manifest fetch-config #540
Conversation
Signed-off-by: Haoliang Yue <[email protected]>
Codecov Report
@@ Coverage Diff @@
## main #540 +/- ##
==========================================
+ Coverage 72.44% 72.54% +0.10%
==========================================
Files 13 14 +1
Lines 508 510 +2
==========================================
+ Hits 368 370 +2
Misses 112 112
Partials 28 28
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
Signed-off-by: Haoliang Yue <[email protected]>
Signed-off-by: Haoliang Yue <[email protected]>
Signed-off-by: Haoliang Yue <[email protected]>
cmd/oras/manifest/fetchConfig.go
Outdated
} | ||
|
||
cmd.Flags().StringVarP(&opts.outputPath, "output", "o", "", "output file path") | ||
cmd.Flags().StringVarP(&opts.mediaType, "media-type", "", "", "media type of the manifest config") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove this flag as it does not have a user scenario and it confuses users? /cc @FeynmanZhou @yizha1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove this flag as it does not have a user scenario and it confuses users? /cc @FeynmanZhou @yizha1
I was tried to support the same feature as oras pull --config
, but if users only use this command for an image manifest, --media-type
is not required, because we can always recognize the config for an image manifest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed --media-type
for now. I think if only image manifest type support this manifest fetch-config
command, this argument is unnecessary.
cmd/oras/manifest/fetchConfig.go
Outdated
func fetchConfigDesc(ctx context.Context, src oras.ReadOnlyTarget, reference string, configMediaType string) (ocispec.Descriptor, error) { | ||
// fetch manifest descriptor | ||
manifestDesc, err := oras.Resolve(ctx, src, reference, oras.ResolveOptions{}) | ||
if err != nil { | ||
return ocispec.Descriptor{}, err | ||
} | ||
|
||
// fetch config descriptor | ||
successors, err := content.Successors(ctx, src, manifestDesc) | ||
if err != nil { | ||
return ocispec.Descriptor{}, err | ||
} | ||
for i, s := range successors { | ||
if s.MediaType == configMediaType || (configMediaType == "" && i == 0 && descriptor.IsImageManifest(manifestDesc.MediaType)) { | ||
return s, nil | ||
} | ||
} | ||
return ocispec.Descriptor{}, fmt.Errorf("%s does not have a config", reference) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we know it is an image manifest, we can call oras.FetchBytes()
and then unmarshal it to extract the config descriptor. The simplified operation not only has less network calls but also cleaner.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we know it is an image manifest, we can call
oras.FetchBytes()
and then unmarshal it to extract the config descriptor. The simplified operation not only has less network calls but also cleaner.
Are we sure that manifest fetch-config
is only used for image manifest? I see in oras pull --config
, users can provided the media type of the config file. If the manifest is not an image manifest, the command will fetch the blob who has a matched media type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we sure that
manifest fetch-config
is only used for image manifest?
Yes, manifest fetch-config
should only run against image manifests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oras manifest fetch-config
should return error if the manifest is not an image manifest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved as required.
@yuehaoliang-microsoft Can we have a UX described in the #131 or https://hackmd.io/aLxws7mhSZukfFzx3PKq3w |
Signed-off-by: Haoliang Yue <[email protected]>
Signed-off-by: Haoliang Yue <[email protected]>
I attached a few picture about UX in #131, and also updates the HackMD documentation. |
Signed-off-by: Haoliang Yue <[email protected]>
Signed-off-by: Haoliang Yue <[email protected]>
Signed-off-by: Haoliang Yue <[email protected]>
Signed-off-by: Haoliang Yue <[email protected]>
|
||
** This command is in preview and under development. ** | ||
|
||
Example - Fetch the config: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a scenario missing:
oras manifest fetch-config --platform 'linux/arm/v5' localhost:5000/hello:latest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Supported option.Platform
.
Signed-off-by: Haoliang Yue <[email protected]>
cmd/oras/manifest/fetch_config.go
Outdated
// fetch manifest descriptor and content | ||
fetchOpts := oras.DefaultFetchBytesOptions | ||
fetchOpts.TargetPlatform = targetPlatform | ||
manifestDesc, manifestContent, err := oras.FetchBytes(ctx, src, reference, oras.DefaultFetchBytesOptions) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
manifestDesc, manifestContent, err := oras.FetchBytes(ctx, src, reference, oras.DefaultFetchBytesOptions) | |
manifestDesc, manifestContent, err := oras.FetchBytes(ctx, src, reference, fetchOpts) |
Signed-off-by: Haoliang Yue <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Signed-off-by: Haoliang Yue <[email protected]>
Resolve #131
Signed-off-by: Haoliang Yue [email protected]