Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade linter - fix found issues - use go1.20 #354

Merged
merged 1 commit into from
Jul 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go: ['1.18','1.19']
go: ['1.19','1.20']

steps:
- name: install make
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/push_image.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -46,7 +46,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go: ['1.19']
go: ['1.20']
steps:
- name: install make
run: sudo apt-get install make
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/push_image_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go: ['1.19']
go: ['1.20']
steps:
- name: checkout
uses: actions/checkout@v3
Expand Down
9 changes: 3 additions & 6 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
linters:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here, using the same config as in the operator. The removed modules were anyway disabled in golangci-lint

enable:
- deadcode
- errcheck
- errorlint
- cyclop
- errname
- 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
Expand All @@ -30,4 +27,4 @@ linters-settings:
- indexAlloc
- deprecatedComment
cyclop:
max-complexity: 15
max-complexity: 20
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ WORKDIR /opt/app-root/web
RUN npm run format-all
RUN npm run build$BUILDSCRIPT

FROM --platform=$BUILDPLATFORM docker.io/library/golang:1.19 as go-builder
FROM --platform=$BUILDPLATFORM docker.io/library/golang:1.20 as go-builder

ARG TARGETPLATFORM
ARG TARGETARCH=amd64
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ OCI_BUILD_OPTS ?=
OCI_BIN_PATH = $(shell which docker 2>/dev/null || which podman)
OCI_BIN ?= $(shell basename ${OCI_BIN_PATH})

GOLANGCI_LINT_VERSION = v1.50.1
GOLANGCI_LINT_VERSION = v1.53.3
NPM_INSTALL ?= install
CMDLINE_ARGS ?= --loglevel trace --loki-tenant-id netobserv --frontend-config config/sample-frontend-config.yaml --auth-check none
LDFLAGS := -X 'main.buildVersion=${BUILD_VERSION}' -X 'main.buildDate=${BUILD_DATE}'
Expand Down Expand Up @@ -93,7 +93,7 @@ help: ## Display this help.
.PHONY: prereqs
prereqs: ## Test if prerequisites are met, and installing missing dependencies
@echo "### Test if prerequisites are met, and installing missing dependencies"
test -f $(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}

.PHONY: vendors
vendors: ## Check go vendors
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/netobserv/network-observability-console-plugin

go 1.18
go 1.19

require (
github.com/gorilla/mux v1.8.0
Expand Down
4 changes: 2 additions & 2 deletions pkg/handler/csv/loki_csv.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ func GetCSVData(qr *model.AggregatedQueryResponse, columns []string) ([][]string
data[0] = append(data[0], fields...)
}

data = append(data, getRowDatas(stream, entry, labels, fields, line, len(data[0])))
data = append(data, getRowDatas(stream, labels, fields, line, len(data[0])))
}
}
return data, nil
}
return nil, fmt.Errorf("loki returned an unexpected type: %T", qr.Result)
}

func getRowDatas(stream model.Stream, entry model.Entry, labels, fields []string,
func getRowDatas(stream model.Stream, labels, fields []string,
line map[string]interface{}, size int) []string {
rowDatas := make([]string, 0, size)

Expand Down
2 changes: 1 addition & 1 deletion pkg/handler/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/sirupsen/logrus"
)

func Status(w http.ResponseWriter, r *http.Request) {
func Status(w http.ResponseWriter, _ *http.Request) {
_, err := w.Write([]byte("OK"))
if err != nil {
logrus.Errorf("could not write response: %v", err)
Expand Down
2 changes: 1 addition & 1 deletion pkg/kubernetes/auth/check_auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type NoopChecker struct {
Checker
}

func (b *NoopChecker) CheckAuth(ctx context.Context, header http.Header) error {
func (b *NoopChecker) CheckAuth(_ context.Context, _ http.Header) error {
hlog.Debug("noop auth checker: ignore auth")
return nil
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -579,9 +579,8 @@ func checkHTTPReady(httpClient *http.Client, url string) {
if r, err := httpClient.Get(url); err == nil {
r.Body.Close()
break
} else {
time.Sleep(time.Second)
}
time.Sleep(time.Second)
}
}

Expand Down
Loading