From f7259ea71c5ee3b4fca912b0a04790ead126732f Mon Sep 17 00:00:00 2001 From: Aleksandr Kurlov Date: Wed, 10 Sep 2025 14:22:17 +0200 Subject: [PATCH 01/14] Bump to go1.24 and upgrade argocd to 1 --- .github/workflows/aws-integration.yaml | 2 +- .github/workflows/ci.yaml | 6 +++--- .github/workflows/emailsender-central-compatibility.yaml | 2 +- .golangci.yml | 2 +- .openshift-ci/e2e-runtime/Dockerfile | 2 +- CLAUDE.md | 2 +- Dockerfile | 2 +- README.md | 2 +- emailsender/Dockerfile | 2 +- fleetshard-operator/Dockerfile | 2 +- go.mod | 6 ++++-- go.sum | 4 ++-- probe/Dockerfile | 4 ++-- tools.Dockerfile | 2 +- tools/go.mod | 2 +- 15 files changed, 22 insertions(+), 20 deletions(-) diff --git a/.github/workflows/aws-integration.yaml b/.github/workflows/aws-integration.yaml index f09f1e3048..cbcedaa460 100644 --- a/.github/workflows/aws-integration.yaml +++ b/.github/workflows/aws-integration.yaml @@ -47,7 +47,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: "1.23" + go-version: "1.24" - name: Check out code into the Go module directory uses: actions/checkout@v4 - name: Cache go module diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index ace1145024..57b0883612 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -33,7 +33,7 @@ jobs: python-version: '3.12' - uses: actions/setup-go@v5 with: - go-version: "1.23" + go-version: "1.24" - uses: pre-commit/action@v3.0.1 - uses: pre-commit/action@v3.0.1 name: Verify generated files are up-to-date @@ -81,7 +81,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: "1.23" + go-version: "1.24" - name: Check out code into the Go module directory uses: actions/checkout@v4 - name: Cache go module @@ -135,7 +135,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: "1.23" + go-version: "1.24" - name: Build and push fleet-manager-tools image to quay.io if: github.event_name == 'push' env: diff --git a/.github/workflows/emailsender-central-compatibility.yaml b/.github/workflows/emailsender-central-compatibility.yaml index f5ed3e151e..e8d30b3914 100644 --- a/.github/workflows/emailsender-central-compatibility.yaml +++ b/.github/workflows/emailsender-central-compatibility.yaml @@ -35,7 +35,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: "1.23" + go-version: "1.24" - name: Cache go module uses: actions/cache@v4 with: diff --git a/.golangci.yml b/.golangci.yml index 82162f6a6d..3bc4c16a68 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -91,7 +91,7 @@ linters-settings: require-explanation: false # don't require an explanation for nolint directives require-specific: true # require nolint directives to be specific about which linter is being skipped staticcheck: - go: "1.23" + go: "1.24" checks: [ all,-ST1000,-ST1001,-ST1003,-ST1005,-SA1019,-SA4001,-ST1016 ] wrapcheck: {} # ignoreSigRegexps: uncomment to add ignore rules diff --git a/.openshift-ci/e2e-runtime/Dockerfile b/.openshift-ci/e2e-runtime/Dockerfile index a07473ecb9..438791fde6 100644 --- a/.openshift-ci/e2e-runtime/Dockerfile +++ b/.openshift-ci/e2e-runtime/Dockerfile @@ -5,7 +5,7 @@ RUN rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial RUN dnf update -y --disablerepo=\* --enablerepo=baseos,appstream && dnf -y install procps make which git gettext jq gcc && dnf clean all && rm -rf /var/cache/dnf -COPY --from=registry.ci.openshift.org/openshift/release:golang-1.23 /usr/lib/golang /usr/lib/golang +COPY --from=registry.ci.openshift.org/openshift/release:golang-1.24 /usr/lib/golang /usr/lib/golang COPY --from=quay.io/openshift/origin-cli:4.20 /usr/bin/oc /usr/bin ENV GOPATH=/go diff --git a/CLAUDE.md b/CLAUDE.md index e1b82abdf8..ddc66ca4a5 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -152,7 +152,7 @@ The codebase follows a dependency injection pattern using the `goava/di` framewo ## Development Workflow ### Environment Setup -1. Install prerequisites: Go 1.23+, Docker, Node.js, Java, OCM CLI +1. Install prerequisites: Go 1.24+, Docker, Node.js, Java, OCM CLI 2. Run `make setup/git/hooks` to install pre-commit hooks 3. Use `make deploy/bootstrap` to set up development cluster 4. Run `make deploy/dev` to start local development environment diff --git a/Dockerfile b/Dockerfile index d895ce8931..aa3fa3a18e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM --platform=$BUILDPLATFORM registry.access.redhat.com/ubi8/go-toolset:1.23.6-4 AS build +FROM --platform=$BUILDPLATFORM registry.access.redhat.com/ubi8/go-toolset:1.24.6-1756315360 AS build USER root RUN mkdir /src /rds_ca diff --git a/README.md b/README.md index 78a6f7b8c9..22f9218047 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ ACS fleet-manager repository for the ACS managed service. #### Prerequisites -* [Golang 1.23+](https://golang.org/dl/) +* [Golang 1.24+](https://golang.org/dl/) * [Docker](https://docs.docker.com/get-docker/) - to create database * [ocm cli](https://github.com/openshift-online/ocm-cli/releases) - ocm command line tool * [Node.js v12.20+](https://nodejs.org/en/download/) and [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) diff --git a/emailsender/Dockerfile b/emailsender/Dockerfile index f49fc7ac15..60cbe38a36 100644 --- a/emailsender/Dockerfile +++ b/emailsender/Dockerfile @@ -1,4 +1,4 @@ -FROM registry.access.redhat.com/ubi8/go-toolset:1.23.6-4 AS build +FROM registry.access.redhat.com/ubi8/go-toolset:1.24.6-1756315360 AS build USER root ENV GOFLAGS="-mod=mod" diff --git a/fleetshard-operator/Dockerfile b/fleetshard-operator/Dockerfile index dbf1d3366e..0499d3fb91 100644 --- a/fleetshard-operator/Dockerfile +++ b/fleetshard-operator/Dockerfile @@ -14,7 +14,7 @@ RUN microdnf install gzip tar && \ ARG IMAGE_TAG=latest RUN yq -i ".global.image.tag = strenv(IMAGE_TAG)" rhacs-terraform/values.yaml -FROM --platform=$BUILDPLATFORM registry.access.redhat.com/ubi8/go-toolset:1.23.6-4 AS build-go +FROM --platform=$BUILDPLATFORM registry.access.redhat.com/ubi8/go-toolset:1.24.6-1756315360 AS build-go USER root RUN mkdir /src diff --git a/go.mod b/go.mod index 430c23a3ee..cc973c5877 100644 --- a/go.mod +++ b/go.mod @@ -1,12 +1,14 @@ module github.com/stackrox/acs-fleet-manager -go 1.23.0 +go 1.24.6 + +toolchain go1.24.7 require ( github.com/DATA-DOG/go-sqlmock v1.5.2 github.com/antihax/optional v1.0.0 github.com/argoproj-labs/argocd-operator v0.14.0 - github.com/argoproj/argo-cd/v2 v2.14.13 + github.com/argoproj/argo-cd/v2 v2.14.17 github.com/aws/aws-sdk-go-v2 v1.36.5 github.com/aws/aws-sdk-go-v2/config v1.29.17 github.com/aws/aws-sdk-go-v2/credentials v1.17.70 diff --git a/go.sum b/go.sum index 0b88ba74f3..ff9686d78b 100644 --- a/go.sum +++ b/go.sum @@ -94,8 +94,8 @@ github.com/antihax/optional v1.0.0 h1:xK2lYat7ZLaVVcIuj82J8kIro4V6kDe0AUDFboUCwc github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= github.com/argoproj-labs/argocd-operator v0.14.0 h1:ksHsdV5hC8u275PWU746EXB/c09g7UzdJPdkIqDQwjU= github.com/argoproj-labs/argocd-operator v0.14.0/go.mod h1:UHe70eXnnCEfzp7EWRofMU+BFnPgZiT5OSqpuInEARA= -github.com/argoproj/argo-cd/v2 v2.14.13 h1:oSLPHV9Gon6mEqVkyBOuLJ7T16ShZv6xSjkCiquzEDM= -github.com/argoproj/argo-cd/v2 v2.14.13/go.mod h1:P72XxcRigWQpQsuAgaXyHPFYkSPE4sdACA5g/s3Si1I= +github.com/argoproj/argo-cd/v2 v2.14.17 h1:r/CkYKzHoPjGgJ/4/fdubUVpG+LBj6AtOigbitNHgy4= +github.com/argoproj/argo-cd/v2 v2.14.17/go.mod h1:CF9GX0CjKiszpAnvYNCLV5tLSVqgfOgn/tcOt2VHTQo= github.com/argoproj/gitops-engine v0.7.1-0.20250521000818-c08b0a72c1f1 h1:Ze4U6kV49vSzlUBhH10HkO52bYKAIXS4tHr/MlNDfdU= github.com/argoproj/gitops-engine v0.7.1-0.20250521000818-c08b0a72c1f1/go.mod h1:WsnykM8idYRUnneeT31cM/Fq/ZsjkefCbjiD8ioCJkU= github.com/argoproj/pkg v0.13.7-0.20230626144333-d56162821bd1 h1:qsHwwOJ21K2Ao0xPju1sNuqphyMnMYkyB3ZLoLtxWpo= diff --git a/probe/Dockerfile b/probe/Dockerfile index fa2d40a931..d5b8ef495f 100644 --- a/probe/Dockerfile +++ b/probe/Dockerfile @@ -1,10 +1,10 @@ -FROM --platform=$BUILDPLATFORM registry.access.redhat.com/ubi8/go-toolset:1.23.9-2.1749483526 AS build +FROM --platform=$BUILDPLATFORM registry.access.redhat.com/ubi8/go-toolset:1.24.6-1756315360 AS build USER root ENV GOFLAGS="-mod=mod" RUN mkdir /src WORKDIR /src -RUN CGO_ENABLED=0 go install -ldflags "-s -w -extldflags '-static'" github.com/go-delve/delve/cmd/dlv@v1.23.1 +RUN CGO_ENABLED=0 go install -ldflags "-s -w -extldflags '-static'" github.com/go-delve/delve/cmd/dlv@v1.24.7 COPY go.* ./ RUN go mod download COPY . ./ diff --git a/tools.Dockerfile b/tools.Dockerfile index 9c817572e3..b4e8d97c19 100644 --- a/tools.Dockerfile +++ b/tools.Dockerfile @@ -1,4 +1,4 @@ -FROM --platform=$BUILDPLATFORM registry.access.redhat.com/ubi8/go-toolset:1.23.6-4 AS build +FROM --platform=$BUILDPLATFORM registry.access.redhat.com/ubi8/go-toolset:1.24.6-1756315360 AS build USER root RUN mkdir /src WORKDIR /src diff --git a/tools/go.mod b/tools/go.mod index e2469c86ab..03ae857d14 100644 --- a/tools/go.mod +++ b/tools/go.mod @@ -1,6 +1,6 @@ module github.com/stackrox/acs-fleet-manager/tools -go 1.23.0 +go 1.24 require ( github.com/matryer/moq v0.5.2 From 8c89e76d4320863b0aea1196abe32e4d808191dc Mon Sep 17 00:00:00 2001 From: Aleksandr Kurlov Date: Wed, 10 Sep 2025 14:58:20 +0200 Subject: [PATCH 02/14] Fix golangci.yaml --- .golangci.yml | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 3bc4c16a68..9f290c922e 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,17 +1,19 @@ run: - skip-dirs: - - internal/central/pkg/api/public - - internal/central/pkg/api/private - - internal/central/pkg/api/admin/private - - pkg/client/redhatsso/api - - emailsender/pkg/client/openapi - skip-files: - - ".*_moq.go" # timeout for analysis, e.g. 30s, 5m, default is 1m timeout: 10m + go: "1.23" + checks: [ all,-ST1000,-ST1001,-ST1003,-ST1005,-SA1019,-SA4001,-ST1016 ] issues: exclude-use-default: false + exclude-files: + - ".*_moq.go" + exclude-dirs: + - "internal/central/pkg/api/public" + - "internal/central/pkg/api/private" + - "internal/central/pkg/api/admin/private" + - "pkg/client/redhatsso/api" + - "emailsender/pkg/client/openapi" exclude-rules: - path: _test\.go linters: @@ -90,9 +92,6 @@ linters-settings: allow-unused: false # report any unused nolint directives require-explanation: false # don't require an explanation for nolint directives require-specific: true # require nolint directives to be specific about which linter is being skipped - staticcheck: - go: "1.24" - checks: [ all,-ST1000,-ST1001,-ST1003,-ST1005,-SA1019,-SA4001,-ST1016 ] wrapcheck: {} # ignoreSigRegexps: uncomment to add ignore rules From c1d0a40ee3d8845222db232fa4d27ee9f098ea68 Mon Sep 17 00:00:00 2001 From: Aleksandr Kurlov Date: Wed, 10 Sep 2025 15:26:42 +0200 Subject: [PATCH 03/14] Migrate golangci-lint configuration from v1 to v2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Add version: 2 specification required for v2 - Remove deprecated run.checks field - Update staticcheck settings to include both SA and ST rules - Remove gofmt and goimports (now formatters, not linters) - Remove gosimple and stylecheck (now part of staticcheck) - Update pre-commit hook to use golangci-lint v2.4.0 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- .golangci.yml | 14 ++++++++------ .pre-commit-config.yaml | 2 +- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/.golangci.yml b/.golangci.yml index 9f290c922e..0851bc9862 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,8 +1,10 @@ +# golangci-lint configuration v2 +version: 2 + run: # timeout for analysis, e.g. 30s, 5m, default is 1m timeout: 10m - go: "1.23" - checks: [ all,-ST1000,-ST1001,-ST1003,-ST1005,-SA1019,-SA4001,-ST1016 ] + go: "1.24.7" issues: exclude-use-default: false @@ -41,6 +43,10 @@ issues: text: "don't use leading k in Go names" linters-settings: + staticcheck: + # Disable specific staticcheck rules that were excluded in v1 config + # staticcheck now includes both SA (staticcheck) and ST (stylecheck) rules + checks: ["all", "-ST1000", "-ST1001", "-ST1003", "-ST1005", "-SA1019", "-SA4001", "-ST1016"] gosec: includes: - G601 @@ -119,13 +125,10 @@ linters: # - godot # - godox # - goerr113 - - gofmt - - goimports - revive # - gomnd # - goprintffuncname - gosec - - gosimple - govet - ineffassign # - interfacer @@ -140,7 +143,6 @@ linters: # - scopelint - staticcheck # - structcheck - # - stylecheck # - testpackage # - typecheck # - unconvert diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 8a8fbeeb1c..956f8a9118 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -15,7 +15,7 @@ repos: - id: detect-secrets args: ["--baseline", ".secrets.baseline"] - repo: https://github.com/golangci/golangci-lint - rev: v1.64.8 + rev: v2.4.0 hooks: - id: golangci-lint - repo: https://github.com/pre-commit/pre-commit-hooks From 86bb4697fe4346162cd91503fa6cb361b036d4bb Mon Sep 17 00:00:00 2001 From: Aleksandr Kurlov Date: Wed, 10 Sep 2025 20:44:12 +0200 Subject: [PATCH 04/14] Fix go formatting for 1.24 --- internal/central/pkg/handlers/admin_central.go | 3 +-- internal/central/pkg/services/central.go | 6 +++--- .../central/pkg/services/quota/ams_quota_service.go | 5 ++--- .../services/quota/quota_management_list_service.go | 4 ++-- internal/central/test/integration/centrals_test.go | 2 +- .../test/integration/data_plane_endpoints_test.go | 2 +- .../require_terms_acceptance_middleware_test.go | 2 +- pkg/api/error.go | 11 +++-------- pkg/api/resource_id_test.go | 2 +- pkg/client/ocm/impl/client_impl.go | 2 +- pkg/errors/errors.go | 6 +++--- test/helper.go | 10 +++++----- test/mocks/jwk_cert_server.go | 2 +- 13 files changed, 25 insertions(+), 32 deletions(-) diff --git a/internal/central/pkg/handlers/admin_central.go b/internal/central/pkg/handlers/admin_central.go index 86218326e4..65a8706073 100644 --- a/internal/central/pkg/handlers/admin_central.go +++ b/internal/central/pkg/handlers/admin_central.go @@ -3,7 +3,6 @@ package handlers import ( "encoding/json" - "fmt" "io" "net/http" "regexp" @@ -372,7 +371,7 @@ func (h adminCentralHandler) GetTrait(w http.ResponseWriter, r *http.Request) { return nil, svcErr } if !arrays.Contains(cr.Traits, trait) { - return nil, errors.NotFound(fmt.Sprintf("Trait %q not found", trait)) + return nil, errors.NotFound("Trait %q not found", trait) } return nil, nil }, diff --git a/internal/central/pkg/services/central.go b/internal/central/pkg/services/central.go index 501a87171e..8a0f9f59fc 100644 --- a/internal/central/pkg/services/central.go +++ b/internal/central/pkg/services/central.go @@ -287,7 +287,7 @@ func (k *centralService) RegisterCentralJob(ctx context.Context, centralRequest } else if !hasCapacity { errorMsg := fmt.Sprintf("Cluster capacity(%d) exhausted in %s region", int64(k.dataplaneClusterConfig.ClusterConfig.GetCapacityForRegion(centralRequest.Region)), centralRequest.Region) logger.Logger.Warningf(errorMsg) - return errors.TooManyCentralInstancesReached(errorMsg) + return errors.TooManyCentralInstancesReached("%s", errorMsg) } instanceType := k.DetectInstanceType(centralRequest) @@ -298,7 +298,7 @@ func (k *centralService) RegisterCentralJob(ctx context.Context, centralRequest if e != nil || cluster == nil { msg := fmt.Sprintf("No available cluster found for '%s' central instance in region: '%s'", centralRequest.InstanceType, centralRequest.Region) logger.Logger.Errorf(msg) - return errors.TooManyCentralInstancesReached(fmt.Sprintf("Region %s cannot accept instance type: %s at this moment", centralRequest.Region, centralRequest.InstanceType)) + return errors.TooManyCentralInstancesReached("Region %s cannot accept instance type: %s at this moment", centralRequest.Region, centralRequest.InstanceType) } centralRequest.ClusterID = cluster.ClusterID subscriptionID, err := k.reserveQuota(ctx, centralRequest, "", "") @@ -749,7 +749,7 @@ func (k *centralService) VerifyAndUpdateCentralAdmin(ctx context.Context, centra return errors.NewWithCause(errors.ErrorGeneral, svcErr, "Unable to find cluster associated with central request: %s", centralRequest.ID) } if cluster == nil { - return errors.New(errors.ErrorValidation, fmt.Sprintf("Unable to get cluster for central %s", centralRequest.ID)) + return errors.New(errors.ErrorValidation, "Unable to get cluster for central %s", centralRequest.ID) } return k.UpdateIgnoreNils(centralRequest) diff --git a/internal/central/pkg/services/quota/ams_quota_service.go b/internal/central/pkg/services/quota/ams_quota_service.go index 0ac851702f..f6e8538d86 100644 --- a/internal/central/pkg/services/quota/ams_quota_service.go +++ b/internal/central/pkg/services/quota/ams_quota_service.go @@ -3,7 +3,6 @@ package quota import ( "context" - "fmt" "net/http" "time" @@ -50,9 +49,9 @@ func (q amsQuotaService) HasQuotaAllowance(central *dbapi.CentralRequest, instan quotaType := instanceType.GetQuotaType() quotaCosts, err := q.amsClient.GetQuotaCostsForProduct(org.ID(), quotaType.GetResourceName(), quotaType.GetProduct()) if err != nil { - return false, errors.NewWithCause(errors.ErrorGeneral, err, fmt.Sprintf( + return false, errors.NewWithCause(errors.ErrorGeneral, err, "failed to get assigned quota of type %q for organization with external id %q and id %q", - quotaType, central.OrganisationID, org.ID())) + quotaType, central.OrganisationID, org.ID()) } quotaCostsByModel, unsupportedModels := mapAllowedQuotaCosts(quotaCosts) diff --git a/internal/central/pkg/services/quota/quota_management_list_service.go b/internal/central/pkg/services/quota/quota_management_list_service.go index 38f8a37279..b9f15de5ad 100644 --- a/internal/central/pkg/services/quota/quota_management_list_service.go +++ b/internal/central/pkg/services/quota/quota_management_list_service.go @@ -95,12 +95,12 @@ func (q QuotaManagementListService) ReserveQuota(_ context.Context, central *dba if quotaManagementListItem.IsInstanceCountWithinLimit(totalInstanceCount) { return "", nil } - return "", errors.MaximumAllowedInstanceReached(message) + return "", errors.MaximumAllowedInstanceReached("%s", message) } if instanceType == types.EVAL && quotaManagementListItem == nil { if totalInstanceCount >= quotamanagement.GetDefaultMaxAllowedInstances() { - return "", errors.MaximumAllowedInstanceReached(message) + return "", errors.MaximumAllowedInstanceReached("%s", message) } return "", nil } diff --git a/internal/central/test/integration/centrals_test.go b/internal/central/test/integration/centrals_test.go index 22c9c76b01..8a0ad5e170 100644 --- a/internal/central/test/integration/centrals_test.go +++ b/internal/central/test/integration/centrals_test.go @@ -142,7 +142,7 @@ func TestCentral_Delete(t *testing.T) { ocmServerBuilder := mocks.NewMockConfigurableServerBuilder() mockedGetClusterResponse, err := mockedClusterWithMetricsInfo(mocks.MockClusterComputeNodes) if err != nil { - t.Fatalf(err.Error()) + t.Fatalf("%s", err.Error()) } ocmServerBuilder.SetClusterGetResponse(mockedGetClusterResponse, nil) diff --git a/internal/central/test/integration/data_plane_endpoints_test.go b/internal/central/test/integration/data_plane_endpoints_test.go index b4e28b28d7..24b7561098 100644 --- a/internal/central/test/integration/data_plane_endpoints_test.go +++ b/internal/central/test/integration/data_plane_endpoints_test.go @@ -28,7 +28,7 @@ func TestDataPlaneClusterStatus(t *testing.T) { ocmServerBuilder := mocks.NewMockConfigurableServerBuilder() mockedGetClusterResponse, err := mockedClusterWithMetricsInfo(mocks.MockClusterComputeNodes) if err != nil { - t.Fatalf(err.Error()) + t.Fatalf("%s", err.Error()) } ocmServerBuilder.SetClusterGetResponse(mockedGetClusterResponse, nil) diff --git a/internal/central/test/integration/require_terms_acceptance_middleware_test.go b/internal/central/test/integration/require_terms_acceptance_middleware_test.go index 9144849733..4d85a257e9 100644 --- a/internal/central/test/integration/require_terms_acceptance_middleware_test.go +++ b/internal/central/test/integration/require_terms_acceptance_middleware_test.go @@ -28,7 +28,7 @@ func termsRequiredSetup(termsRequired bool, t *testing.T) TestEnv { ocmServerBuilder := mocks.NewMockConfigurableServerBuilder() termsReviewResponse, err := mocks.GetMockTermsReviewBuilder(nil).TermsRequired(termsRequired).Build() if err != nil { - t.Fatalf(err.Error()) + t.Fatalf("%s", err.Error()) } ocmServerBuilder.SetTermsReviewPostResponse(termsReviewResponse, nil) ocmServer := ocmServerBuilder.Build() diff --git a/pkg/api/error.go b/pkg/api/error.go index 95f968469d..4f22c378d5 100644 --- a/pkg/api/error.go +++ b/pkg/api/error.go @@ -17,11 +17,7 @@ func SendNotFound(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/json") // Prepare the body: - reason := fmt.Sprintf( - "The requested resource '%s' doesn't exist", - r.URL.Path, - ) - apiError := errors.NotFound(reason).AsOpenapiError("", r.RequestURI) + apiError := errors.NotFound("The requested resource '%s' doesn't exist", r.URL.Path).AsOpenapiError("", r.RequestURI) data, err := json.Marshal(apiError) if err != nil { SendPanic(w, r) @@ -41,8 +37,7 @@ func SendNotFound(w http.ResponseWriter, r *http.Request) { // SendMethodNotAllowed response func SendMethodNotAllowed(w http.ResponseWriter, r *http.Request) { - reason := fmt.Sprintf("Method: %s is not allowed or not yet implemented for %s", r.Method, r.URL.Path) - apiError := errors.NotImplemented(reason).AsOpenapiError("", r.RequestURI) + apiError := errors.NotImplemented("Method: %s is not allowed or not yet implemented for %s", r.Method, r.URL.Path).AsOpenapiError("", r.RequestURI) jsonPayload, err := json.Marshal(apiError) if err != nil { SendPanic(w, r) @@ -87,7 +82,7 @@ func SendServiceUnavailable(w http.ResponseWriter, r *http.Request, reason strin w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusServiceUnavailable) - apiError := errors.GeneralError(reason).AsOpenapiError("", r.RequestURI) + apiError := errors.GeneralError("%s", reason).AsOpenapiError("", r.RequestURI) jsonPayload, err := json.Marshal(apiError) if err != nil { SendPanic(w, r) diff --git a/pkg/api/resource_id_test.go b/pkg/api/resource_id_test.go index 5997f2b5d1..41ab1c3c61 100644 --- a/pkg/api/resource_id_test.go +++ b/pkg/api/resource_id_test.go @@ -11,7 +11,7 @@ func TestResourceIDGeneration(t *testing.T) { errors := validation.IsDNS1123Label(id) if len(errors) > 0 { for _, e := range errors { - t.Fatalf(e) + t.Fatalf("%s", e) } } } diff --git a/pkg/client/ocm/impl/client_impl.go b/pkg/client/ocm/impl/client_impl.go index ca4dd2996a..d8ab118965 100644 --- a/pkg/client/ocm/impl/client_impl.go +++ b/pkg/client/ocm/impl/client_impl.go @@ -123,7 +123,7 @@ func (c *client) CreateCluster(cluster *clustersmgmtv1.Cluster) (*clustersmgmtv1 clusterResource := c.connection.ClustersMgmt().V1().Clusters() response, err := clusterResource.Add().Body(cluster).Send() if err != nil { - return &clustersmgmtv1.Cluster{}, serviceErrors.New(serviceErrors.ErrorGeneral, err.Error()) + return &clustersmgmtv1.Cluster{}, serviceErrors.New(serviceErrors.ErrorGeneral, "%s", err.Error()) } createdCluster := response.Body() diff --git a/pkg/errors/errors.go b/pkg/errors/errors.go index dfc256a37c..6b42a5e876 100644 --- a/pkg/errors/errors.go +++ b/pkg/errors/errors.go @@ -314,7 +314,7 @@ func ToServiceError(err error) *ServiceError { case *ServiceError: return convertedErr default: - return GeneralError(convertedErr.Error()) + return GeneralError("%s", convertedErr.Error()) } } @@ -398,7 +398,7 @@ func (e *ServiceError) AsError() error { if e == nil { return nil } - return fmt.Errorf(e.Error()) + return fmt.Errorf("%s", e.Error()) } // Is404 ... @@ -693,5 +693,5 @@ func FailedClusterAuthorization(err error) *ServiceError { if svcErr.IsForbidden() { reason += " - please contact your administrator to ensure that your Red Hat account has the RedhatManagedCluster permission." } - return NewWithCause(svcErr.Code, svcErr, reason) + return NewWithCause(svcErr.Code, svcErr, "%s", reason) } diff --git a/test/helper.go b/test/helper.go index d3c5540d77..4dcbbb11c2 100644 --- a/test/helper.go +++ b/test/helper.go @@ -230,7 +230,7 @@ func (helper *Helper) NewAccountWithNameAndOrg(name string, orgID string) *amv1. func (helper *Helper) NewAccount(username, name, email string, orgID string) *amv1.Account { account, err := helper.AuthHelper.NewAccount(username, name, email, orgID) if err != nil { - helper.T.Errorf(fmt.Sprintf("Unable to create a new account: %s", err.Error())) + helper.T.Errorf("Unable to create a new account: %s", err.Error()) } return account } @@ -239,7 +239,7 @@ func (helper *Helper) NewAccount(username, name, email string, orgID string) *am func (helper *Helper) NewAuthenticatedContext(account *amv1.Account, claims jwt.MapClaims) context.Context { token, err := helper.AuthHelper.CreateSignedJWT(account, claims) if err != nil { - helper.T.Errorf(fmt.Sprintf("Unable to create a signed token: %s", err.Error())) + helper.T.Errorf("Unable to create a signed token: %s", err.Error()) } return context.WithValue(context.Background(), compat.ContextAccessToken, token) @@ -260,7 +260,7 @@ func (helper *Helper) NewAuthenticatedAdminContext(account *amv1.Account, claims token, err := helper.AuthHelper.CreateSignedJWT(account, claims) if err != nil { - helper.T.Errorf(fmt.Sprintf("Unable to create a signed token: %s", err.Error())) + helper.T.Errorf("Unable to create a signed token: %s", err.Error()) } return context.WithValue(context.Background(), adminprivate.ContextAccessToken, token) @@ -301,7 +301,7 @@ func (helper *Helper) ResetDB() { func (helper *Helper) CreateJWTString(account *amv1.Account) string { token, err := helper.AuthHelper.CreateSignedJWT(account, nil) if err != nil { - helper.T.Errorf(fmt.Sprintf("Unable to create a signed token: %s", err.Error())) + helper.T.Errorf("Unable to create a signed token: %s", err.Error()) } return token } @@ -310,7 +310,7 @@ func (helper *Helper) CreateJWTString(account *amv1.Account) string { func (helper *Helper) CreateJWTStringWithClaim(account *amv1.Account, jwtClaims jwt.MapClaims) string { token, err := helper.AuthHelper.CreateSignedJWT(account, jwtClaims) if err != nil { - helper.T.Errorf(fmt.Sprintf("Unable to create a signed token with the given claims: %s", err.Error())) + helper.T.Errorf("Unable to create a signed token with the given claims: %s", err.Error()) } return token } diff --git a/test/mocks/jwk_cert_server.go b/test/mocks/jwk_cert_server.go index af76829a29..3d5278ea0a 100644 --- a/test/mocks/jwk_cert_server.go +++ b/test/mocks/jwk_cert_server.go @@ -32,7 +32,7 @@ func NewJWKCertServerMock(t *testing.T, pubKey crypto.PublicKey, jwkKID string) t.Errorf("Unable to marshal public jwk: %s", err) return } - fmt.Fprintf(w, fmt.Sprintf(`{"keys":[%s]}`, string(jwkBytes))) //nolint:staticcheck + _, _ = fmt.Fprintf(w, `{"keys":[%s]}`, string(jwkBytes)) }, ) From 7ecf57d083f17a5aafdf6ec9575dcaadc24dc264 Mon Sep 17 00:00:00 2001 From: Aleksandr Kurlov Date: Wed, 10 Sep 2025 20:48:42 +0200 Subject: [PATCH 05/14] Set github.com/go-delve/delve/cmd/dlv to latest --- probe/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/probe/Dockerfile b/probe/Dockerfile index d5b8ef495f..4c7e73f921 100644 --- a/probe/Dockerfile +++ b/probe/Dockerfile @@ -4,7 +4,7 @@ ENV GOFLAGS="-mod=mod" RUN mkdir /src WORKDIR /src -RUN CGO_ENABLED=0 go install -ldflags "-s -w -extldflags '-static'" github.com/go-delve/delve/cmd/dlv@v1.24.7 +RUN CGO_ENABLED=0 go install -ldflags "-s -w -extldflags '-static'" github.com/go-delve/delve/cmd/dlv@latest COPY go.* ./ RUN go mod download COPY . ./ From 090465007b9759396a1092d91868864de8f10e50 Mon Sep 17 00:00:00 2001 From: Aleksandr Kurlov Date: Wed, 10 Sep 2025 20:53:49 +0200 Subject: [PATCH 06/14] Remove debugging --- probe/Dockerfile | 1 - 1 file changed, 1 deletion(-) diff --git a/probe/Dockerfile b/probe/Dockerfile index 4c7e73f921..14f61fc235 100644 --- a/probe/Dockerfile +++ b/probe/Dockerfile @@ -4,7 +4,6 @@ ENV GOFLAGS="-mod=mod" RUN mkdir /src WORKDIR /src -RUN CGO_ENABLED=0 go install -ldflags "-s -w -extldflags '-static'" github.com/go-delve/delve/cmd/dlv@latest COPY go.* ./ RUN go mod download COPY . ./ From 20b12098cded59de5c441da58beb05f2bb984986 Mon Sep 17 00:00:00 2001 From: Aleksandr Kurlov Date: Wed, 10 Sep 2025 21:29:40 +0200 Subject: [PATCH 07/14] Update openshiftCI golang image --- .openshift-ci/e2e-runtime/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.openshift-ci/e2e-runtime/Dockerfile b/.openshift-ci/e2e-runtime/Dockerfile index 438791fde6..db0ad19b91 100644 --- a/.openshift-ci/e2e-runtime/Dockerfile +++ b/.openshift-ci/e2e-runtime/Dockerfile @@ -5,7 +5,7 @@ RUN rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial RUN dnf update -y --disablerepo=\* --enablerepo=baseos,appstream && dnf -y install procps make which git gettext jq gcc && dnf clean all && rm -rf /var/cache/dnf -COPY --from=registry.ci.openshift.org/openshift/release:golang-1.24 /usr/lib/golang /usr/lib/golang +COPY --from=registry.ci.openshift.org/openshift/release:rhel-9-release-golang-1.24-openshift-4.20 /usr/lib/golang /usr/lib/golang COPY --from=quay.io/openshift/origin-cli:4.20 /usr/bin/oc /usr/bin ENV GOPATH=/go From 6ed00b9b1bc023cb355d183e3ef207d3005d8e7c Mon Sep 17 00:00:00 2001 From: Aleksandr Kurlov Date: Mon, 15 Sep 2025 13:41:15 +0200 Subject: [PATCH 08/14] Fix fetching nightly version tag for emailsender test --- scripts/ci/central_compatibility/run_compatibility_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ci/central_compatibility/run_compatibility_test.sh b/scripts/ci/central_compatibility/run_compatibility_test.sh index b74b089394..c8cea46565 100644 --- a/scripts/ci/central_compatibility/run_compatibility_test.sh +++ b/scripts/ci/central_compatibility/run_compatibility_test.sh @@ -66,7 +66,7 @@ if [ "$GITHUB_REPOSITORY" = "stackrox/stackrox" ]; then ACS_VERSION="$(make --no-print-directory -C "$STACKROX_DIR" tag)" else git -C "$STACKROX_DIR" fetch --tags - ACS_VERSION="$(git -C "$STACKROX_DIR" tag | grep nightly | tail -n 1)" + ACS_VERSION="$(git -C "$STACKROX_DIR" tag | grep -E '-nightly-[0-9]{8}$' | tail -n 1)" git -C "$STACKROX_DIR" checkout "$ACS_VERSION" fi From bac72463d0c98704d7c34224a1db7bcc5ad87dc9 Mon Sep 17 00:00:00 2001 From: Aleksandr Kurlov Date: Mon, 15 Sep 2025 13:57:09 +0200 Subject: [PATCH 09/14] Add tag list --- scripts/ci/central_compatibility/run_compatibility_test.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/ci/central_compatibility/run_compatibility_test.sh b/scripts/ci/central_compatibility/run_compatibility_test.sh index c8cea46565..91c72ab39c 100644 --- a/scripts/ci/central_compatibility/run_compatibility_test.sh +++ b/scripts/ci/central_compatibility/run_compatibility_test.sh @@ -58,6 +58,9 @@ kubectl apply -f "${SOURCE_DIR}/emailsender-db.yaml" log "Emailsender deployed to Kind." +echo "Available tags:" +git -C "$STACKROX_DIR" tag + log "Starting to deploy central services..." # use nightly if GH action running for acs-fleet-manager # use the stackrox tag otherwise From 51fdd926c302d3d8e641299abe40ade40398bbf1 Mon Sep 17 00:00:00 2001 From: Aleksandr Kurlov Date: Mon, 15 Sep 2025 14:24:29 +0200 Subject: [PATCH 10/14] Fix tag filtering --- scripts/ci/central_compatibility/run_compatibility_test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ci/central_compatibility/run_compatibility_test.sh b/scripts/ci/central_compatibility/run_compatibility_test.sh index 91c72ab39c..3c154a5800 100644 --- a/scripts/ci/central_compatibility/run_compatibility_test.sh +++ b/scripts/ci/central_compatibility/run_compatibility_test.sh @@ -69,7 +69,7 @@ if [ "$GITHUB_REPOSITORY" = "stackrox/stackrox" ]; then ACS_VERSION="$(make --no-print-directory -C "$STACKROX_DIR" tag)" else git -C "$STACKROX_DIR" fetch --tags - ACS_VERSION="$(git -C "$STACKROX_DIR" tag | grep -E '-nightly-[0-9]{8}$' | tail -n 1)" + ACS_VERSION="$(git -C "$STACKROX_DIR" tag | grep -E '.*-nightly-[0-9]{8}$' | tail -n 1)" git -C "$STACKROX_DIR" checkout "$ACS_VERSION" fi From 6b4326343cdfc2da9c200f960009319aab87ab26 Mon Sep 17 00:00:00 2001 From: Aleksandr Kurlov Date: Tue, 16 Sep 2025 12:11:37 +0200 Subject: [PATCH 11/14] Set 1.24.4 --- go.mod | 4 +--- scripts/ci/central_compatibility/run_compatibility_test.sh | 3 --- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/go.mod b/go.mod index cc973c5877..9de95ff32b 100644 --- a/go.mod +++ b/go.mod @@ -1,8 +1,6 @@ module github.com/stackrox/acs-fleet-manager -go 1.24.6 - -toolchain go1.24.7 +go 1.24.4 require ( github.com/DATA-DOG/go-sqlmock v1.5.2 diff --git a/scripts/ci/central_compatibility/run_compatibility_test.sh b/scripts/ci/central_compatibility/run_compatibility_test.sh index 3c154a5800..7fa9af51e7 100644 --- a/scripts/ci/central_compatibility/run_compatibility_test.sh +++ b/scripts/ci/central_compatibility/run_compatibility_test.sh @@ -58,9 +58,6 @@ kubectl apply -f "${SOURCE_DIR}/emailsender-db.yaml" log "Emailsender deployed to Kind." -echo "Available tags:" -git -C "$STACKROX_DIR" tag - log "Starting to deploy central services..." # use nightly if GH action running for acs-fleet-manager # use the stackrox tag otherwise From 9701ec7f0eaede51d7ac8fcb944d9a81fb7afaec Mon Sep 17 00:00:00 2001 From: Aleksandr Kurlov Date: Wed, 17 Sep 2025 17:46:38 +0200 Subject: [PATCH 12/14] Update image for golang for openshiftCI --- .openshift-ci/e2e-runtime/Dockerfile | 2 +- go.mod | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.openshift-ci/e2e-runtime/Dockerfile b/.openshift-ci/e2e-runtime/Dockerfile index db0ad19b91..911f48b103 100644 --- a/.openshift-ci/e2e-runtime/Dockerfile +++ b/.openshift-ci/e2e-runtime/Dockerfile @@ -5,7 +5,7 @@ RUN rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial RUN dnf update -y --disablerepo=\* --enablerepo=baseos,appstream && dnf -y install procps make which git gettext jq gcc && dnf clean all && rm -rf /var/cache/dnf -COPY --from=registry.ci.openshift.org/openshift/release:rhel-9-release-golang-1.24-openshift-4.20 /usr/lib/golang /usr/lib/golang +COPY --from=registry.redhat.io/rhel8/go-toolset@sha256:4842bf7e31849a442f4c6d00f00fe3a6d4793525764e0ddb3ba098c6649a7f67 /usr/lib/golang /usr/lib/golang COPY --from=quay.io/openshift/origin-cli:4.20 /usr/bin/oc /usr/bin ENV GOPATH=/go diff --git a/go.mod b/go.mod index 9de95ff32b..302c56e386 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/stackrox/acs-fleet-manager -go 1.24.4 +go 1.24.6 require ( github.com/DATA-DOG/go-sqlmock v1.5.2 From 40896a2609a4a7f573b822211a0a5b0913b60089 Mon Sep 17 00:00:00 2001 From: Aleksandr Kurlov Date: Thu, 18 Sep 2025 01:05:21 +0200 Subject: [PATCH 13/14] Set scannerV4 db image --- scripts/ci/central_compatibility/run_compatibility_test.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/ci/central_compatibility/run_compatibility_test.sh b/scripts/ci/central_compatibility/run_compatibility_test.sh index 7fa9af51e7..dc4f66bef1 100644 --- a/scripts/ci/central_compatibility/run_compatibility_test.sh +++ b/scripts/ci/central_compatibility/run_compatibility_test.sh @@ -100,7 +100,8 @@ helm upgrade --install -n $CENTRAL_NS stackrox-central-services ./central-chart -f "${SOURCE_DIR}/central-values.yaml" \ --set "central.adminPassword.values=$ADMIN_PW" \ --set "central.image.tag=$ACS_VERSION" \ - --set "central.db.image.tag=$ACS_VERSION" + --set "central.db.image.tag=$ACS_VERSION" \ + --set "scannerV4.db.image.tag=$ACS_VERSION" KUBECTL="$(which kubectl)" wait_for_container_to_become_ready "$CENTRAL_NS" "app=central" "central" From 69292a8d025ed35f1d3f282fc2497819bc63b700 Mon Sep 17 00:00:00 2001 From: Aleksandr Kurlov Date: Mon, 22 Sep 2025 13:28:29 +0200 Subject: [PATCH 14/14] Set tools version and set tag to e2e golang image --- .openshift-ci/e2e-runtime/Dockerfile | 2 +- tools/go.mod | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.openshift-ci/e2e-runtime/Dockerfile b/.openshift-ci/e2e-runtime/Dockerfile index 911f48b103..1b0be29fb7 100644 --- a/.openshift-ci/e2e-runtime/Dockerfile +++ b/.openshift-ci/e2e-runtime/Dockerfile @@ -5,7 +5,7 @@ RUN rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial RUN dnf update -y --disablerepo=\* --enablerepo=baseos,appstream && dnf -y install procps make which git gettext jq gcc && dnf clean all && rm -rf /var/cache/dnf -COPY --from=registry.redhat.io/rhel8/go-toolset@sha256:4842bf7e31849a442f4c6d00f00fe3a6d4793525764e0ddb3ba098c6649a7f67 /usr/lib/golang /usr/lib/golang +COPY --from=registry.redhat.io/rhel9/go-toolset:1.24.6 /usr/lib/golang /usr/lib/golang COPY --from=quay.io/openshift/origin-cli:4.20 /usr/bin/oc /usr/bin ENV GOPATH=/go diff --git a/tools/go.mod b/tools/go.mod index 03ae857d14..7faefb7964 100644 --- a/tools/go.mod +++ b/tools/go.mod @@ -1,6 +1,6 @@ module github.com/stackrox/acs-fleet-manager/tools -go 1.24 +go 1.24.6 require ( github.com/matryer/moq v0.5.2