From de3401b9d1fc963c10d50613d5ee3715cf908eae Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Tue, 24 Oct 2023 11:29:36 +0200 Subject: [PATCH 1/4] Update Go runtime to 1.21.3 --- .go-version | 2 +- CHANGELOG.md | 2 ++ Dockerfile | 2 +- categories.go | 3 ++- internal/util/strings.go | 15 --------------- packages/package.go | 8 ++++---- packages/packages.go | 4 ++-- 7 files changed, 12 insertions(+), 24 deletions(-) delete mode 100644 internal/util/strings.go diff --git a/.go-version b/.go-version index 8909929f6..bae5c7f66 100644 --- a/.go-version +++ b/.go-version @@ -1 +1 @@ -1.20.7 +1.21.3 diff --git a/CHANGELOG.md b/CHANGELOG.md index 02bbf2754..b08240862 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Bugfixes +* Update Go runtime to 1.21.3. [#1102](https://github.com/elastic/package-registry/pull/1102) + ### Added ### Deprecated diff --git a/Dockerfile b/Dockerfile index 216c64493..675c2620e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,7 +2,7 @@ # It expects packages to be mounted under /packages/package-registry or have a config file loaded into /package-registry/config.yml # Build binary -ARG GO_VERSION=1.20.7 +ARG GO_VERSION=1.21.3 FROM golang:${GO_VERSION} AS builder COPY ./ /package-registry diff --git a/categories.go b/categories.go index b3f05b960..e5c344406 100644 --- a/categories.go +++ b/categories.go @@ -9,6 +9,7 @@ import ( "fmt" "net/http" "net/url" + "slices" "sort" "strconv" "strings" @@ -194,7 +195,7 @@ func getCategories(ctx context.Context, pkgs packages.Packages, includePolicyTem } } - if !p.HasCategory(c) && !util.StringsContains(extraPackageCategories, c) { + if !p.HasCategory(c) && !slices.Contains(extraPackageCategories, c) { extraPackageCategories = append(extraPackageCategories, c) categories[c].Count = categories[c].Count + 1 } diff --git a/internal/util/strings.go b/internal/util/strings.go deleted file mode 100644 index c72b2e62d..000000000 --- a/internal/util/strings.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one -// or more contributor license agreements. Licensed under the Elastic License; -// you may not use this file except in compliance with the Elastic License. - -package util - -// StringsContains function checks if needle is present in the stack. -func StringsContains(haystack []string, needle string) bool { - for _, h := range haystack { - if h == needle { - return true - } - } - return false -} diff --git a/packages/package.go b/packages/package.go index a222c83cc..1604fcc89 100644 --- a/packages/package.go +++ b/packages/package.go @@ -8,6 +8,7 @@ import ( "fmt" "os" "path" + "slices" "strings" "github.com/Masterminds/semver/v3" @@ -17,7 +18,6 @@ import ( "github.com/elastic/go-ucfg/yaml" "github.com/elastic/package-registry/categories" - "github.com/elastic/package-registry/internal/util" ) const ( @@ -382,7 +382,7 @@ func (p *Package) HasPolicyTemplateWithCategory(category string) bool { } func hasCategory(categories []string, category string) bool { - if util.StringsContains(categories, category) { + if slices.Contains(categories, category) { return true } @@ -392,7 +392,7 @@ func hasCategory(categories []string, category string) bool { continue } - if util.StringsContains(categories, subcategory.Name) { + if slices.Contains(categories, subcategory.Name) { return true } } @@ -414,7 +414,7 @@ func (p *Package) WorksWithCapabilities(capabilities []string) bool { } for _, requiredCapability := range p.Conditions.Elastic.Capabilities { - if !util.StringsContains(capabilities, requiredCapability) { + if !slices.Contains(capabilities, requiredCapability) { return false } } diff --git a/packages/packages.go b/packages/packages.go index 656672008..0e7a7ee67 100644 --- a/packages/packages.go +++ b/packages/packages.go @@ -10,6 +10,7 @@ import ( "fmt" "os" "path/filepath" + "slices" "strings" "time" @@ -19,7 +20,6 @@ import ( "go.elastic.co/apm/v2" "go.uber.org/zap" - "github.com/elastic/package-registry/internal/util" "github.com/elastic/package-registry/metrics" ) @@ -504,7 +504,7 @@ func filterPolicyTemplates(p Package, category string) *Package { var updatedPolicyTemplates []PolicyTemplate var updatedBasePolicyTemplates []BasePolicyTemplate for i, pt := range p.PolicyTemplates { - if util.StringsContains(pt.Categories, category) { + if slices.Contains(pt.Categories, category) { updatedPolicyTemplates = append(updatedPolicyTemplates, pt) updatedBasePolicyTemplates = append(updatedBasePolicyTemplates, p.BasePackage.BasePolicyTemplates[i]) } From 8dd287884c9d3f73d11ab6e12a1ca30a1393121d Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Tue, 24 Oct 2023 11:43:47 +0200 Subject: [PATCH 2/4] Update go.mod too --- go.mod | 2 +- go.sum | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 3dd52a399..2555730d1 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/elastic/package-registry -go 1.20 +go 1.21.0 require ( cloud.google.com/go/storage v1.33.0 diff --git a/go.sum b/go.sum index 8a84f2e1b..04ec20ede 100644 --- a/go.sum +++ b/go.sum @@ -8,6 +8,7 @@ cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2Aawl cloud.google.com/go/iam v1.1.3 h1:18tKG7DzydKWUnLjonWcJO6wjSCAtzh4GcRKlH/Hrzc= cloud.google.com/go/iam v1.1.3/go.mod h1:3khUlaBXfPKKe7huYgEpDn6FtgRyMEqbkvBxrQyY5SE= cloud.google.com/go/kms v1.15.2 h1:lh6qra6oC4AyWe5fUUUBe/S27k12OHAleOOOw6KakdE= +cloud.google.com/go/kms v1.15.2/go.mod h1:3hopT4+7ooWRCjc2DxgnpESFxhIraaI2IpAVUEhbT/w= cloud.google.com/go/pubsub v1.33.0 h1:6SPCPvWav64tj0sVX/+npCBKhUi/UjJehy9op/V3p2g= cloud.google.com/go/pubsub v1.33.0/go.mod h1:f+w71I33OMyxf9VpMVcZbnG5KSUkCOUHYpFd5U1GdRc= cloud.google.com/go/storage v1.33.0 h1:PVrDOkIC8qQVa1P3SXGpQvfuJhN2LHOoyZvWs8D2X5M= @@ -31,6 +32,7 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs 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/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= +github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/elastic/go-licenser v0.4.1 h1:1xDURsc8pL5zYT9R29425J3vkHdt4RT5TNEMeRN48x4= github.com/elastic/go-licenser v0.4.1/go.mod h1:V56wHMpmdURfibNBggaSBfqgPxyT1Tldns1i87iTEvU= github.com/elastic/go-sysinfo v1.7.1 h1:Wx4DSARcKLllpKT2TnFVdSUJOsybqMYCNQZq1/wO+s0= @@ -75,7 +77,9 @@ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/martian/v3 v3.3.2 h1:IqNFLAmvJOgVlpdEBiQbDc2EwKW77amAycfTuWKdfvw= +github.com/google/martian/v3 v3.3.2/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= github.com/google/renameio/v2 v2.0.0 h1:UifI23ZTGY8Tt29JbYFiuyIU3eX+RNFtUwefq9qAhxg= github.com/google/renameio/v2 v2.0.0/go.mod h1:BtmJXm5YlszgC+TD4HOEEUFgkJP3nLxehU6hfe7jRt4= github.com/google/s2a-go v0.1.7 h1:60BLSyTrOV4/haCDW4zb1guZItoSq8foHCXrAnjBo/o= @@ -101,22 +105,32 @@ github.com/jessevdk/go-flags v1.4.0/go.mod h1:4FA24M0QyGHXBuZZK/XkWh8h0e1EYbRYJS github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901 h1:rp+c0RAYOWj8l6qbCUTSiRLG/iKnW3K3/QfPPuSsBt4= github.com/joeshaw/multierror v0.0.0-20140124173710-69b34d4ec901/go.mod h1:Z86h9688Y0wesXCyonoVr47MasHilkuLMqGhRZ4Hpak= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= +github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= github.com/klauspost/compress v1.16.7 h1:2mk3MPGNzKyxErAw8YaohYh69+pa4sIQSC0fPGCFR9I= +github.com/klauspost/compress v1.16.7/go.mod h1:ntbaceVETuRiXiv4DpjP66DpAtAGkEQskQzEyD//IeE= github.com/klauspost/cpuid/v2 v2.2.5 h1:0E5MSMDEoAulmXNFquVs//DdoomxaoTY1kUhbc/qbZg= +github.com/klauspost/cpuid/v2 v2.2.5/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/magefile/mage v1.15.0 h1:BvGheCMAsG3bWUDbZ8AyXXpCNwU9u5CB6sM+HNb9HYg= github.com/magefile/mage v1.15.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/minio/md5-simd v1.1.2 h1:Gdi1DZK69+ZVMoNHRXJyNcxrMA4dSxoYHZSQbirFg34= +github.com/minio/md5-simd v1.1.2/go.mod h1:MzdKDxYpY2BT9XQFocsiZf/NKVtR7nkE4RoEpN+20RM= github.com/minio/minio-go/v7 v7.0.63 h1:GbZ2oCvaUdgT5640WJOpyDhhDxvknAJU2/T3yurwcbQ= +github.com/minio/minio-go/v7 v7.0.63/go.mod h1:Q6X7Qjb7WMhvG65qKf4gUgA5XaiSox74kR1uAEjxRS4= github.com/minio/sha256-simd v1.0.1 h1:6kaan5IFmwTNynnKKpDHe6FWHohJOHhCPchzK49dzMM= +github.com/minio/sha256-simd v1.0.1/go.mod h1:Pz6AKMiUdngCLpeTL/RJY1M9rUuPMYujV5xJjtbRSN8= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= +github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -137,8 +151,11 @@ github.com/prometheus/procfs v0.0.0-20190425082905-87a4384529e0/go.mod h1:TjEm7z github.com/prometheus/procfs v0.11.1 h1:xRC8Iq1yyca5ypa9n1EZnWZkt7dwcoRPQwX/5gwaUuI= github.com/prometheus/procfs v0.11.1/go.mod h1:eesXgaPo1q7lBpVMoMy0ZOFTth9hBn4W/y0/p/ScXhY= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= +github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/rs/xid v1.5.0 h1:mKX4bl4iPYJtEIxp6CYiUuLQ/8DYMoz0PUdtGgMFRVc= +github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= +github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= @@ -171,6 +188,7 @@ go.opencensus.io v0.24.0/go.mod h1:vNK8G9p7aAivkbmorf4v+7Hgx+Zs0yY+0fOtgBfjQKo= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/goleak v1.2.0 h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk= +go.uber.org/goleak v1.2.0/go.mod h1:XJYK+MuIchqpmGmUSAzotztawfKvYLUIgg7guXrwVUo= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ= go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= @@ -299,8 +317,10 @@ gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8 gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/hjson/hjson-go.v3 v3.0.1/go.mod h1:X6zrTSVeImfwfZLfgQdInl9mWjqPqgH90jom9nym/lw= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= +gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/yaml.v1 v1.0.0-20140924161607-9f9df34309c0/go.mod h1:WDnlLJ4WF5VGsH/HVa3CI79GS0ol3YnhVnKP89i0kNg= gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= From 0a0718a0dcf8ec704faaa03b9a5aa7515a27338a Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Tue, 24 Oct 2023 11:45:06 +0200 Subject: [PATCH 3/4] Update go.mod and buildkite scripts --- .buildkite/release-package-registry-distribution.yml | 2 +- .buildkite/scripts/triggerJenkinsJob/go.mod | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.buildkite/release-package-registry-distribution.yml b/.buildkite/release-package-registry-distribution.yml index cbfa52b33..38d9961a1 100644 --- a/.buildkite/release-package-registry-distribution.yml +++ b/.buildkite/release-package-registry-distribution.yml @@ -1,7 +1,7 @@ # yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json env: - SETUP_GOLANG_VERSION: '1.20.4' + SETUP_GOLANG_VERSION: '1.21.3' DOCKER_REGISTRY: 'docker.elastic.co' steps: diff --git a/.buildkite/scripts/triggerJenkinsJob/go.mod b/.buildkite/scripts/triggerJenkinsJob/go.mod index ba130f43d..b5a6dd6c6 100644 --- a/.buildkite/scripts/triggerJenkinsJob/go.mod +++ b/.buildkite/scripts/triggerJenkinsJob/go.mod @@ -1,6 +1,6 @@ module github.com/elastic/trigger-jenkins-buildkite-plugin -go 1.20 +go 1.21.0 require github.com/bndr/gojenkins v1.1.0 From db710a7079644f6aa74f6e77220f56abf0e02b0d Mon Sep 17 00:00:00 2001 From: Jaime Soriano Pastor Date: Tue, 24 Oct 2023 15:38:44 +0200 Subject: [PATCH 4/4] Remove unused variable --- .buildkite/release-package-registry-distribution.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.buildkite/release-package-registry-distribution.yml b/.buildkite/release-package-registry-distribution.yml index 38d9961a1..e0a6e5658 100644 --- a/.buildkite/release-package-registry-distribution.yml +++ b/.buildkite/release-package-registry-distribution.yml @@ -1,7 +1,6 @@ # yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json env: - SETUP_GOLANG_VERSION: '1.21.3' DOCKER_REGISTRY: 'docker.elastic.co' steps: