Skip to content

Splunk Operator: Code formatting #1634

@ductrung-nguyen

Description

@ductrung-nguyen

Please select the type of request

Enhancement

Tell us more

Describe the request
Currently the code is pushed and merged to branch main without checking the format properly.
More precisely, we do check the format, but neve mark the action fail when there is any file not in a good format.
This issue makes the code format to be inconsistent between developers/contributors.

For example, from this action job:
https://github.com/splunk/splunk-operator/actions/runs/17735316662/job/50395521395

Image Image
Run make fmt && if [[ $? -ne 0 ]]; then false; fi
go fmt ./...
go: downloading k8s.io/apimachinery v0.31.0
go: downloading sigs.k8s.io/controller-runtime v0.19.0
go: downloading k8s.io/api v0.31.0
go: downloading go.uber.org/zap v1.26.0
go: downloading k8s.io/client-go v0.31.0
go: downloading github.com/google/go-cmp v0.7.0
go: downloading k8s.io/apiextensions-apiserver v0.31.
...
go: downloading github.com/go-logr/stdr v1.2.2
go: downloading github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0
cmd/main.go
test/secret/manager_secret_m4_test.go
test/secret/manager_secret_s1_test.go
test/secret/secret_c3_test.go
test/secret/secret_m4_test.go
test/secret/secret_s1_test.go
test/smartstore/manager_smartstore_test.go
test/smartstore/smartstore_test.go
test/smoke/smoke_test.go
Image

Expected behavior
The action job should fail.

Splunk setup on K8S
N/A

Reproduction/Testing steps
N/A

K8s environment
N/A

Proposed changes(optional)
Instead of running make fmt which is used to format the file locally, we should use gofmt -l ./....

Or we can have something like this in the github actions:

steps:
  - name: Check formatting
    run: |
      UNFORMATTED=$(gofmt -l .)
      if [ -n "$UNFORMATTED" ]; then
        echo "These files are not formatted:"
        echo "$UNFORMATTED"
        exit 1
      fi

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions