From 24ed45dbff4f0ae5488329bba08a4f3c07e5c796 Mon Sep 17 00:00:00 2001 From: Liran BG Date: Tue, 5 Dec 2023 20:17:37 -0500 Subject: [PATCH] [Go] Bump to 1.21 (#61) --- .gitignore | 2 ++ .golangci.yml | 12 ++++++++++ Makefile | 29 ++++------------------- cmd/autoscaler/Dockerfile | 4 ++-- cmd/dlx/Dockerfile | 4 ++-- pkg/resourcescaler/mock/resourcescaler.go | 2 +- pkg/resourcescaler/nop/resourcescaler.go | 6 ++--- 7 files changed, 27 insertions(+), 32 deletions(-) diff --git a/.gitignore b/.gitignore index cdca0c20..554a94d8 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,5 @@ # Output of the go coverage tool, specifically when used with LiteIDE *.out + +.bin diff --git a/.golangci.yml b/.golangci.yml index e402732d..2c3daada 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -31,12 +31,24 @@ linters: - govet - typecheck - gocritic + - gci run: # timeout for analysis timeout: 5m +linters-settings: + gci: + sections: + - standard + - prefix(github.com/v3io/scaler) + - default + - blank + - dot + + custom-order: true + issues: # List of regexps of issue texts to exclude diff --git a/Makefile b/Makefile index cb9a5c90..6aa798b2 100644 --- a/Makefile +++ b/Makefile @@ -73,31 +73,17 @@ GO_BUILD_TOOL_WORKDIR = /scaler .PHONY: lint lint: modules - @echo Installing linters... - @test -e $(GOPATH)/bin/impi || \ - curl -s https://api.github.com/repos/pavius/impi/releases/latest \ - | grep -i "browser_download_url.*impi.*$(OS_NAME)" \ - | cut -d : -f 2,3 \ - | tr -d \" \ - | wget -O $(GOPATH)/bin/impi -qi - - @test -e $(GOPATH)/bin/golangci-lint || \ - (curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin v1.50.1) - - @echo Verifying imports... - chmod +x $(GOPATH)/bin/impi && $(GOPATH)/bin/impi \ - --local github.com/v3io/scaler/ \ - --scheme stdLocalThirdParty \ - --skip pkg/platform/kube/apis \ - --skip pkg/platform/kube/client \ - ./cmd/... ./pkg/... + @test -e .bin/golangci-lint || \ + (curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b .bin v1.55.1) @echo Linting... - $(GOPATH)/bin/golangci-lint run -v + .bin/golangci-lint run -v @echo Done. .PHONY: fmt fmt: gofmt -s -w . + .bin/golangci-lint run --fix ./... .PHONY: test-undockerized test-undockerized: modules @@ -116,13 +102,8 @@ test: $(SCALER_DOCKER_TEST_TAG) \ /bin/bash -c "make test-undockerized" -.PHONY: ensure-gopath -ensure-gopath: -ifndef GOPATH - $(error GOPATH must be set) -endif .PHONY: modules -modules: ensure-gopath +modules: @echo Getting go modules @go mod download diff --git a/cmd/autoscaler/Dockerfile b/cmd/autoscaler/Dockerfile index 450d1802..a38b2678 100644 --- a/cmd/autoscaler/Dockerfile +++ b/cmd/autoscaler/Dockerfile @@ -13,7 +13,7 @@ # limitations under the License. # -FROM gcr.io/iguazio/golang:1.19-alpine3.17 AS builder +FROM gcr.io/iguazio/golang:1.21-alpine3.18 AS builder RUN apk --update --no-cache add \ git \ @@ -30,6 +30,6 @@ COPY . . RUN GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -ldflags="-s -w" -o autoscaler cmd/autoscaler/main.go -FROM gcr.io/iguazio/alpine:3.17 +FROM gcr.io/iguazio/alpine:3.18 COPY --from=builder /autoscaler/autoscaler /home/v3io/bin/autoscaler diff --git a/cmd/dlx/Dockerfile b/cmd/dlx/Dockerfile index 814557f8..73a63f87 100644 --- a/cmd/dlx/Dockerfile +++ b/cmd/dlx/Dockerfile @@ -13,7 +13,7 @@ # limitations under the License. # -FROM gcr.io/iguazio/golang:1.19-alpine3.17 AS builder +FROM gcr.io/iguazio/golang:1.21-alpine3.18 AS builder RUN apk --update --no-cache add \ git \ @@ -30,6 +30,6 @@ COPY . . RUN GOOS=linux GOARCH=amd64 go build -a -installsuffix cgo -ldflags="-s -w" -o dlx cmd/dlx/main.go -FROM gcr.io/iguazio/alpine:3.17 +FROM gcr.io/iguazio/alpine:3.18 COPY --from=builder /dlx/dlx /home/v3io/bin/dlx diff --git a/pkg/resourcescaler/mock/resourcescaler.go b/pkg/resourcescaler/mock/resourcescaler.go index 70692b63..59573371 100644 --- a/pkg/resourcescaler/mock/resourcescaler.go +++ b/pkg/resourcescaler/mock/resourcescaler.go @@ -32,7 +32,7 @@ type ResourceScaler struct { mock.Mock } -func New(kubeconfigPath string, namespace string) (scalertypes.ResourceScaler, error) { // nolint: deadcode +func New(_ string, _ string) (scalertypes.ResourceScaler, error) { // nolint: deadcode return &ResourceScaler{}, nil } diff --git a/pkg/resourcescaler/nop/resourcescaler.go b/pkg/resourcescaler/nop/resourcescaler.go index 440f1cd9..49505dfb 100644 --- a/pkg/resourcescaler/nop/resourcescaler.go +++ b/pkg/resourcescaler/nop/resourcescaler.go @@ -28,15 +28,15 @@ import ( type ResourceScaler struct{} -func New(kubeconfigPath string, namespace string) (scalertypes.ResourceScaler, error) { // nolint: deadcode +func New(_ string, _ string) (scalertypes.ResourceScaler, error) { // nolint: deadcode return &ResourceScaler{}, nil } -func (r *ResourceScaler) SetScale(resources []scalertypes.Resource, scale int) error { +func (r *ResourceScaler) SetScale(_ []scalertypes.Resource, _ int) error { return nil } -func (r *ResourceScaler) SetScaleCtx(ctx context.Context, resources []scalertypes.Resource, scale int) error { +func (r *ResourceScaler) SetScaleCtx(_ context.Context, _ []scalertypes.Resource, _ int) error { return nil }