From 4db0160764f841d2a3e700fc3c98ef65b4c194f9 Mon Sep 17 00:00:00 2001 From: Albert Safin Date: Sat, 23 Apr 2022 19:00:00 +0000 Subject: [PATCH] Update go to 1.18 Signed-off-by: Albert Safin --- .github/workflows/automerge.yaml | 2 +- .github/workflows/ci.yaml | 24 ++++---- .github/workflows/docker-push.yaml | 2 +- .gitignore | 3 + .golangci.yml | 11 ++-- Dockerfile | 10 ++-- go.mod | 63 ++++++++++++++++++++- go.sum | 7 ++- internal/{pkg => }/imports/gen.go | 5 +- internal/{pkg => }/imports/imports_linux.go | 2 +- tools.go | 23 ++++++++ 11 files changed, 121 insertions(+), 31 deletions(-) rename internal/{pkg => }/imports/gen.go (77%) rename internal/{pkg => }/imports/imports_linux.go (95%) create mode 100644 tools.go diff --git a/.github/workflows/automerge.yaml b/.github/workflows/automerge.yaml index 5695861..66641f9 100644 --- a/.github/workflows/automerge.yaml +++ b/.github/workflows/automerge.yaml @@ -101,7 +101,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v1 with: - go-version: 1.16 + go-version: 1.18 - name: Update version manually run: | branch=${{ needs.automerge.outputs.pr_branch_ref }} diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4fd1408..d9be596 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -39,7 +39,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v1 with: - go-version: 1.16 + go-version: 1.18 - name: Build run: go build -race ./... @@ -55,11 +55,11 @@ jobs: - name: Setup Go uses: actions/setup-go@v1 with: - go-version: 1.16 + go-version: 1.18 - name: golangci-lint uses: golangci/golangci-lint-action@v3 with: - version: v1.35.0 + version: v1.45.2 excludeFmtErrorf: name: exclude fmt.Errorf @@ -80,13 +80,13 @@ jobs: - uses: actions/checkout@v2 - name: Restrict dependencies on github.com/networkservicemesh/* env: - ALLOWED_REPOSITORIES: "api, sdk, sdk-k8s, sdk-kernel, sdk-sriov, sdk-vpp" + ALLOWED_REPOSITORIES: "api sdk sdk-k8s sdk-kernel sdk-sriov sdk-vpp" + run: | - for i in $(grep github.com/networkservicemesh/ go.mod | grep -v '^module' | sed 's;.*\(github.com\/networkservicemesh\/[^ ]*\).*;\1;g');do - if ! [ "$(echo ${ALLOWED_REPOSITORIES} | grep ${i#github.com/networkservicemesh/})" ]; then - echo Dependency on "${i}" is forbidden - exit 1 - fi; + for i in $(grep -v '// indirect' go.mod | gsed -n 's:^\tgithub.com/networkservicemesh/\([^ ]\+\) .*:\1:p'); do + ! [[ " $ALLOWED_REPOSITORIES " =~ " $i " ]] || continue + echo Dependency on "${i}" is forbidden + exit 1 done checkgomod: @@ -96,7 +96,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-go@v1 with: - go-version: 1.16 + go-version: 1.18 - run: go mod tidy - name: Check for changes run: | @@ -109,7 +109,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-go@v1 with: - go-version: 1.16 + go-version: 1.18 - run: go generate ./... - name: Check for changes run: | @@ -134,7 +134,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-go@v1 with: - go-version: 1.16 + go-version: 1.18 - name: Build container run: docker build . - name: Run tests diff --git a/.github/workflows/docker-push.yaml b/.github/workflows/docker-push.yaml index 40693f7..be2636f 100644 --- a/.github/workflows/docker-push.yaml +++ b/.github/workflows/docker-push.yaml @@ -24,7 +24,7 @@ jobs: - uses: actions/checkout@v2 - uses: actions/setup-go@v1 with: - go-version: 1.16 + go-version: 1.18 - name: Build ${NAME}:${GITHUB_SHA::8} image run: docker build . -t "${ORG}/${NAME}:${GITHUB_SHA::8}" --target runtime - name: Build ${NAME}:latest image diff --git a/.gitignore b/.gitignore index be19042..743e0e7 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,6 @@ .idea/ junit/ + +# Installed tools listed in tools.go +/.bin diff --git a/.golangci.yml b/.golangci.yml index b19ddec..dd7b933 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -10,8 +10,9 @@ linters-settings: values: regexp: company: .* - copyright-holder: Copyright \(c\) ({{year-range}}) {{company}}\n\n - copyright-holders: ({{copyright-holder}})+ + copyright-holder-curr: Copyright \(c\) ({{year-range}}) {{company}}\n\n + copyright-holder: Copyright \(c\) .*\n\n + copyright-holders: ({{copyright-holder}})*({{copyright-holder-curr}})+({{copyright-holder}})* errcheck: check-type-assertions: false check-blank: false @@ -24,7 +25,7 @@ linters-settings: - (github.com/sirupsen/logrus.FieldLogger).Warnf - (github.com/sirupsen/logrus.FieldLogger).Errorf - (github.com/sirupsen/logrus.FieldLogger).Fatalf - golint: + revive: min-confidence: 0.8 goimports: local-prefixes: github.com/networkservicemesh @@ -143,7 +144,7 @@ linters: - gocyclo - gofmt - goimports - - golint + - revive - gosec - gosimple - govet @@ -152,7 +153,7 @@ linters: # - lll - misspell - nakedret - - scopelint + - exportloopref - staticcheck - structcheck - stylecheck diff --git a/Dockerfile b/Dockerfile index f09da69..349d5cb 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,17 +1,17 @@ -FROM golang:1.16-buster as go +FROM golang:1.18-bullseye as go ENV GO111MODULE=on ENV CGO_ENABLED=0 ENV GOBIN=/bin -RUN go get github.com/go-delve/delve/cmd/dlv@v1.6.0 -RUN go get github.com/edwarnicke/dl +RUN go install github.com/go-delve/delve/cmd/dlv@v1.6.0 +RUN go install github.com/edwarnicke/dl@latest RUN dl https://github.com/spiffe/spire/releases/download/v0.11.1/spire-0.11.1-linux-x86_64-glibc.tar.gz | \ tar -xzvf - -C /bin --strip=3 ./spire-0.11.1/bin/spire-server ./spire-0.11.1/bin/spire-agent FROM go as build WORKDIR /build COPY go.mod go.sum ./ -COPY internal ./internal -RUN go build ./internal/pkg/imports +COPY ./internal/imports internal/imports +RUN go build ./internal/imports COPY . . RUN go build -o /bin/nse-supplier-k8s . diff --git a/go.mod b/go.mod index 4301ae9..0e6b3dd 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,11 @@ module github.com/networkservicemesh/cmd-nse-supplier-k8s -go 1.16 +go 1.18 require ( github.com/antonfisher/nested-logrus-formatter v1.3.1 github.com/edwarnicke/grpcfd v1.1.2 + github.com/edwarnicke/imports-gen v1.1.2 github.com/kelseyhightower/envconfig v1.4.0 github.com/networkservicemesh/api v1.3.0-rc.1.0.20220405210054-fbcde048efa5 github.com/networkservicemesh/sdk v0.5.1-0.20220408124029-adfd2db62d17 @@ -17,3 +18,63 @@ require ( k8s.io/apimachinery v0.22.1 k8s.io/client-go v0.22.1 ) + +require ( + github.com/OneOfOne/xxhash v1.2.3 // indirect + github.com/cenkalti/backoff/v4 v4.1.2 // indirect + github.com/davecgh/go-spew v1.1.1 // indirect + github.com/edwarnicke/exechelper v1.0.2 // indirect + github.com/edwarnicke/serialize v1.0.7 // indirect + github.com/ghodss/yaml v1.0.0 // indirect + github.com/go-logr/logr v1.2.1 // indirect + github.com/go-logr/stdr v1.2.0 // indirect + github.com/gobwas/glob v0.2.3 // indirect + github.com/gogo/protobuf v1.3.2 // indirect + github.com/golang-jwt/jwt/v4 v4.1.0 // indirect + github.com/golang/protobuf v1.5.2 // indirect + github.com/google/go-cmp v0.5.6 // indirect + github.com/google/gofuzz v1.1.0 // indirect + github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect + github.com/google/uuid v1.1.2 // indirect + github.com/googleapis/gnostic v0.5.5 // indirect + github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect + github.com/json-iterator/go v1.1.11 // indirect + github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect + github.com/modern-go/reflect2 v1.0.1 // indirect + github.com/open-policy-agent/opa v0.16.1 // indirect + github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect + github.com/yashtewari/glob-intersection v0.0.0-20180916065949-5c77d914dd0b // indirect + github.com/zeebo/errs v1.2.2 // indirect + go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.27.0 // indirect + go.opentelemetry.io/otel v1.3.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.3.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlpmetric v0.26.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.26.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.3.0 // indirect + go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.3.0 // indirect + go.opentelemetry.io/otel/internal/metric v0.26.0 // indirect + go.opentelemetry.io/otel/metric v0.26.0 // indirect + go.opentelemetry.io/otel/sdk v1.3.0 // indirect + go.opentelemetry.io/otel/sdk/export/metric v0.26.0 // indirect + go.opentelemetry.io/otel/sdk/metric v0.26.0 // indirect + go.opentelemetry.io/otel/trace v1.3.0 // indirect + go.opentelemetry.io/proto/otlp v0.11.0 // indirect + golang.org/x/crypto v0.0.0-20220307211146-efcb8507fb70 // indirect + golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2 // indirect + golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d // indirect + golang.org/x/sys v0.0.0-20220307203707-22a9840ba4d7 // indirect + golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d // indirect + golang.org/x/text v0.3.7 // indirect + golang.org/x/time v0.0.0-20211116232009-f0f3c7e86c11 // indirect + google.golang.org/appengine v1.6.5 // indirect + google.golang.org/genproto v0.0.0-20211129164237-f09f9a12af12 // indirect + google.golang.org/protobuf v1.27.1 // indirect + gopkg.in/inf.v0 v0.9.1 // indirect + gopkg.in/square/go-jose.v2 v2.4.1 // indirect + gopkg.in/yaml.v2 v2.4.0 // indirect + gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect + k8s.io/klog/v2 v2.40.1 // indirect + k8s.io/utils v0.0.0-20210707171843-4b05e18ac7d9 // indirect + sigs.k8s.io/structured-merge-diff/v4 v4.1.2 // indirect + sigs.k8s.io/yaml v1.2.0 // indirect +) diff --git a/go.sum b/go.sum index 195fc87..339e22f 100644 --- a/go.sum +++ b/go.sum @@ -105,9 +105,13 @@ github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3 github.com/eapache/go-resiliency v1.2.0/go.mod h1:kFI+JgMyC7bLPUVY133qvEBtVayf5mFgVsvEsIPBvNs= github.com/eapache/go-xerial-snappy v0.0.0-20180814174437-776d5712da21/go.mod h1:+020luEh2TKB4/GOp8oxxtq0Daoen/Cii55CzbTV6DU= github.com/eapache/queue v1.1.0/go.mod h1:6eCeP0CKFpHLu8blIFXhExK/dRa7WDZfr6jVFPTqq+I= +github.com/edwarnicke/exechelper v1.0.1/go.mod h1:/T271jtNX/ND4De6pa2aRy2+8sNtyCDB1A2pp4M+fUs= +github.com/edwarnicke/exechelper v1.0.2 h1:dD49Ui2U0FBFxxhalnKw6vLS0P0TkgnXBRvKL/xmC5w= github.com/edwarnicke/exechelper v1.0.2/go.mod h1:/T271jtNX/ND4De6pa2aRy2+8sNtyCDB1A2pp4M+fUs= github.com/edwarnicke/grpcfd v1.1.2 h1:2b8kCABQ1+JjSKGDoHadqSW7whCeTXMqtyo6jmB5B8k= github.com/edwarnicke/grpcfd v1.1.2/go.mod h1:rHihB9YvNMixz8rS+ZbwosI2kj65VLkeyYAI2M+/cGA= +github.com/edwarnicke/imports-gen v1.1.2 h1:7GHc07PTo8kRzdOVJdQEuxYic3wg5SYGHOg5qrY3PEk= +github.com/edwarnicke/imports-gen v1.1.2/go.mod h1:aCSe8SMtEh1O51cS5s3vxK6Lu3sPMkQwAqnye8AROwo= github.com/edwarnicke/serialize v0.0.0-20200705214914-ebc43080eecf/go.mod h1:XvbCO/QGsl3X8RzjBMoRpkm54FIAZH5ChK2j+aox7pw= github.com/edwarnicke/serialize v1.0.7 h1:geX8vmyu8Ij2S5fFIXjy9gBDkKxXnrMIzMoDvV0Ddac= github.com/edwarnicke/serialize v1.0.7/go.mod h1:y79KgU2P7ALH/4j37uTSIdNavHFNttqN7pzO6Y8B2aw= @@ -219,6 +223,7 @@ github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hf github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= +github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y= @@ -485,7 +490,6 @@ go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opentelemetry.io/contrib v0.20.0 h1:ubFQUn0VCZ0gPwIoJfBJVpeBlyRMxu8Mm/huKWYd9p0= go.opentelemetry.io/contrib v0.20.0/go.mod h1:G/EtFaa6qaN7+LxqfIAT3GiZa7Wv5DTBUzl5H4LY0Kc= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.27.0 h1:TON1iU3Y5oIytGQHIejDYLam5uoSMsmA0UV9Yupb5gQ= go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.27.0/go.mod h1:T/zQwBldOpoAEpE3HMbLnI8ydESZVz4ggw6Is4FF9LI= @@ -495,7 +499,6 @@ go.opentelemetry.io/otel v1.2.0/go.mod h1:aT17Fk0Z1Nor9e0uisf98LrntPGMnk4frBO9+d go.opentelemetry.io/otel v1.3.0 h1:APxLf0eiBwLl+SOXiJJCVYzA1OOJNyAoV8C5RNRyy7Y= go.opentelemetry.io/otel v1.3.0/go.mod h1:PWIKzi6JCp7sM0k9yZ43VX+T345uNbAkDKwHVjb2PTs= go.opentelemetry.io/otel/exporters/jaeger v1.3.0/go.mod h1:KoYHi1BtkUPncGSRtCe/eh1ijsnePhSkxwzz07vU0Fc= -go.opentelemetry.io/otel/exporters/otlp v0.20.0 h1:PTNgq9MRmQqqJY0REVbZFvwkYOA85vbdQU/nVfxDyqg= go.opentelemetry.io/otel/exporters/otlp v0.20.0/go.mod h1:YIieizyaN77rtLJra0buKiNBOm9XQfkPEKBeuhoMwAM= go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.3.0 h1:R/OBkMoGgfy2fLhs2QhkCI1w4HLEQX92GCcJB6SSdNk= go.opentelemetry.io/otel/exporters/otlp/internal/retry v1.3.0/go.mod h1:VpP4/RMn8bv8gNo9uK7/IMY4mtWLELsS+JIP0inH0h4= diff --git a/internal/pkg/imports/gen.go b/internal/imports/gen.go similarity index 77% rename from internal/pkg/imports/gen.go rename to internal/imports/gen.go index 34b8002..4387ef6 100644 --- a/internal/pkg/imports/gen.go +++ b/internal/imports/gen.go @@ -1,4 +1,4 @@ -// Copyright (c) 2020-2021 Cisco and/or its affiliates. +// Copyright (c) 2022 Cisco and/or its affiliates. // // SPDX-License-Identifier: Apache-2.0 // @@ -18,5 +18,4 @@ package imports //go:generate bash -c "rm -rf imports*.go" -//go:generate bash -c "cd $(mktemp -d) && GO111MODULE=on go get github.com/edwarnicke/imports-gen@v1.1.0" -//go:generate bash -c "GOOS=linux ${GOPATH}/bin/imports-gen" +//go:generate go run -exec "env GOOS=linux" github.com/edwarnicke/imports-gen diff --git a/internal/pkg/imports/imports_linux.go b/internal/imports/imports_linux.go similarity index 95% rename from internal/pkg/imports/imports_linux.go rename to internal/imports/imports_linux.go index faa15e8..603dcf9 100644 --- a/internal/pkg/imports/imports_linux.go +++ b/internal/imports/imports_linux.go @@ -1,4 +1,4 @@ -// DO NOT EDIT - generated by github.com/edwarnicke/imports-gen +// Code generated by github.com/edwarnicke/imports-gen DO NOT EDIT. package imports import ( diff --git a/tools.go b/tools.go new file mode 100644 index 0000000..1f7b9d9 --- /dev/null +++ b/tools.go @@ -0,0 +1,23 @@ +// Copyright (c) 2022 Cisco and/or its affiliates. +// +// SPDX-License-Identifier: Apache-2.0 +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at: +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//go:build tools + +package tools + +import ( + _ "github.com/edwarnicke/imports-gen" +)