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: ignore --pretty when --output is used for oras manifest fetch #1363

Merged
merged 2 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion cmd/oras/root/manifest/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,11 @@ Example - Fetch raw manifest from an OCI layout archive file 'layout.tar':
switch {
case opts.outputPath == "-" && opts.Template != "":
return fmt.Errorf("`--output -` cannot be used with `--format %s` at the same time", opts.Template)
case opts.OutputDescriptor && opts.outputPath == "-":
case opts.outputPath == "-" && opts.OutputDescriptor:
return fmt.Errorf("`--descriptor` cannot be used with `--output -` at the same time")
// ignore --pretty when output to a file
case opts.outputPath != "" && opts.outputPath != "-":
opts.Pretty.Pretty = false
}
if err := oerrors.CheckMutuallyExclusiveFlags(cmd.Flags(), "format", "pretty"); err != nil {
return err
Expand Down
7 changes: 7 additions & 0 deletions test/e2e/suite/command/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,13 @@ var _ = Describe("1.1 registry users:", func() {
MatchFile(fetchPath, multi_arch.Manifest, DefaultTimeout)
})

It("should ignore --pretty when fetching manifest to a file", func() {
fetchPath := filepath.Join(GinkgoT().TempDir(), "fetchedImage")
ORAS("manifest", "fetch", RegistryRef(ZOTHost, ImageRepo, multi_arch.Tag), "--output", fetchPath, "--pretty").
Exec()
MatchFile(fetchPath, multi_arch.Manifest, DefaultTimeout)
})

It("should fetch manifest to file and output json", func() {
fetchPath := filepath.Join(GinkgoT().TempDir(), "fetchedImage")
digest := multi_arch.LinuxAMD64.Digest.String()
Expand Down
Loading