Skip to content

Commit

Permalink
fix: return error when --format and --pretty are both used (oras-proj…
Browse files Browse the repository at this point in the history
…ect#1359)

Signed-off-by: Xiaoxuan Wang <wangxiaoxuan119@gmail.com>
  • Loading branch information
wangxiaoxuan273 authored and FeynmanZhou committed May 11, 2024
1 parent 9f142b0 commit 62ce5f9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 6 additions & 2 deletions cmd/oras/root/manifest/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,15 @@ 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.Template != "":
return fmt.Errorf("`--descriptor` cannot be used with `--format %s` at the same time", opts.Template)
case opts.OutputDescriptor && opts.outputPath == "-":
return fmt.Errorf("`--descriptor` cannot be used with `--output -` at the same time")
}
if err := oerrors.CheckMutuallyExclusiveFlags(cmd.Flags(), "format", "pretty"); err != nil {
return err
}
if err := oerrors.CheckMutuallyExclusiveFlags(cmd.Flags(), "format", "descriptor"); err != nil {
return err
}
opts.RawReference = args[0]
return option.Parse(cmd, &opts)
},
Expand Down
2 changes: 2 additions & 0 deletions test/e2e/suite/command/manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ var _ = Describe("ORAS beginners:", func() {
ExpectFailure().Exec()
ORAS("manifest", "fetch", RegistryRef(ZOTHost, ImageRepo, foobar.Tag), "--output", "-", "--descriptor").
ExpectFailure().Exec()
ORAS("manifest", "fetch", RegistryRef(ZOTHost, ImageRepo, foobar.Tag), "--format", "test", "--pretty").
ExpectFailure().Exec()
})
})

Expand Down

0 comments on commit 62ce5f9

Please sign in to comment.