Skip to content

Commit

Permalink
fix: push bug when multi tagging
Browse files Browse the repository at this point in the history
Signed-off-by: Billy Zha <[email protected]>
  • Loading branch information
qweeah committed Mar 2, 2023
1 parent 8c238a9 commit 6ff560c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cmd/oras/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Example - Push file "hi.txt" into an OCI layout folder 'layout-dir' with tag 'te
Args: cobra.MinimumNArgs(1),
PreRunE: func(cmd *cobra.Command, args []string) error {
refs := strings.Split(args[0], ",")
opts.RawReference = args[0]
opts.RawReference = refs[0]
opts.extraRefs = refs[1:]
opts.FileRefs = args[1:]
if opts.manifestConfigRef != "" {
Expand Down
19 changes: 19 additions & 0 deletions test/e2e/suite/command/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,25 @@ var _ = Describe("Remote registry users:", func() {
WithInput(fetched).Exec()
})

It("should push files and tag", func() {
repo := fmt.Sprintf("%s/%s", repoPrefix, "with-mediatype")
tempDir := CopyTestDataToTemp()
extraTag := "2e2"

ORAS("push", fmt.Sprintf("%s,%s", Reference(Host, repo, tag), extraTag), files[1], "-v").
MatchStatus(statusKeys, true, 1).
WithWorkDir(tempDir).Exec()
fetched := ORAS("manifest", "fetch", Reference(Host, repo, tag)).Exec().Out
Binary("jq", ".blobs[]", "--compact-output").
MatchTrimmedContent(fmt.Sprintf(layerDescriptorTemplate, ocispec.MediaTypeImageLayer)).
WithInput(fetched).Exec()

fetched = ORAS("manifest", "fetch", Reference(Host, repo, extraTag)).Exec().Out
Binary("jq", ".blobs[]", "--compact-output").
MatchTrimmedContent(fmt.Sprintf(layerDescriptorTemplate, ocispec.MediaTypeImageLayer)).
WithInput(fetched).Exec()
})

It("should push files with customized media types", func() {
repo := fmt.Sprintf("%s/%s", repoPrefix, "layer-mediatype")
layerType := "layer.type"
Expand Down

0 comments on commit 6ff560c

Please sign in to comment.