From 8bda262f901e8ef8404cf23d59c5f47f4280fdf3 Mon Sep 17 00:00:00 2001 From: Terry Howe Date: Tue, 7 Feb 2023 07:24:33 -0700 Subject: [PATCH 1/3] fix: Have make file fail with wrong go version (#785) Signed-off-by: Terry Howe --- Makefile | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 8bdd225cb..6957c0d93 100644 --- a/Makefile +++ b/Makefile @@ -17,6 +17,7 @@ CLI_PKG = $(PROJECT_PKG)/cmd/oras GIT_COMMIT = $(shell git rev-parse HEAD) GIT_TAG = $(shell git describe --tags --abbrev=0 --exact-match 2>/dev/null) GIT_DIRTY = $(shell test -n "`git status --porcelain`" && echo "dirty" || echo "clean") +GO_EXE = go TARGET_OBJS ?= checksums.txt darwin_amd64.tar.gz darwin_arm64.tar.gz linux_amd64.tar.gz linux_arm64.tar.gz linux_armv7.tar.gz linux_s390x.tar.gz windows_amd64.zip @@ -31,8 +32,8 @@ LDFLAGS += -X $(PROJECT_PKG)/internal/version.GitCommit=${GIT_COMMIT} LDFLAGS += -X $(PROJECT_PKG)/internal/version.GitTreeState=${GIT_DIRTY} .PHONY: test -test: vendor check-encoding - go test -race -v -coverprofile=coverage.txt -covermode=atomic ./... +test: tidy vendor check-encoding + $(GO_EXE) test -race -v -coverprofile=coverage.txt -covermode=atomic ./... .PHONY: covhtml covhtml: @@ -50,22 +51,22 @@ build-linux: build-linux-amd64 build-linux-arm64 build-linux-arm-v7 build-linux- .PHONY: build-linux-amd64 build-linux-amd64: - GOARCH=amd64 CGO_ENABLED=0 GOOS=linux go build -v --ldflags="$(LDFLAGS)" \ + GOARCH=amd64 CGO_ENABLED=0 GOOS=linux $(GO_EXE) build -v --ldflags="$(LDFLAGS)" \ -o bin/linux/amd64/$(CLI_EXE) $(CLI_PKG) .PHONY: build-linux-arm64 build-linux-arm64: - GOARCH=arm64 CGO_ENABLED=0 GOOS=linux go build -v --ldflags="$(LDFLAGS)" \ + GOARCH=arm64 CGO_ENABLED=0 GOOS=linux $(GO_EXE) build -v --ldflags="$(LDFLAGS)" \ -o bin/linux/arm64/$(CLI_EXE) $(CLI_PKG) .PHONY: build-linux-arm-v7 build-linux-arm-v7: - GOARCH=arm CGO_ENABLED=0 GOOS=linux go build -v --ldflags="$(LDFLAGS)" \ + GOARCH=arm CGO_ENABLED=0 GOOS=linux $(GO_EXE) build -v --ldflags="$(LDFLAGS)" \ -o bin/linux/arm/v7/$(CLI_EXE) $(CLI_PKG) .PHONY: build-linux-s390x build-linux-s390x: - GOARCH=s390x CGO_ENABLED=0 GOOS=linux go build -v --ldflags="$(LDFLAGS)" \ + GOARCH=s390x CGO_ENABLED=0 GOOS=linux $(GO_EXE) build -v --ldflags="$(LDFLAGS)" \ -o bin/linux/s390x/$(CLI_EXE) $(CLI_PKG) .PHONY: build-mac @@ -73,12 +74,12 @@ build-mac: build-mac-arm64 build-mac-amd64 .PHONY: build-mac-amd64 build-mac-amd64: - GOARCH=amd64 CGO_ENABLED=0 GOOS=darwin go build -v --ldflags="$(LDFLAGS)" \ + GOARCH=amd64 CGO_ENABLED=0 GOOS=darwin $(GO_EXE) build -v --ldflags="$(LDFLAGS)" \ -o bin/darwin/amd64/$(CLI_EXE) $(CLI_PKG) .PHONY: build-mac-arm64 build-mac-arm64: - GOARCH=arm64 CGO_ENABLED=0 GOOS=darwin go build -v --ldflags="$(LDFLAGS)" \ + GOARCH=arm64 CGO_ENABLED=0 GOOS=darwin $(GO_EXE) build -v --ldflags="$(LDFLAGS)" \ -o bin/darwin/arm64/$(CLI_EXE) $(CLI_PKG) .PHONY: build-windows @@ -86,12 +87,12 @@ build-windows: build-windows-amd64 build-windows-arm64 .PHONY: build-windows-amd64 build-windows-amd64: - GOARCH=amd64 CGO_ENABLED=0 GOOS=windows go build -v --ldflags="$(LDFLAGS)" \ + GOARCH=amd64 CGO_ENABLED=0 GOOS=windows $(GO_EXE) build -v --ldflags="$(LDFLAGS)" \ -o bin/windows/amd64/$(CLI_EXE).exe $(CLI_PKG) .PHONY: build-windows-arm64 build-windows-arm64: - GOARCH=arm64 CGO_ENABLED=0 GOOS=windows go build -v --ldflags="$(LDFLAGS)" \ + GOARCH=arm64 CGO_ENABLED=0 GOOS=windows $(GO_EXE) build -v --ldflags="$(LDFLAGS)" \ -o bin/windows/arm64/$(CLI_EXE).exe $(CLI_PKG) .PHONY: check-encoding @@ -102,9 +103,13 @@ check-encoding: fix-encoding: find cmd internal -type f -name "*.go" -exec sed -i -e "s/\r//g" {} + +.PHONY: tidy +tidy: + GO111MODULE=on $(GO_EXE) mod tidy + .PHONY: vendor vendor: - GO111MODULE=on go mod vendor + GO111MODULE=on $(GO_EXE) mod vendor .PHONY: fetch-dist fetch-dist: From 0866598561b50339c799ecc3c6a307b3843de130 Mon Sep 17 00:00:00 2001 From: Billy Zha Date: Fri, 10 Feb 2023 20:11:38 +0800 Subject: [PATCH 2/3] feat!: show subject digest in oras discover (#798) Changes in this PR prints resolved digest for root node of tree-view output in `oras discover`. Resolves #789 Signed-off-by: Billy Zha --- cmd/oras/attach.go | 10 +--------- cmd/oras/discover.go | 2 +- cmd/oras/internal/option/target.go | 11 ++++++++++- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/cmd/oras/attach.go b/cmd/oras/attach.go index 25710339d..c8b31a5c3 100644 --- a/cmd/oras/attach.go +++ b/cmd/oras/attach.go @@ -26,7 +26,6 @@ import ( "oras.land/oras-go/v2" "oras.land/oras-go/v2/content" "oras.land/oras-go/v2/content/file" - "oras.land/oras-go/v2/registry/remote" "oras.land/oras/cmd/oras/internal/option" ) @@ -164,14 +163,7 @@ func runAttach(opts attachOptions) error { digest := subject.Digest.String() if !strings.HasSuffix(opts.RawReference, digest) { - // Reassemble a reference with subject digest - if repo, ok := dst.(*remote.Repository); ok { - ref := repo.Reference - ref.Reference = subject.Digest.String() - opts.RawReference = ref.String() - } else if opts.Type == option.TargetTypeOCILayout { - opts.RawReference = fmt.Sprintf("%s@%s", opts.Path, subject.Digest) - } + opts.RawReference = fmt.Sprintf("%s@%s", opts.Path, subject.Digest) } fmt.Println("Attached to", opts.AnnotatedReference()) fmt.Println("Digest:", root.Digest) diff --git a/cmd/oras/discover.go b/cmd/oras/discover.go index e3c254d04..02904b92b 100644 --- a/cmd/oras/discover.go +++ b/cmd/oras/discover.go @@ -109,7 +109,7 @@ func runDiscover(opts discoverOptions) error { } if opts.outputType == "tree" { - root := tree.New(opts.Reference) + root := tree.New(fmt.Sprintf("%s@%s", opts.Path, desc.Digest)) err = fetchAllReferrers(ctx, repo, desc, opts.artifactType, root, &opts) if err != nil { return err diff --git a/cmd/oras/internal/option/target.go b/cmd/oras/internal/option/target.go index 4d75d8b99..bf0a4650a 100644 --- a/cmd/oras/internal/option/target.go +++ b/cmd/oras/internal/option/target.go @@ -41,7 +41,10 @@ type Target struct { RawReference string Type string Reference string //contains tag or digest - Path string + // Path contains + // - path to the OCI image layout target, or + // - registry and repository for the remote target + Path string isOCILayout bool } @@ -118,6 +121,9 @@ func (opts *Target) NewTarget(common Common) (oras.GraphTarget, error) { if err != nil { return nil, err } + tmp := repo.Reference + tmp.Reference = "" + opts.Path = tmp.String() opts.Reference = repo.Reference.Reference return repo, nil } @@ -153,6 +159,9 @@ func (opts *Target) NewReadonlyTarget(ctx context.Context, common Common) (ReadO if err != nil { return nil, err } + tmp := repo.Reference + tmp.Reference = "" + opts.Path = tmp.String() opts.Reference = repo.Reference.Reference return repo, nil } From d6240d66bfb6fe84073ea650dad2412f56eea3d2 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 10 Feb 2023 12:21:34 +0000 Subject: [PATCH 3/3] build(deps): bump github.com/docker/cli from 23.0.0+incompatible to 23.0.1+incompatible (#795) --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index a4a70bf93..23793f39e 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module oras.land/oras go 1.20 require ( - github.com/docker/cli v23.0.0+incompatible + github.com/docker/cli v23.0.1+incompatible github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 github.com/need-being/go-tree v0.1.0 github.com/opencontainers/go-digest v1.0.0 diff --git a/go.sum b/go.sum index 8bee84111..53b781f07 100644 --- a/go.sum +++ b/go.sum @@ -7,8 +7,8 @@ github.com/danieljoos/wincred v1.1.0/go.mod h1:XYlo+eRTsVA9aHGp7NGjFkPla4m+DCL7h github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/docker/cli v23.0.0+incompatible h1:bcM4syaQ+EM/iczJTimMOGzvnzJBFPFEf4acS7sZ+RM= -github.com/docker/cli v23.0.0+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= +github.com/docker/cli v23.0.1+incompatible h1:LRyWITpGzl2C9e9uGxzisptnxAn1zfZKXy13Ul2Q5oM= +github.com/docker/cli v23.0.1+incompatible/go.mod h1:JLrzqnKDaYBop7H2jaqPtU4hHvMKP+vjCwu2uszcLI8= github.com/docker/docker v20.10.17+incompatible h1:JYCuMrWaVNophQTOrMMoSwudOVEfcegoZZrleKc1xwE= github.com/docker/docker v20.10.17+incompatible/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/docker-credential-helpers v0.6.4 h1:axCks+yV+2MR3/kZhAmy07yC56WZ2Pwu/fKWtKuZB0o=