From 1045794ba886dc52e004a5ca566b2bb61e3e9ac5 Mon Sep 17 00:00:00 2001 From: Joel Takvorian <joel.takvorian@qaraywa.net> Date: Thu, 13 Jul 2023 09:24:59 +0200 Subject: [PATCH] Upgrade linter - fix found issues - use go1.20 (#148) --- .github/workflows/pull_request.yml | 2 +- .github/workflows/pull_request_e2e.yml | 2 +- .github/workflows/push_image.yml | 2 +- .github/workflows/push_image_pr.yml | 2 +- .github/workflows/release.yml | 2 +- .golangci.yml | 8 ++------ Dockerfile | 2 +- Makefile | 4 ++-- examples/performance/Dockerfile_packet_counter | 2 +- go.mod | 2 +- scripts/generators.Dockerfile | 2 +- 11 files changed, 13 insertions(+), 17 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index d011bbb8..64df4b3b 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go: ['1.18','1.19'] + go: ['1.19','1.20'] steps: - uses: actions/checkout@v3 - name: Set up Go diff --git a/.github/workflows/pull_request_e2e.yml b/.github/workflows/pull_request_e2e.yml index d42a12a9..16fc97b8 100644 --- a/.github/workflows/pull_request_e2e.yml +++ b/.github/workflows/pull_request_e2e.yml @@ -17,7 +17,7 @@ jobs: - name: set up go 1.x uses: actions/setup-go@v3 with: - go-version: 1.19 + go-version: '1.20' - name: checkout uses: actions/checkout@v3 - name: run end-to-end tests diff --git a/.github/workflows/push_image.yml b/.github/workflows/push_image.yml index 7bd2cb16..c4cf2dfd 100644 --- a/.github/workflows/push_image.yml +++ b/.github/workflows/push_image.yml @@ -15,7 +15,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go: ['1.19'] + go: ['1.20'] steps: - name: install make run: sudo apt-get install make diff --git a/.github/workflows/push_image_pr.yml b/.github/workflows/push_image_pr.yml index f670434a..3225fe01 100644 --- a/.github/workflows/push_image_pr.yml +++ b/.github/workflows/push_image_pr.yml @@ -16,7 +16,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go: ['1.19'] + go: ['1.20'] steps: - name: install make run: sudo apt-get install make diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3d7f4b82..d0fd17c5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - go: ['1.19'] + go: ['1.20'] steps: - name: checkout uses: actions/checkout@v3 diff --git a/.golangci.yml b/.golangci.yml index 6f8b9897..dacbd203 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,6 +1,5 @@ linters: enable: - - deadcode - errcheck - errorlint - cyclop @@ -8,20 +7,18 @@ linters: - exhaustive - exportloopref - gocritic - - goimports + - gofmt - gosimple - govet - ineffassign - revive - staticcheck - - structcheck - stylecheck - typecheck - unused - - varcheck linters-settings: stylecheck: - go: "1.19" + go: "1.20" gocritic: enabled-checks: - hugeParam @@ -31,4 +28,3 @@ linters-settings: - deprecatedComment cyclop: max-complexity: 20 - diff --git a/Dockerfile b/Dockerfile index a9b20c7a..299577e8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ ARG BUILDPLATFORM=linux/amd64 ARG TARGETARCH=amd64 # Build the manager binary -FROM --platform=$BUILDPLATFORM docker.io/library/golang:1.19 as builder +FROM --platform=$BUILDPLATFORM docker.io/library/golang:1.20 as builder ARG TARGETARCH ARG TARGETPLATFORM diff --git a/Makefile b/Makefile index dea367bf..b11fa111 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,7 @@ OCI_BIN ?= $(shell basename ${OCI_BIN_PATH}) LOCAL_GENERATOR_IMAGE ?= ebpf-generator:latest CILIUM_EBPF_VERSION := v0.11.0 -GOLANGCI_LINT_VERSION = v1.50.1 +GOLANGCI_LINT_VERSION = v1.53.3 CLANG ?= clang CFLAGS := -O2 -g -Wall -Werror $(CFLAGS) GOOS ?= linux @@ -89,7 +89,7 @@ vendors: ## Check go vendors .PHONY: prereqs prereqs: ## Check if prerequisites are met, and install missing dependencies @echo "### Checking if prerequisites are met, and installing missing dependencies" - test -f $(shell go env GOPATH)/bin/golangci-lint || GOFLAGS="" go install github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION} + GOFLAGS="" go install github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION} test -f $(shell go env GOPATH)/bin/bpf2go || go install github.com/cilium/ebpf/cmd/bpf2go@${CILIUM_EBPF_VERSION} test -f $(shell go env GOPATH)/bin/protoc-gen-go || go install google.golang.org/protobuf/cmd/protoc-gen-go@latest test -f $(shell go env GOPATH)/bin/protoc-gen-go-grpc || go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest diff --git a/examples/performance/Dockerfile_packet_counter b/examples/performance/Dockerfile_packet_counter index 5e8863b5..0b44bcba 100644 --- a/examples/performance/Dockerfile_packet_counter +++ b/examples/performance/Dockerfile_packet_counter @@ -1,6 +1,6 @@ # this file has to be built from the project root directory -FROM golang:1.18 as builder +FROM golang:1.20 as builder WORKDIR /app diff --git a/go.mod b/go.mod index 520b1b66..9411ece3 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/netobserv/netobserv-ebpf-agent -go 1.18 +go 1.19 require ( github.com/caarlos0/env/v6 v6.9.1 diff --git a/scripts/generators.Dockerfile b/scripts/generators.Dockerfile index c48833c7..df6d3ce7 100644 --- a/scripts/generators.Dockerfile +++ b/scripts/generators.Dockerfile @@ -1,6 +1,6 @@ FROM fedora:35 -ARG GOVERSION="1.18.4" +ARG GOVERSION="1.20.5" ARG PROTOCVERSION="3.19.4" # Installs dependencies that are required to compile eBPF programs -- GitLab