diff --git a/.github/workflows/build-test-push-workflow.yml b/.github/workflows/build-test-push-workflow.yml index bc876543f..98a73ffb8 100644 --- a/.github/workflows/build-test-push-workflow.yml +++ b/.github/workflows/build-test-push-workflow.yml @@ -18,7 +18,13 @@ jobs: with: go-version: ${{ steps.dotenv.outputs.GO_VERSION }} - name: Check Source formatting - run: make fmt && if [[ $? -ne 0 ]]; then false; fi + run: | + UNFORMATTED=$(gofmt -l .) + if [ -n "$UNFORMATTED" ]; then + echo "These files are not formatted:" + echo "$UNFORMATTED" + exit 1 + fi - name: Lint source code run: make vet && if [[ $? -ne 0 ]]; then false; fi unit-tests: diff --git a/cmd/main.go b/cmd/main.go index 6a152ce16..f8aba0ae1 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -107,11 +107,11 @@ func main() { // as certificates issued by a trusted Certificate Authority (CA). The primary risk is potentially allowing // unauthorized access to sensitive metrics data. Consider replacing with CertDir, CertName, and KeyName // to provide certificates, ensuring the server communicates using trusted and secure certificates. - TLSOpts: tlsOpts, + TLSOpts: tlsOpts, FilterProvider: filters.WithAuthenticationAndAuthorization, } - // TODO: enable https for /metrics endpoint by default + // TODO: enable https for /metrics endpoint by default // if secureMetrics { // // FilterProvider is used to protect the metrics endpoint with authn/authz. // // These configurations ensure that only authorized users and service accounts diff --git a/pkg/splunk/enterprise/afwscheduler_test.go b/pkg/splunk/enterprise/afwscheduler_test.go index e3b1f336c..38668da69 100644 --- a/pkg/splunk/enterprise/afwscheduler_test.go +++ b/pkg/splunk/enterprise/afwscheduler_test.go @@ -3064,7 +3064,7 @@ func TestRunLocalScopedPlaybook(t *testing.T) { // Test3: get installed app name passes but isAppAlreadyInstalled fails with real error (not "Could not find object") mockPodExecReturnContexts[1].StdErr = "" mockPodExecReturnContexts[2].StdErr = "Some other real error message" // Real error, not "Could not find object" - mockPodExecReturnContexts[2].Err = fmt.Errorf("exit status 2") // Real error, not grep exit code 1 + mockPodExecReturnContexts[2].Err = fmt.Errorf("exit status 2") // Real error, not grep exit code 1 localInstallCtxt.sem <- struct{}{} waiter.Add(1) err = localInstallCtxt.runPlaybook(ctx) @@ -3073,10 +3073,10 @@ func TestRunLocalScopedPlaybook(t *testing.T) { } // Test4: isAppAlreadyInstalled returns app not enabled (grep exit code 1), then install fails - mockPodExecReturnContexts[2].StdOut = "" // No stdout means grep didn't find ENABLED - mockPodExecReturnContexts[2].StdErr = "" // No stderr - mockPodExecReturnContexts[2].Err = fmt.Errorf("exit status 1") // grep exit code 1 = pattern not found - mockPodExecReturnContexts[3].StdErr = "real installation error" // This is just logged now + mockPodExecReturnContexts[2].StdOut = "" // No stdout means grep didn't find ENABLED + mockPodExecReturnContexts[2].StdErr = "" // No stderr + mockPodExecReturnContexts[2].Err = fmt.Errorf("exit status 1") // grep exit code 1 = pattern not found + mockPodExecReturnContexts[3].StdErr = "real installation error" // This is just logged now mockPodExecReturnContexts[3].Err = fmt.Errorf("install command failed") // This causes the actual failure localInstallCtxt.sem <- struct{}{} @@ -3103,7 +3103,7 @@ func TestRunLocalScopedPlaybook(t *testing.T) { // Test6: Install succeeds with stderr content (should be ignored), but cleanup fails mockPodExecReturnContexts[3].StdErr = "Some informational message in stderr" // Stderr content should be ignored - mockPodExecReturnContexts[3].Err = nil // No actual error for install + mockPodExecReturnContexts[3].Err = nil // No actual error for install // Keep cleanup failure from previous test setup to make overall test fail // mockPodExecReturnContexts[4] still has error from earlier @@ -3326,10 +3326,10 @@ func TestPremiumAppScopedPlaybook(t *testing.T) { // Test4: isAppAlreadyInstalled returns app is not enabled (grep exit code 1) // so app install will run and it should fail with real error - mockPodExecReturnContexts[2].StdOut = "" // No stdout means grep didn't find ENABLED - mockPodExecReturnContexts[2].StdErr = "" // No stderr - mockPodExecReturnContexts[2].Err = fmt.Errorf("exit status 1") // grep exit code 1 = pattern not found - mockPodExecReturnContexts[3].StdErr = "real installation error" // This is just logged now + mockPodExecReturnContexts[2].StdOut = "" // No stdout means grep didn't find ENABLED + mockPodExecReturnContexts[2].StdErr = "" // No stderr + mockPodExecReturnContexts[2].Err = fmt.Errorf("exit status 1") // grep exit code 1 = pattern not found + mockPodExecReturnContexts[3].StdErr = "real installation error" // This is just logged now mockPodExecReturnContexts[3].Err = fmt.Errorf("install command failed") // This causes the actual failure localInstallCtxt.sem <- struct{}{} @@ -3341,7 +3341,7 @@ func TestPremiumAppScopedPlaybook(t *testing.T) { // Test5: Install succeeds with stderr content (should be ignored), but post install fails mockPodExecReturnContexts[3].StdErr = "Some informational message in stderr" // Stderr content should be ignored - mockPodExecReturnContexts[3].Err = nil // No actual error for install + mockPodExecReturnContexts[3].Err = nil // No actual error for install localInstallCtxt.sem <- struct{}{} waiter.Add(1) diff --git a/pkg/splunk/enterprise/util.go b/pkg/splunk/enterprise/util.go index 70b9b8f8a..abd96482a 100644 --- a/pkg/splunk/enterprise/util.go +++ b/pkg/splunk/enterprise/util.go @@ -2503,7 +2503,7 @@ func loadFixture(t *testing.T, filename string) string { if err != nil { t.Fatalf("Failed to load fixture %s: %v", filename, err) } - + // Compact the JSON to match the output from json.Marshal var compactJSON bytes.Buffer if err := json.Compact(&compactJSON, data); err != nil { diff --git a/test/secret/manager_secret_m4_test.go b/test/secret/manager_secret_m4_test.go index 526af6d31..fdf2d2a31 100644 --- a/test/secret/manager_secret_m4_test.go +++ b/test/secret/manager_secret_m4_test.go @@ -17,8 +17,8 @@ import ( "context" "fmt" - "github.com/onsi/ginkgo/v2/types" . "github.com/onsi/ginkgo/v2" + "github.com/onsi/ginkgo/v2/types" . "github.com/onsi/gomega" enterpriseApi "github.com/splunk/splunk-operator/api/v4" diff --git a/test/secret/manager_secret_s1_test.go b/test/secret/manager_secret_s1_test.go index d51e004fd..123538317 100644 --- a/test/secret/manager_secret_s1_test.go +++ b/test/secret/manager_secret_s1_test.go @@ -19,8 +19,8 @@ import ( enterpriseApi "github.com/splunk/splunk-operator/api/v4" - "github.com/onsi/ginkgo/v2/types" . "github.com/onsi/ginkgo/v2" + "github.com/onsi/ginkgo/v2/types" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" diff --git a/test/secret/secret_c3_test.go b/test/secret/secret_c3_test.go index 90bb9fe9c..698c84786 100644 --- a/test/secret/secret_c3_test.go +++ b/test/secret/secret_c3_test.go @@ -19,8 +19,8 @@ import ( enterpriseApi "github.com/splunk/splunk-operator/api/v4" - "github.com/onsi/ginkgo/v2/types" . "github.com/onsi/ginkgo/v2" + "github.com/onsi/ginkgo/v2/types" . "github.com/onsi/gomega" "github.com/splunk/splunk-operator/test/testenv" diff --git a/test/secret/secret_m4_test.go b/test/secret/secret_m4_test.go index f257e70ce..e40d94cfd 100644 --- a/test/secret/secret_m4_test.go +++ b/test/secret/secret_m4_test.go @@ -19,8 +19,8 @@ import ( enterpriseApi "github.com/splunk/splunk-operator/api/v4" - "github.com/onsi/ginkgo/v2/types" . "github.com/onsi/ginkgo/v2" + "github.com/onsi/ginkgo/v2/types" . "github.com/onsi/gomega" "github.com/splunk/splunk-operator/test/testenv" diff --git a/test/secret/secret_s1_test.go b/test/secret/secret_s1_test.go index 11c621815..fc7a0e47d 100644 --- a/test/secret/secret_s1_test.go +++ b/test/secret/secret_s1_test.go @@ -19,8 +19,8 @@ import ( enterpriseApi "github.com/splunk/splunk-operator/api/v4" - "github.com/onsi/ginkgo/v2/types" . "github.com/onsi/ginkgo/v2" + "github.com/onsi/ginkgo/v2/types" . "github.com/onsi/gomega" corev1 "k8s.io/api/core/v1" diff --git a/test/smartstore/manager_smartstore_test.go b/test/smartstore/manager_smartstore_test.go index 45db78875..b90a68337 100644 --- a/test/smartstore/manager_smartstore_test.go +++ b/test/smartstore/manager_smartstore_test.go @@ -7,8 +7,8 @@ import ( enterpriseApi "github.com/splunk/splunk-operator/api/v4" - "github.com/onsi/ginkgo/v2/types" . "github.com/onsi/ginkgo/v2" + "github.com/onsi/ginkgo/v2/types" . "github.com/onsi/gomega" "github.com/splunk/splunk-operator/test/testenv" diff --git a/test/smartstore/smartstore_test.go b/test/smartstore/smartstore_test.go index f1c330a66..c2d550411 100644 --- a/test/smartstore/smartstore_test.go +++ b/test/smartstore/smartstore_test.go @@ -5,8 +5,8 @@ import ( "fmt" "time" - "github.com/onsi/ginkgo/v2/types" . "github.com/onsi/ginkgo/v2" + "github.com/onsi/ginkgo/v2/types" . "github.com/onsi/gomega" enterpriseApiV3 "github.com/splunk/splunk-operator/api/v3" diff --git a/test/smoke/smoke_test.go b/test/smoke/smoke_test.go index 9c0a609e6..de4d26e88 100644 --- a/test/smoke/smoke_test.go +++ b/test/smoke/smoke_test.go @@ -17,8 +17,8 @@ import ( "context" "fmt" - "github.com/onsi/ginkgo/v2/types" . "github.com/onsi/ginkgo/v2" + "github.com/onsi/ginkgo/v2/types" . "github.com/onsi/gomega" "github.com/splunk/splunk-operator/test/testenv"