Skip to content

Commit

Permalink
[Go] Bump to 1.21 (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
liranbg authored Dec 6, 2023
1 parent 362f556 commit 24ed45d
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 32 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

.bin
12 changes: 12 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 5 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
4 changes: 2 additions & 2 deletions cmd/autoscaler/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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
4 changes: 2 additions & 2 deletions cmd/dlx/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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
2 changes: 1 addition & 1 deletion pkg/resourcescaler/mock/resourcescaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
6 changes: 3 additions & 3 deletions pkg/resourcescaler/nop/resourcescaler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 24ed45d

Please sign in to comment.