Skip to content

Commit

Permalink
fix: return error if content and password are both read from stdin (o…
Browse files Browse the repository at this point in the history
…ras-project#892)

Signed-off-by: Billy Zha <[email protected]>
  • Loading branch information
qweeah authored Mar 17, 2023
1 parent dbc0cec commit 3cce80f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/oras/manifest/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ Example - Push a manifest to an OCI layout folder 'layout-dir' and tag with 'v1'
`,
Args: cobra.ExactArgs(2),
PreRunE: func(cmd *cobra.Command, args []string) error {
opts.fileRef = args[1]
if opts.fileRef == "-" && opts.PasswordFromStdin {
return errors.New("`-` read file from input and `--password-stdin` read password from input cannot be both used")
}
refs := strings.Split(args[0], ",")
opts.RawReference = refs[0]
opts.extraRefs = refs[1:]
opts.fileRef = args[1]
return option.Parse(&opts)
},
RunE: func(_ *cobra.Command, args []string) error {
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 @@ -67,6 +67,13 @@ var _ = Describe("ORAS beginners:", func() {
MatchErrKeyWords("Error:").
Exec()
})

It("should fail pushing with a manifest from stdin without media type flag", func() {
tag := "from-stdin"
ORAS("manifest", "push", RegistryRef(Host, ImageRepo, tag), "-", "--password-stdin", "--media-type", "application/vnd.oci.image.manifest.v1+json").
ExpectFailure().
MatchErrKeyWords("`-`", "`--password-stdin`", " cannot be both used").Exec()
})
})

When("running `manifest fetch`", func() {
Expand Down

0 comments on commit 3cce80f

Please sign in to comment.