From f2220f960d32d5bae023ea7b0f4ccb253fbc3212 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Wed, 15 Nov 2023 21:53:45 +0100 Subject: [PATCH 1/3] Update to Go 1.20 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miloslav Trmač --- go.mod | 2 +- install.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/go.mod b/go.mod index c99b1dece9..097d50b2ac 100644 --- a/go.mod +++ b/go.mod @@ -1,7 +1,7 @@ module github.com/containers/skopeo // Minimum required golang version -go 1.19 // ***** ATTENTION WARNING CAUTION DANGER ****** +go 1.20 // ***** ATTENTION WARNING CAUTION DANGER ****** // Go versions 1.21 and later will AUTO-UPDATE based // on currently running tools and the (new) `toolchain` diff --git a/install.md b/install.md index 4caf526c50..f7f4b04467 100644 --- a/install.md +++ b/install.md @@ -139,7 +139,7 @@ located at [https://github.com/containers/image_build/tree/main/skopeo](https:// Otherwise, read on for building and installing it from source: -To build the `skopeo` binary you need at least Go 1.19. +To build the `skopeo` binary you need at least Go 1.20. There are two ways to build skopeo: in a container, or locally without a container. Choose the one which better matches your needs and environment. From 4a43163fbadaac79e70f5826f1d184a0e0bc274d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Wed, 15 Nov 2023 22:49:44 +0100 Subject: [PATCH 2/3] Use strings.CutPrefix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miloslav Trmač --- cmd/skopeo/list_tags.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/cmd/skopeo/list_tags.go b/cmd/skopeo/list_tags.go index 98b46f8b61..fa271e4495 100644 --- a/cmd/skopeo/list_tags.go +++ b/cmd/skopeo/list_tags.go @@ -78,16 +78,12 @@ See skopeo-list-tags(1) section "REPOSITORY NAMES" for the expected format // Customized version of the alltransports.ParseImageName and docker.ParseReference that does not place a default tag in the reference // Would really love to not have this, but needed to enforce tag-less and digest-less names func parseDockerRepositoryReference(refString string) (types.ImageReference, error) { - if !strings.HasPrefix(refString, docker.Transport.Name()+"://") { + dockerRefString, ok := strings.CutPrefix(refString, docker.Transport.Name()+"://") + if !ok { return nil, fmt.Errorf("docker: image reference %s does not start with %s://", refString, docker.Transport.Name()) } - _, dockerImageName, hasColon := strings.Cut(refString, ":") - if !hasColon { - return nil, fmt.Errorf(`Invalid image name "%s", expected colon-separated transport:reference`, refString) - } - - ref, err := reference.ParseNormalizedNamed(strings.TrimPrefix(dockerImageName, "//")) + ref, err := reference.ParseNormalizedNamed(dockerRefString) if err != nil { return nil, err } From a75ed8166826a69c2f2ff2b5e50e483c6d956ba8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Sat, 9 Mar 2024 22:51:50 +0100 Subject: [PATCH 3/3] Use strings.CutSuffix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miloslav Trmač --- integration/utils.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integration/utils.go b/integration/utils.go index f0e4484323..7f75c95b8d 100644 --- a/integration/utils.go +++ b/integration/utils.go @@ -268,8 +268,8 @@ func decompressDir(t *testing.T, dir string) { rawLayer["size"] = uncompressedSize var mimeType string getRawMapField(t, rawLayer, "mediaType", &mimeType) - if strings.HasSuffix(mimeType, ".gzip") { // This should use CutSuffix with Go ≥1.20 - rawLayer["mediaType"] = strings.TrimSuffix(mimeType, ".gzip") + if uncompressedMIMEType, ok := strings.CutSuffix(mimeType, ".gzip"); ok { + rawLayer["mediaType"] = uncompressedMIMEType } rawLayers[i] = rawLayer