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

feat: update to go 1.24.x #342

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
- 'v*'

env:
GO_VERSION: "1.22.x"
GO_VERSION: "1.24.x"

jobs:
wait-for-checks:
Expand All @@ -31,7 +31,7 @@ jobs:
with:
token: ${{ secrets.GITHUB_TOKEN }}
# This check name is defined as the github actions job name (in .github/workflows/static-analysis-integration.yaml)
checkName: "Static-Analysis (1.22.x, ubuntu-latest)"
checkName: "Static-Analysis (1.24.x, ubuntu-latest)"
ref: ${{ github.event.pull_request.head.sha || github.sha }}

- name: Check unit, and integration test results
Expand All @@ -40,7 +40,7 @@ jobs:
with:
token: ${{ secrets.GITHUB_TOKEN }}
# This check name is defined as the github actions job name (in .github/workflows/static-analysis-integration.yaml)
checkName: "Tests (1.22.x, ubuntu-latest)"
checkName: "Tests (1.24.x, ubuntu-latest)"
ref: ${{ github.event.pull_request.head.sha || github.sha }}

- name: Quality gate
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/static-unit-integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
Static-Analysis:
strategy:
matrix:
go-version: ["1.22.x"]
go-version: ["1.24.x"]
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
Expand Down Expand Up @@ -43,7 +43,7 @@ jobs:
strategy:
matrix:
# test the lower bounds of support, and the latest available
go-version: ["1.22.x"]
go-version: ["1.24.x"]
platform: [ubuntu-latest]
runs-on: ${{ matrix.platform }}
steps:
Expand Down
50 changes: 15 additions & 35 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
run:
timeout: 5m
skip-dirs:
issues:
max-same-issues: 25
uniq-by-line: false
exclude-dirs:
- .circleci
- .github
- scripts
exclude-rules:
- path: (.+)_test.go
linters:
- funlen
- dupl
- goconst

run:
timeout: 5m

linters:
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
disable-all: true
Expand All @@ -13,7 +24,7 @@ linters:
- dupl
- errcheck
- errorlint
- exportloopref
- copyloopvar
- funlen
- gocognit
- goconst
Expand Down Expand Up @@ -46,34 +57,3 @@ linters-settings:
# If lower than 0, disable the check.
# Default: 40
statements: 50
output:
uniq-by-line: false
issues:
exclude-rules:
- path: (.+)_test.go
linters:
- funlen
- dupl
- goconst

# do not enable...
# - dogsled # found to be to niche and ineffective
# - goprintffuncname # does not catch all cases and there are exceptions
# - nakedret # does not catch all cases and should not fail a build
# - gochecknoglobals
# - gochecknoinits # this is too aggressive
# - rowserrcheck disabled per generics https://github.com/golangci/golangci-lint/issues/2649
# - godot
# - godox
# - goerr113
# - goimports # we're using gosimports now instead to account for extra whitespaces (see https://github.com/golang/go/issues/20818)
# - golint # deprecated
# - gomnd # this is too aggressive
# - interfacer # this is a good idea, but is no longer supported and is prone to false positives
# - lll # without a way to specify per-line exception cases, this is not usable
# - maligned # this is an excellent linter, but tricky to optimize and we are not sensitive to memory layout optimizations
# - nestif
# - prealloc # following this rule isn't consistently a good idea, as it sometimes forces unnecessary allocations that result in less idiomatic code
# - scopelint # deprecated
# - testpackage
# - wsl # this doens't have an auto-fixer yet and is pretty noisy (https://github.com/bombsimon/wsl/issues/90)
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ COVERAGE_THRESHOLD := 45

CLUSTER_NAME=anchore-k8s-inventory-testing

GOLANG_CI_VERSION=v1.55.2
GOLANG_CI_VERSION=v1.64.2
GOBOUNCER_VERSION=v0.4.0
GORELEASER_VERSION=v1.18.2

Expand Down
7 changes: 4 additions & 3 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package cmd
import (
"errors"
"fmt"
"os"
"runtime/pprof"

"github.com/anchore/k8s-inventory/pkg/healthreporter"
"github.com/anchore/k8s-inventory/pkg/integration"
"github.com/anchore/k8s-inventory/pkg/mode"
"github.com/anchore/k8s-inventory/pkg/reporter"
"os"
"runtime/pprof"

"github.com/spf13/cobra"
"github.com/spf13/viper"
Expand Down Expand Up @@ -40,7 +41,7 @@ var rootCmd = &cobra.Command{
if len(args) > 0 {
err := cmd.Help()
if err != nil {
log.Errorf(err.Error())
log.Error(err.Error())
os.Exit(1)
}
os.Exit(1)
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/anchore/k8s-inventory

go 1.22.5
go 1.24.0

require (
github.com/adrg/xdg v0.5.3
Expand Down
1 change: 0 additions & 1 deletion pkg/inventory/containers.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ func getRegistryOverrideNormalisedImageTag(imageTag, missingRegistryOverride str
return imageTag
}

//nolint:funlen
func getContainersInPod(pod v1.Pod, missingRegistryOverride, missingTagPolicy, dummyTag string) []Container {
// Look at both status/spec for init and regular containers
// Must use status when looking at containers in order to obtain the container ID
Expand Down
7 changes: 4 additions & 3 deletions pkg/lib.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@ import (
"encoding/json"
"errors"
"fmt"
jstime "github.com/anchore/k8s-inventory/internal/time"
"github.com/anchore/k8s-inventory/pkg/integration"
"os"
"regexp"
"time"

jstime "github.com/anchore/k8s-inventory/internal/time"
"github.com/anchore/k8s-inventory/pkg/integration"

"k8s.io/client-go/kubernetes"
"k8s.io/client-go/rest"

Expand Down Expand Up @@ -95,7 +96,7 @@ func HandleReport(report inventory.Report, reportInfo *healthreporter.InventoryR
// PeriodicallyGetInventoryReport periodically retrieve image results and report/output them according to the configuration.
// Note: Errors do not cause the function to exit, since this is periodically running
//
//nolint:funlen, gocognit
//nolint:gocognit
func PeriodicallyGetInventoryReport(cfg *config.Application, ch integration.Channels, gatedReportInfo *healthreporter.GatedReportInfo) {
// Wait for registration with Enterprise to be disabled or completed
<-ch.InventoryReportingEnabled
Expand Down
2 changes: 1 addition & 1 deletion scripts/install-go.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env bash

GO_VERSION="1.22.5"
GO_VERSION="1.24.0"
ARCH=$(uname | tr '[:upper:]' '[:lower:]')
GO_ARTIFACT="go$GO_VERSION.$ARCH-amd64.tar.gz"
wget "https://dl.google.com/go/$GO_ARTIFACT"
Expand Down
Loading