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

chore(go): Update to Go 1.24 #330

Open
wants to merge 6 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
4 changes: 2 additions & 2 deletions .github/workflows/linter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ jobs:
- name: Setup Golang
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
with:
go-version: "1.23"
go-version: "1.24"

- name: Checkout Git Repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: golangci-lint
uses: golangci/golangci-lint-action@971e284b6050e8a5849b72094c50ab08da042db8 # v6.1.1
with:
version: v1.63.3
version: v1.64.5
args: ./...
2 changes: 1 addition & 1 deletion .github/workflows/system-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
- name: Setup Golang
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
with:
go-version: "1.23"
go-version: "1.24"

- name: Run integration Tests
run: make system-test
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Setup Golang
uses: actions/setup-go@3041bf56c941b39c61721a86cd11f3bb1338122a # v5.2.0
with:
go-version: "1.23"
go-version: "1.24"

- name: Checkout Git Repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
Expand Down
4 changes: 2 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ linters:
# - gofumpt
- goheader
- goimports
- gomoddirectives
# - gomoddirectives
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The linter is disabled as it raises a package replacement warning, which is required to compile KH successfully.

- gomodguard
- goprintffuncname
- gosec
Expand Down Expand Up @@ -75,7 +75,6 @@ linters:
- sqlclosecheck
- staticcheck
# - stylecheck TODO reeanble
- tenv
- testableexamples
# - testpackage
- thelper
Expand All @@ -85,6 +84,7 @@ linters:
- unparam
- unused
- usestdlibvars
- usetesting
- wastedassign
# - whitespace
# - wrapcheck #TODO: add it back later potentially?
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# syntax=docker/dockerfile:1

ARG GO_VERSION=1.23.0
ARG XX_VERSION=1.2.1
ARG GOLANGCI_LINT_VERSION=v1.62.0
ARG GO_VERSION=1.24.0
ARG XX_VERSION=1.6.1
ARG GOLANGCI_LINT_VERSION=v1.64.5

# xx is a helper for cross-compilation
FROM --platform=${BUILDPLATFORM} tonistiigi/xx:${XX_VERSION} AS xx
Expand Down
253 changes: 84 additions & 169 deletions LICENSE-3rdparty.csv

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion deployments/kubehound/binary/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.23 AS build-stage
FROM golang:1.24 AS build-stage

COPY go.mod go.sum ./
RUN go mod download
Expand Down
2 changes: 1 addition & 1 deletion docs/dev-guide/getting-started.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ make help
## Requirements build

