From 6afb31073426f7e77e4acbf81e327025dc21409e 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 | 9 +++-- go.mod | 37 ++++++++++++++++++- go.sum | 5 +++ {imports => internal/imports}/gen.go | 3 +- .../imports}/imports_linux.go | 0 tools.go | 23 ++++++++++++ 11 files changed, 94 insertions(+), 25 deletions(-) rename {imports => internal/imports}/gen.go (82%) rename {imports => internal/imports}/imports_linux.go (100%) 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 9875aed..4491261 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 b2303ed..5e12d55 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,14 +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/imports internal/imports +RUN go build ./internal/imports COPY . . RUN go build -o /bin/app . diff --git a/go.mod b/go.mod index 313fcbc..00f9d00 100644 --- a/go.mod +++ b/go.mod @@ -1,9 +1,10 @@ module github.com/networkservicemesh/cmd-template -go 1.16 +go 1.18 require ( github.com/antonfisher/nested-logrus-formatter v1.3.1 + 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.20220415125440-009c3f3a16bd @@ -11,3 +12,37 @@ require ( github.com/spiffe/go-spiffe/v2 v2.0.0 google.golang.org/grpc v1.42.0 ) + +require ( + github.com/cenkalti/backoff/v4 v4.1.2 // indirect + github.com/edwarnicke/exechelper v1.0.2 // indirect + github.com/go-logr/logr v1.2.1 // indirect + github.com/go-logr/stdr v1.2.0 // indirect + github.com/golang/protobuf v1.5.2 // indirect + github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 // indirect + github.com/google/uuid v1.1.2 // indirect + github.com/grpc-ecosystem/grpc-gateway v1.16.0 // indirect + github.com/pkg/errors v0.9.1 // 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/sys v0.0.0-20220307203707-22a9840ba4d7 // indirect + golang.org/x/text v0.3.7 // indirect + google.golang.org/genproto v0.0.0-20200806141610-86f49bd18e98 // indirect + google.golang.org/protobuf v1.27.1 // indirect + gopkg.in/square/go-jose.v2 v2.4.1 // indirect +) diff --git a/go.sum b/go.sum index b7723e4..0cbfa75 100644 --- a/go.sum +++ b/go.sum @@ -39,8 +39,12 @@ github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs 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/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/go.mod h1:y79KgU2P7ALH/4j37uTSIdNavHFNttqN7pzO6Y8B2aw= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -96,6 +100,7 @@ github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ= github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +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.2 h1:EVhdT+1Kseyi1/pUmXKaFxYsDNy9RQYkMWRH68J/W7Y= github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= diff --git a/imports/gen.go b/internal/imports/gen.go similarity index 82% rename from imports/gen.go rename to internal/imports/gen.go index d4eafe4..4387ef6 100644 --- a/imports/gen.go +++ b/internal/imports/gen.go @@ -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.2" -//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/imports/imports_linux.go b/internal/imports/imports_linux.go similarity index 100% rename from imports/imports_linux.go rename to internal/imports/imports_linux.go 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" +)