From 983791c49e2e1dd82b1dd35fbe5186a4cd124983 Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Mon, 9 Dec 2024 16:20:09 +0800 Subject: [PATCH 1/4] build(deps): bump golang and dependencies (#1572) Signed-off-by: Billy Zha --- .github/workflows/release-github.yml | 2 +- Dockerfile | 2 +- go.mod | 2 +- test/e2e/go.mod | 2 +- test/e2e/go.work | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/release-github.yml b/.github/workflows/release-github.yml index e1c066139..6e70aa2c4 100644 --- a/.github/workflows/release-github.yml +++ b/.github/workflows/release-github.yml @@ -29,7 +29,7 @@ jobs: - name: setup go environment uses: actions/setup-go@v5 with: - go-version: '1.23.0' + go-version: '1.23.4' - name: run goreleaser uses: goreleaser/goreleaser-action@v6 with: diff --git a/Dockerfile b/Dockerfile index f999e0281..1cf6ee683 100644 --- a/Dockerfile +++ b/Dockerfile @@ -11,7 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -FROM --platform=$BUILDPLATFORM docker.io/library/golang:1.23.0-alpine as builder +FROM --platform=$BUILDPLATFORM docker.io/library/golang:1.23.4-alpine as builder ARG TARGETPLATFORM RUN apk add git make ENV ORASPKG /oras diff --git a/go.mod b/go.mod index 856edbc98..ad3700605 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module oras.land/oras -go 1.23.0 +go 1.23.1 require ( github.com/Masterminds/sprig/v3 v3.3.0 diff --git a/test/e2e/go.mod b/test/e2e/go.mod index 9841a41dc..53ca195ac 100644 --- a/test/e2e/go.mod +++ b/test/e2e/go.mod @@ -1,6 +1,6 @@ module oras.land/oras/test/e2e -go 1.23.0 +go 1.23.1 require ( github.com/onsi/ginkgo/v2 v2.22.0 diff --git a/test/e2e/go.work b/test/e2e/go.work index 30c306ef4..7607458b7 100644 --- a/test/e2e/go.work +++ b/test/e2e/go.work @@ -1,4 +1,4 @@ -go 1.23.0 +go 1.23.1 use ( . From 2ca02f6f6514200366df26ba9ef6d1b311629dad Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Mon, 9 Dec 2024 08:43:19 +0000 Subject: [PATCH 2/4] bump: tag and release ORAS CLI v1.3.0-beta.1 Signed-off-by: Billy Zha --- internal/version/version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/version/version.go b/internal/version/version.go index 0244b2cc2..546aca8b4 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -17,7 +17,7 @@ package version var ( // Version is the current version of the oras. - Version = "1.2.0" + Version = "1.3.0-beta.1" // BuildMetadata is the extra build time data BuildMetadata = "unreleased" // GitCommit is the git sha1 From 4b55afe53cdd9eb8177a49312f3812d46c676f4a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 10 Dec 2024 05:50:02 -0700 Subject: [PATCH 3/4] build(deps): bump github.com/onsi/gomega from 1.36.0 to 1.36.1 in /test/e2e (#1580) Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Terry Howe --- test/e2e/go.mod | 2 +- test/e2e/go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/test/e2e/go.mod b/test/e2e/go.mod index 53ca195ac..350acf445 100644 --- a/test/e2e/go.mod +++ b/test/e2e/go.mod @@ -4,7 +4,7 @@ go 1.23.1 require ( github.com/onsi/ginkgo/v2 v2.22.0 - github.com/onsi/gomega v1.36.0 + github.com/onsi/gomega v1.36.1 github.com/opencontainers/go-digest v1.0.0 github.com/opencontainers/image-spec v1.1.0 gopkg.in/yaml.v2 v2.4.0 diff --git a/test/e2e/go.sum b/test/e2e/go.sum index efeff1d22..b778761b6 100644 --- a/test/e2e/go.sum +++ b/test/e2e/go.sum @@ -10,8 +10,8 @@ github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db h1:097atOisP2aRj7vFgY github.com/google/pprof v0.0.0-20241029153458-d1b30febd7db/go.mod h1:vavhavw2zAxS5dIdcRluK6cSGGPlZynqzFM8NdvU144= github.com/onsi/ginkgo/v2 v2.22.0 h1:Yed107/8DjTr0lKCNt7Dn8yQ6ybuDRQoMGrNFKzMfHg= github.com/onsi/ginkgo/v2 v2.22.0/go.mod h1:7Du3c42kxCUegi0IImZ1wUQzMBVecgIHjR1C+NkhLQo= -github.com/onsi/gomega v1.36.0 h1:Pb12RlruUtj4XUuPUqeEWc6j5DkVVVA49Uf6YLfC95Y= -github.com/onsi/gomega v1.36.0/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog= +github.com/onsi/gomega v1.36.1 h1:bJDPBO7ibjxcbHMgSCoo4Yj18UWbKDlLwX1x9sybDcw= +github.com/onsi/gomega v1.36.1/go.mod h1:PvZbdDc8J6XJEpDK4HCuRBm8a6Fzp9/DmhC9C7yFlog= github.com/opencontainers/go-digest v1.0.0 h1:apOUWs51W5PlhuyGyz9FCeeBIOUDA/6nW8Oi/yOhh5U= github.com/opencontainers/go-digest v1.0.0/go.mod h1:0JzlMkj0TRzQZfJkVvzbP0HBR3IKzErnv2BNG4W4MAM= github.com/opencontainers/image-spec v1.1.0 h1:8SG7/vwALn54lVB/0yZ/MMwhFrPYtpEHQb2IpWsCzug= From 084400464d5765e90e79f804f6b4c0f66c1c9f27 Mon Sep 17 00:00:00 2001 From: Xiaoxuan Wang <103478229+wangxiaoxuan273@users.noreply.github.com> Date: Wed, 11 Dec 2024 15:13:39 +0800 Subject: [PATCH 4/4] fix: handle errors returned by `Close()` in write paths (#1581) Signed-off-by: Xiaoxuan Wang --- cmd/oras/internal/display/content/manifest_fetch.go | 8 ++++++-- cmd/oras/internal/display/content/manifest_index.go | 8 ++++++-- cmd/oras/root/pull.go | 8 ++++++-- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/cmd/oras/internal/display/content/manifest_fetch.go b/cmd/oras/internal/display/content/manifest_fetch.go index 9dcf7347b..de8f06772 100644 --- a/cmd/oras/internal/display/content/manifest_fetch.go +++ b/cmd/oras/internal/display/content/manifest_fetch.go @@ -31,14 +31,18 @@ type manifestFetch struct { outputPath string } -func (h *manifestFetch) OnContentFetched(desc ocispec.Descriptor, manifest []byte) error { +func (h *manifestFetch) OnContentFetched(desc ocispec.Descriptor, manifest []byte) (eventErr error) { out := h.stdout if h.outputPath != "-" && h.outputPath != "" { f, err := os.Create(h.outputPath) if err != nil { return fmt.Errorf("failed to open %q: %w", h.outputPath, err) } - defer f.Close() + defer func() { + if err := f.Close(); eventErr == nil { + eventErr = err + } + }() out = f } return output.PrintJSON(out, manifest, h.pretty) diff --git a/cmd/oras/internal/display/content/manifest_index.go b/cmd/oras/internal/display/content/manifest_index.go index b040aa998..6c07506fe 100644 --- a/cmd/oras/internal/display/content/manifest_index.go +++ b/cmd/oras/internal/display/content/manifest_index.go @@ -44,14 +44,18 @@ func NewManifestIndexCreateHandler(out io.Writer, pretty bool, outputPath string } // OnContentCreated is called after index content is created. -func (h *manifestIndexCreate) OnContentCreated(manifest []byte) error { +func (h *manifestIndexCreate) OnContentCreated(manifest []byte) (eventErr error) { out := h.stdout if h.outputPath != "" && h.outputPath != "-" { f, err := os.Create(h.outputPath) if err != nil { return fmt.Errorf("failed to open %q: %w", h.outputPath, err) } - defer f.Close() + defer func() { + if err := f.Close(); eventErr == nil { + eventErr = err + } + }() out = f } return output.PrintJSON(out, manifest, h.pretty) diff --git a/cmd/oras/root/pull.go b/cmd/oras/root/pull.go index e7b558fc3..60bd60a32 100644 --- a/cmd/oras/root/pull.go +++ b/cmd/oras/root/pull.go @@ -121,7 +121,7 @@ Example - Pull artifact files from an OCI layout archive 'layout.tar': return oerrors.Command(cmd, &opts.Target) } -func runPull(cmd *cobra.Command, opts *pullOptions) error { +func runPull(cmd *cobra.Command, opts *pullOptions) (pullError error) { ctx, logger := command.GetLogger(cmd, &opts.Common) statusHandler, metadataHandler, err := display.NewPullHandler(opts.Printer, opts.Format, opts.Path, opts.TTY) if err != nil { @@ -148,7 +148,11 @@ func runPull(cmd *cobra.Command, opts *pullOptions) error { if err != nil { return err } - defer dst.Close() + defer func() { + if err := dst.Close(); pullError == nil { + pullError = err + } + }() dst.AllowPathTraversalOnWrite = opts.PathTraversal dst.DisableOverwrite = opts.KeepOldFiles