- 16GB of RAM (minimum)
- go (v1.23): https://go.dev/doc/install
- go (v1.24): https://go.dev/doc/install
- [Docker](https://docs.docker.com/engine/install/) >= 19.03 (`docker version`)
- [Docker Compose](https://docs.docker.com/compose/compose-file/compose-versioning/) >= v2.0 (`docker compose version`)

Expand Down
2 changes: 1 addition & 1 deletion docs/dev-guide/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ To ensure no regression in KubeHound, 2 kinds of tests are in place:

## Requirements test

- [Golang](https://go.dev/doc/install) `>= 1.23`
- [Golang](https://go.dev/doc/install) `>= 1.24`
- [Kind](https://kind.sigs.k8s.io/docs/user/quick-start/#installing-with-a-package-manager)
- [Kubectl](https://kubernetes.io/docs/tasks/tools/)

Expand Down
211 changes: 112 additions & 99 deletions go.mod

Large diffs are not rendered by default.

496 changes: 274 additions & 222 deletions go.sum

Large diffs are not rendered by default.

5 changes: 1 addition & 4 deletions pkg/dump/writer/file_writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ func TestFileWriter_Write(t *testing.T) {
t.Parallel()
ctx := context.Background()

tmpDir, err := os.MkdirTemp("/tmp/", "kh-unit-tests-*")
if err != nil {
t.Fatalf("failer to create temp dir for test: %v", err)
}
tmpDir := t.TempDir()

fileNameK8sObject := collector.EndpointPath
dummyK8sObject := []*discoveryv1.EndpointSlice{
Expand Down
11 changes: 2 additions & 9 deletions pkg/dump/writer/tar_writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,8 @@ func TestTarWriter_Write(t *testing.T) {
t.Parallel()
ctx := context.Background()

tmpTarFileDir, err := os.MkdirTemp("/tmp/", "kh-unit-tests-*")
if err != nil {
t.Fatalf("failed to create temporary directory: %v", err)
}

tmpTarExtractDir, err := os.MkdirTemp("/tmp/", "kh-unit-tests-*")
if err != nil {
t.Fatalf("failed to create temporary directory: %v", err)
}
tmpTarFileDir := t.TempDir()
tmpTarExtractDir := t.TempDir()

// Constructing a buffer of Endpoints objects in different namespaces/files
tarBundle := make(map[string]any)
Expand Down
6 changes: 1 addition & 5 deletions pkg/ingestor/puller/puller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,7 @@ func TestExtractTarGz(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
tmpPath, err := os.MkdirTemp("/tmp", "kubehound-test")
defer os.RemoveAll(tmpPath)
if err != nil {
t.Error(err)
}
tmpPath := t.TempDir()
dryRun := false
if err := ExtractTarGz(ctx, dryRun, "./testdata/archive.tar.gz", tmpPath, tt.args.maxArchiveSize); (err != nil) != tt.wantErr {
t.Errorf("ExtractTarGz() error = %v, wantErr %v", err, tt.wantErr)
Expand Down
1 change: 0 additions & 1 deletion pkg/kubehound/graph/adapter/gremlin.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ func GremlinEdgeProcessor(ctx context.Context, oic *converter.ObjectIDConverter,
func DefaultEdgeTraversal() types.EdgeTraversal {
return func(source *gremlin.GraphTraversalSource, inserts []any) *gremlin.GraphTraversal {
g := source.GetGraphTraversal().
//nolint:asasalint // required due to constraints in the gremlin API
Inject(inserts).
Unfold().As("em").
MergeE(__.Select("em")).
Expand Down
1 change: 0 additions & 1 deletion pkg/kubehound/graph/edge/pod_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ func (e *PodCreate) Traversal() types.EdgeTraversal {
if e.cfg.LargeClusterOptimizations {
// In large clusters this can explode the number of edges and we can safely assume this is a critical issue
g.
//nolint:asasalint // required due to constraints in the gremlin API
Inject(inserts).
Unfold().
As("rpc").
Expand Down
1 change: 0 additions & 1 deletion pkg/kubehound/graph/edge/pod_exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ func (e *PodExec) Traversal() types.EdgeTraversal {
if e.cfg.LargeClusterOptimizations {
// In large clusters this can explode the number of edges and we can safely assume this is a critical issue
g.
//nolint:asasalint // required due to constraints in the gremlin API
Inject(inserts).
Unfold().
As("rpe").
Expand Down
1 change: 0 additions & 1 deletion pkg/kubehound/graph/edge/pod_patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ func (e *PodPatch) Traversal() types.EdgeTraversal {
if e.cfg.LargeClusterOptimizations {
// In large clusters this can explode the number of edges and we can safely assume this is a critical issue
g.
//nolint:asasalint // required due to constraints in the gremlin API
Inject(inserts).
Unfold().
As("rpp").
Expand Down
1 change: 0 additions & 1 deletion pkg/kubehound/graph/vertex/base_vertex.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ func (v *BaseVertex) BatchSize() int {
func (v *BaseVertex) DefaultTraversal(label string) types.VertexTraversal {
return func(source *gremlingo.GraphTraversalSource, inserts []any) *gremlingo.GraphTraversal {
g := source.GetGraphTraversal().
//nolint:asasalint // required due to constraints in the gremlin API
Inject(inserts).
Unfold().As("entities").
AddV(label).As("vtx").
Expand Down
Loading