From aa0454b48172e4a8dda42dc0de8e8a56dacb82bd Mon Sep 17 00:00:00 2001 From: Jonathan Knight Date: Tue, 19 Aug 2025 16:54:09 +0300 Subject: [PATCH] Build using Go 1.25.0 --- .go-version | 2 +- .golangci.yml | 47 ++++++++++++++----- Makefile | 5 +- api/v1/coherence_types.go | 11 +++-- api/v1/coherence_webhook_job.go | 3 +- api/v1/coherencejobresource_types.go | 5 +- api/v1/coherenceresource_types.go | 3 +- controllers/job/job_controller.go | 7 +-- .../statefulset/statefulset_controller.go | 11 +++-- go.mod | 2 +- pkg/management/coherence_management.go | 2 +- pkg/operator/operator.go | 11 +++-- pkg/runner/cmd_server.go | 7 +-- pkg/runner/runner.go | 33 ++++++------- pkg/runner/runner_initialise_test.go | 11 +++-- .../certification/certifiy_deployment_test.go | 13 ++--- test/e2e/helper/e2e-helpers.go | 20 ++++---- test/e2e/helper/rest_helpers.go | 9 ++-- test/e2e/local/clustering_test.go | 7 +-- utils/docgen/main.go | 4 +- utils/linkcheck/main.go | 20 +++----- 21 files changed, 130 insertions(+), 103 deletions(-) diff --git a/.go-version b/.go-version index 7ad7fa018..f2538f8b5 100644 --- a/.go-version +++ b/.go-version @@ -1 +1 @@ -1.24.4 \ No newline at end of file +1.25.0 \ No newline at end of file diff --git a/.golangci.yml b/.golangci.yml index 46dddb4fb..7bc39411b 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,26 +1,47 @@ # options for analysis running +version: "2" + run: # include test files or not, default is true tests: true +formatters: + enable: + - gofmt + exclusions: + generated: disable + paths: + - data/ + linters: + settings: + staticcheck: + dot-import-whitelist: + - github.com/onsi/gomeg enable: - asasalint - asciicheck - bidichk - bodyclose - gocritic - - gofmt -issues: - # Excluding configuration per-path, per-linter, per-text and per-source - exclude-rules: - # Exclude some linters from running on data files. - - path: pkg/data - linters: - - gofmt - # Exclude some linters from running on tests files. - - path: test\.go - linters: - - gosec - - bodyclose + exclusions: + presets: + - common-false-positives + paths: + - utils/docgen/main.go + - utils/linkcheck/main.go + rules: + - path: _test\.go + linters: + - gosec + - bodyclose + - errcheck + - path: test/ + linters: + - staticcheck + text: "ST1001:" + - path: pkg/fakes/ + linters: + - staticcheck + text: "ST1001:" diff --git a/Makefile b/Makefile index eee6830a8..a88565772 100644 --- a/Makefile +++ b/Makefile @@ -881,8 +881,7 @@ code-review: $(BUILD_TARGETS)/generate golangci copyright ## Full code review a # ---------------------------------------------------------------------------------------------------------------------- .PHONY: golangci golangci: $(TOOLS_BIN)/golangci-lint ## Go code review - $(TOOLS_BIN)/golangci-lint run -v --timeout=5m --exclude='G402:' --exclude='G101:' --exclude='G114:' --exclude-dirs=.*/fakes --exclude-files=zz_.*,generated/*,pkg/data/assets... ./api/... ./controllers/... ./pkg/... ./runner/... - $(TOOLS_BIN)/golangci-lint run -v --timeout=5m --exclude='G107:' --exclude='G101:' --exclude='G112:' --exclude='SA4005:' --exclude='should not use dot imports' ./test/... ./pkg/fakes/... + $(TOOLS_BIN)/golangci-lint run -v --timeout=5m # ---------------------------------------------------------------------------------------------------------------------- @@ -2969,7 +2968,7 @@ get-istio: $(BUILD_PROPS) $(BUILD_OUTPUT)/istio-config.yaml ## Download Istio to # ---------------------------------------------------------------------------------------------------------------------- $(TOOLS_BIN)/golangci-lint: @mkdir -p $(TOOLS_BIN) - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh --header $(GH_AUTH) | sh -s -- -b $(TOOLS_BIN) v1.64.7 + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh --header $(GH_AUTH) | sh -s -- -b $(TOOLS_BIN) v2.4.0 # ---------------------------------------------------------------------------------------------------------------------- # Display the full version string for the artifacts that would be built. diff --git a/api/v1/coherence_types.go b/api/v1/coherence_types.go index 392b2c542..72568802b 100644 --- a/api/v1/coherence_types.go +++ b/api/v1/coherence_types.go @@ -11,6 +11,11 @@ import ( "context" "encoding/json" "fmt" + "os" + "strconv" + "strings" + "time" + "github.com/go-logr/logr" "github.com/go-test/deep" "github.com/oracle/coherence-operator/pkg/operator" @@ -26,13 +31,9 @@ import ( "k8s.io/apimachinery/pkg/runtime/schema" "k8s.io/apimachinery/pkg/util/intstr" "k8s.io/utils/ptr" - "os" "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" "sigs.k8s.io/controller-runtime/pkg/manager" - "strconv" - "strings" - "time" ) // Common Coherence API structs @@ -2985,7 +2986,7 @@ type Resources struct { func (in Resources) MarshalJSON() ([]byte, error) { buffer := bytes.NewBufferString("{") - buffer.WriteString(fmt.Sprintf(`"apiVersion":"%d"`, in.Version)) + _, _ = fmt.Fprintf(buffer, `"apiVersion":"%d"`, in.Version) buffer.WriteString(`, "kind": "Resources"`) buffer.WriteString(`, "items":[`) diff --git a/api/v1/coherence_webhook_job.go b/api/v1/coherence_webhook_job.go index 22994b580..3ed2e8111 100644 --- a/api/v1/coherence_webhook_job.go +++ b/api/v1/coherence_webhook_job.go @@ -9,6 +9,7 @@ package v1 import ( "context" "fmt" + batchv1 "k8s.io/api/batch/v1" corev1 "k8s.io/api/core/v1" apiequality "k8s.io/apimachinery/pkg/api/equality" @@ -68,7 +69,7 @@ func (in *CoherenceJob) Default(_ context.Context, obj runtime.Object) error { } // set the default replicas if not present - if spec.CoherenceResourceSpec.Replicas == nil { + if spec.Replicas == nil { spec.SetReplicas(spec.GetReplicas()) } diff --git a/api/v1/coherencejobresource_types.go b/api/v1/coherencejobresource_types.go index 0394e1244..0e45b6726 100644 --- a/api/v1/coherencejobresource_types.go +++ b/api/v1/coherencejobresource_types.go @@ -8,6 +8,7 @@ package v1 import ( "fmt" + "github.com/oracle/coherence-operator/pkg/operator" "golang.org/x/mod/semver" batchv1 "k8s.io/api/batch/v1" @@ -544,10 +545,10 @@ func (in *CoherenceJobResourceSpec) GetRestartPolicy() *corev1.RestartPolicy { // return either the actual Replica value or the default (DefaultReplicas const) // if the Replicas field is nil. func (in *CoherenceJobResourceSpec) GetReplicas() int32 { - if in == nil || in.CoherenceResourceSpec.Replicas == nil { + if in == nil || in.Replicas == nil { return DefaultJobReplicas } - return *in.CoherenceResourceSpec.Replicas + return *in.Replicas } // GetWkaIPFamily returns the IP Family of the headless Service used for Coherence WKA. diff --git a/api/v1/coherenceresource_types.go b/api/v1/coherenceresource_types.go index 66a53a72a..2d420f2e1 100644 --- a/api/v1/coherenceresource_types.go +++ b/api/v1/coherenceresource_types.go @@ -8,6 +8,7 @@ package v1 import ( "fmt" + "github.com/oracle/coherence-operator/pkg/operator" "golang.org/x/mod/semver" appsv1 "k8s.io/api/apps/v1" @@ -186,7 +187,7 @@ func (in *Coherence) GetReplicas() int32 { // SetReplicas sets the number of replicas required for a deployment. func (in *Coherence) SetReplicas(replicas int32) { if in != nil { - in.Spec.CoherenceResourceSpec.Replicas = &replicas + in.Spec.Replicas = &replicas } } diff --git a/controllers/job/job_controller.go b/controllers/job/job_controller.go index 5733b5ad6..d88fa99b5 100644 --- a/controllers/job/job_controller.go +++ b/controllers/job/job_controller.go @@ -9,6 +9,8 @@ package job import ( "context" "fmt" + "time" + "github.com/go-logr/logr" coh "github.com/oracle/coherence-operator/api/v1" "github.com/oracle/coherence-operator/controllers/reconciler" @@ -25,7 +27,6 @@ import ( "sigs.k8s.io/controller-runtime/pkg/client" "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/reconcile" - "time" ) const ( @@ -260,8 +261,8 @@ func (in *ReconcileJob) patchJob(ctx context.Context, deployment coh.CoherenceRe current := job.DeepCopy() // We NEVER patch finalizers - original.ObjectMeta.Finalizers = current.ObjectMeta.Finalizers - desired.ObjectMeta.Finalizers = current.ObjectMeta.Finalizers + original.Finalizers = current.Finalizers + desired.Finalizers = current.Finalizers // We need to ensure we do not create a patch due to differences in // Job Status, so we blank out the status fields diff --git a/controllers/statefulset/statefulset_controller.go b/controllers/statefulset/statefulset_controller.go index 3dcc6ef9f..445c7fdec 100644 --- a/controllers/statefulset/statefulset_controller.go +++ b/controllers/statefulset/statefulset_controller.go @@ -9,6 +9,10 @@ package statefulset import ( "context" "fmt" + "os" + "strings" + "time" + "github.com/go-logr/logr" coh "github.com/oracle/coherence-operator/api/v1" "github.com/oracle/coherence-operator/controllers/reconciler" @@ -25,12 +29,9 @@ import ( apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/utils/ptr" - "os" logf "sigs.k8s.io/controller-runtime/pkg/log" "sigs.k8s.io/controller-runtime/pkg/manager" "sigs.k8s.io/controller-runtime/pkg/reconcile" - "strings" - "time" ) const ( @@ -455,8 +456,8 @@ func (in *ReconcileStatefulSet) maybePatchStatefulSet(ctx context.Context, deplo } // We NEVER patch finalizers - original.ObjectMeta.Finalizers = current.ObjectMeta.Finalizers - desired.ObjectMeta.Finalizers = current.ObjectMeta.Finalizers + original.Finalizers = current.Finalizers + desired.Finalizers = current.Finalizers // We need to ensure we do not create a patch due to differences in // StatefulSet Status, so we blank out the status fields diff --git a/go.mod b/go.mod index 887ffd029..63f4641f3 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ module github.com/oracle/coherence-operator // See ./.go-version for the go compiler version used when building binaries // // https://go.dev/doc/modules/gomod-ref#go -go 1.24.4 +go 1.25.0 require ( github.com/distribution/reference v0.6.0 diff --git a/pkg/management/coherence_management.go b/pkg/management/coherence_management.go index c5fa787d6..545f56a7f 100644 --- a/pkg/management/coherence_management.go +++ b/pkg/management/coherence_management.go @@ -148,7 +148,7 @@ func query(cl *http.Client, url string, v interface{}) (int, error) { } if response != nil { - defer response.Body.Close() + defer func() { _ = response.Body.Close() }() } if err != nil { diff --git a/pkg/operator/operator.go b/pkg/operator/operator.go index f547a718a..e22b4971a 100644 --- a/pkg/operator/operator.go +++ b/pkg/operator/operator.go @@ -11,6 +11,11 @@ import ( "crypto/tls" "flag" "fmt" + "os" + "path/filepath" + "strings" + "time" + "github.com/go-logr/logr" "github.com/oracle/coherence-operator/pkg/clients" "github.com/oracle/coherence-operator/pkg/data" @@ -19,11 +24,7 @@ import ( "github.com/spf13/viper" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/util/version" - "os" - "path/filepath" ctrl "sigs.k8s.io/controller-runtime" - "strings" - "time" ) const ( @@ -553,7 +554,7 @@ func NewCipherSuiteConfig(v *viper.Viper, log logr.Logger) (func(c *tls.Config), if allDenied && len(allowList) == 0 { return func(c *tls.Config) {}, - fmt.Errorf("The --%s command line flag has denied all cipher suites but no allowed suites have been specified using the %s flag ", FlagCipherDenyList, FlagCipherAllowList) + fmt.Errorf("the --%s command line flag has denied all cipher suites but no allowed suites have been specified using the %s flag ", FlagCipherDenyList, FlagCipherAllowList) } for _, name := range allowList { diff --git a/pkg/runner/cmd_server.go b/pkg/runner/cmd_server.go index a2b82c39c..35e174dd8 100644 --- a/pkg/runner/cmd_server.go +++ b/pkg/runner/cmd_server.go @@ -9,12 +9,13 @@ package runner import ( "bufio" "fmt" + "os" + "strings" + v1 "github.com/oracle/coherence-operator/api/v1" "github.com/oracle/coherence-operator/pkg/runner/run_details" "github.com/pkg/errors" "github.com/spf13/cobra" - "os" - "strings" ) const ( @@ -124,7 +125,7 @@ func readLines(path string) ([]string, error) { if err != nil { return nil, err } - defer file.Close() + defer func() { _ = file.Close() }() var lines []string scanner := bufio.NewScanner(file) diff --git a/pkg/runner/runner.go b/pkg/runner/runner.go index 763f7203b..cc86d2883 100644 --- a/pkg/runner/runner.go +++ b/pkg/runner/runner.go @@ -11,6 +11,16 @@ import ( "bytes" "context" "fmt" + "io" + "net/http" + "net/url" + "os" + "os/exec" + "path/filepath" + "strconv" + "strings" + "time" + "github.com/fsnotify/fsnotify" "github.com/go-logr/logr" v1 "github.com/oracle/coherence-operator/api/v1" @@ -20,17 +30,8 @@ import ( "github.com/spf13/cobra" "github.com/spf13/pflag" "github.com/spf13/viper" - "io" "k8s.io/apimachinery/pkg/api/resource" - "net/http" - "net/url" - "os" - "os/exec" - "path/filepath" ctrl "sigs.k8s.io/controller-runtime" - "strconv" - "strings" - "time" ) // The code that actually starts the process in the Coherence container. @@ -443,16 +444,16 @@ func configureCommand(details *run_details.RunDetails) error { } gc := strings.ToLower(details.Getenv(v1.EnvVarJvmGcCollector)) - switch { - case gc == "g1": + switch gc { + case "g1": details.AddMemoryOption("-XX:+UseG1GC") - case gc == "cms": + case "cms": details.AddMemoryOption("-XX:+UseConcMarkSweepGC") - case gc == "parallel": + case "parallel": details.AddMemoryOption("-XX:+UseParallelGC") - case gc == "serial": + case "serial": details.AddMemoryOption("-XX:+UseSerialGC") - case gc == "zgc": + case "zgc": details.AddMemoryOption("-XX:+UseZGC") } @@ -948,7 +949,7 @@ func httpGet(urlString string, client http.Client) (string, int, error) { return "", http.StatusInternalServerError, errors.Wrapf(err, "failed to get URL %s", urlString) } //noinspection GoUnhandledErrorResult - defer resp.Body.Close() + defer func() { _ = resp.Body.Close() }() body, err := io.ReadAll(resp.Body) if err != nil { diff --git a/pkg/runner/runner_initialise_test.go b/pkg/runner/runner_initialise_test.go index b472e00e9..d0553d305 100644 --- a/pkg/runner/runner_initialise_test.go +++ b/pkg/runner/runner_initialise_test.go @@ -8,14 +8,15 @@ package runner import ( "fmt" - . "github.com/onsi/gomega" - coh "github.com/oracle/coherence-operator/api/v1" - "github.com/oracle/coherence-operator/test/e2e/helper" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "math/rand" "os" "strings" "testing" + + . "github.com/onsi/gomega" + coh "github.com/oracle/coherence-operator/api/v1" + "github.com/oracle/coherence-operator/test/e2e/helper" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) const ( @@ -149,7 +150,7 @@ func createFakeFile(filename string) error { defer closeIgnoreError(f) data := rand.Intn(100) - if _, err = f.WriteString(fmt.Sprintf("%d", data)); err != nil { + if _, err = fmt.Fprintf(f, "%d", data); err != nil { return err } diff --git a/test/certification/certifiy_deployment_test.go b/test/certification/certifiy_deployment_test.go index e1cfcdb01..62b08b7c5 100644 --- a/test/certification/certifiy_deployment_test.go +++ b/test/certification/certifiy_deployment_test.go @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2024, Oracle and/or its affiliates. + * Copyright (c) 2020, 2025, Oracle and/or its affiliates. * Licensed under the Universal Permissive License v 1.0 as shown at * http://oss.oracle.com/licenses/upl. */ @@ -9,16 +9,17 @@ package certification import ( "context" "fmt" - . "github.com/onsi/gomega" - v1 "github.com/oracle/coherence-operator/api/v1" - "github.com/oracle/coherence-operator/test/e2e/helper" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/utils/ptr" "os" "os/exec" "strings" "testing" "time" + + . "github.com/onsi/gomega" + v1 "github.com/oracle/coherence-operator/api/v1" + "github.com/oracle/coherence-operator/test/e2e/helper" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/utils/ptr" ) func TestCertifyMinimalSpec(t *testing.T) { diff --git a/test/e2e/helper/e2e-helpers.go b/test/e2e/helper/e2e-helpers.go index 5a6c5392d..d9ff849ad 100644 --- a/test/e2e/helper/e2e-helpers.go +++ b/test/e2e/helper/e2e-helpers.go @@ -11,11 +11,15 @@ import ( goctx "context" "encoding/json" "fmt" + "io" + "os" + "strings" + "testing" + . "github.com/onsi/gomega" coh "github.com/oracle/coherence-operator/api/v1" "github.com/oracle/coherence-operator/pkg/operator" "golang.org/x/net/context" - "io" appsv1 "k8s.io/api/apps/v1" batchv1 "k8s.io/api/batch/v1" corev1 "k8s.io/api/core/v1" @@ -24,13 +28,9 @@ import ( "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "k8s.io/utils/ptr" - "os" "sigs.k8s.io/controller-runtime/pkg/client/apiutil" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" - "strings" - "testing" - "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/client-go/kubernetes" @@ -416,7 +416,7 @@ func WaitForOperatorPods(ctx TestContext, namespace string, retryInterval, timeo func DeleteJob(ctx TestContext, namespace, jobName string) error { cl := ctx.KubeClient.BatchV1().Jobs(namespace) - if err := cl.Delete(ctx.Context, jobName, metav1.DeleteOptions{PropagationPolicy: ptr.To(metav1.DeletePropagationBackground)}); err != nil && !errors.IsNotFound(err) { + if err := cl.Delete(ctx.Context, jobName, metav1.DeleteOptions{PropagationPolicy: ptr.To(metav1.DeletePropagationBackground)}); err != nil && !apierrors.IsNotFound(err) { return err } pods, err := ListPodsWithLabelSelector(ctx, namespace, "job-name="+jobName) @@ -496,9 +496,9 @@ func WaitForDeletion(ctx TestContext, namespace, name string, resource client.Ob err := wait.PollUntilContextTimeout(ctx.Context, retryInterval, timeout, true, func(context.Context) (done bool, err error) { err = ctx.Client.Get(ctx.Context, key, resource) switch { - case err != nil && errors.IsNotFound(err): + case err != nil && apierrors.IsNotFound(err): return true, nil - case err != nil && !errors.IsNotFound(err): + case err != nil && !apierrors.IsNotFound(err): ctx.Logf("Waiting for deletion of %v %s/%s - Error=%s", gvk, namespace, name, err) return false, err default: @@ -737,7 +737,7 @@ func WaitForCoherenceCleanup(ctx TestContext, namespace string) error { // Wait for removal of the Coherence resources err = wait.PollUntilContextTimeout(ctx.Context, RetryInterval, Timeout, true, func(context.Context) (done bool, err error) { err = ctx.Client.List(goctx.TODO(), list, client.InNamespace(namespace)) - if err == nil || isNoResources(err) || errors.IsNotFound(err) { + if err == nil || isNoResources(err) || apierrors.IsNotFound(err) { if len(list.Items) > 0 { ctx.Logf("Waiting for deletion of %d Coherence resources", len(list.Items)) return false, nil @@ -812,7 +812,7 @@ func waitForCoherenceJobCleanup(ctx TestContext, namespace string) error { // Wait for removal of the CoherenceJob resources err = wait.PollUntilContextTimeout(ctx.Context, RetryInterval, Timeout, true, func(context.Context) (done bool, err error) { err = ctx.Client.List(goctx.TODO(), list, client.InNamespace(namespace)) - if err == nil || isNoResources(err) || errors.IsNotFound(err) { + if err == nil || isNoResources(err) || apierrors.IsNotFound(err) { if len(list.Items) > 0 { ctx.Logf("Waiting for deletion of %d CoherenceJob resources", len(list.Items)) return false, nil diff --git a/test/e2e/helper/rest_helpers.go b/test/e2e/helper/rest_helpers.go index a9e545eda..fad55b63a 100644 --- a/test/e2e/helper/rest_helpers.go +++ b/test/e2e/helper/rest_helpers.go @@ -10,12 +10,13 @@ import ( "context" "fmt" "io" - v1 "k8s.io/api/core/v1" - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" - "k8s.io/apimachinery/pkg/util/wait" "net/http" "strings" "time" + + v1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/util/wait" ) // StartCanary initialises the canary test in the deployment being scaled. @@ -104,7 +105,7 @@ func httpRequestToPod(endpoint, method string, pod *v1.Pod) error { } if resp.StatusCode < http.StatusOK || resp.StatusCode >= http.StatusMultipleChoices { - defer resp.Body.Close() + defer func() { _ = resp.Body.Close() }() bodyBytes, err := io.ReadAll(resp.Body) bodyString := "" if err == nil { diff --git a/test/e2e/local/clustering_test.go b/test/e2e/local/clustering_test.go index 385295a23..0f202b35f 100644 --- a/test/e2e/local/clustering_test.go +++ b/test/e2e/local/clustering_test.go @@ -9,6 +9,9 @@ package local import ( "context" "fmt" + "testing" + "time" + . "github.com/onsi/gomega" coh "github.com/oracle/coherence-operator/api/v1" "github.com/oracle/coherence-operator/pkg/utils" @@ -16,8 +19,6 @@ import ( appsv1 "k8s.io/api/apps/v1" apierrors "k8s.io/apimachinery/pkg/api/errors" "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil" - "testing" - "time" ) // Test that a deployment works using the minimal valid yaml for a Coherence @@ -108,7 +109,7 @@ func TestStartQuorumRequireOnePodReady(t *testing.T) { g.Expect(created).NotTo(BeNil()) // created time should not be before first data Pod ready time g.Expect(created.LastTransitionTime.Time.Before(dataPodReady.Time)).To(BeFalse(), - fmt.Sprintf("Expected test created %s after data ready %s", created.LastTransitionTime.Time.String(), dataPodReady.Time.String())) + fmt.Sprintf("Expected test created %s after data ready %s", created.LastTransitionTime.String(), dataPodReady.String())) // earliest test Pod scheduled should not be before last data Pod ready testPodScheduled := helper.GetFirstPodScheduledTime(pods, "test") diff --git a/utils/docgen/main.go b/utils/docgen/main.go index 125f5f3e0..c5d32e118 100644 --- a/utils/docgen/main.go +++ b/utils/docgen/main.go @@ -269,8 +269,8 @@ func fmtRawDoc(rawDoc string) string { } postDoc := strings.TrimRight(buffer.String(), "\n") - //postDoc = strings.Replace(postDoc, "\\\"", "\"", -1) // replace user's \" to " - //postDoc = strings.Replace(postDoc, "\"", "\\\"", -1) // Escape " + // postDoc = strings.Replace(postDoc, "\\\"", "\"", -1) // replace user's \" to " + // postDoc = strings.Replace(postDoc, "\"", "\\\"", -1) // Escape " postDoc = strings.Replace(postDoc, "\n", " +\n", -1) postDoc = strings.Replace(postDoc, "\t", "    ", -1) postDoc = strings.Replace(postDoc, "|", "\\|", -1) diff --git a/utils/linkcheck/main.go b/utils/linkcheck/main.go index c74090a0f..a8cd44669 100644 --- a/utils/linkcheck/main.go +++ b/utils/linkcheck/main.go @@ -9,28 +9,23 @@ package main import ( "context" "fmt" - "github.com/spf13/cobra" - "github.com/spf13/viper" "io" "net/http" "net/url" "os" "regexp" - ctrl "sigs.k8s.io/controller-runtime" - logf "sigs.k8s.io/controller-runtime/pkg/log" "sort" "strconv" "strings" "time" + + "github.com/spf13/cobra" + "github.com/spf13/viper" + logf "sigs.k8s.io/controller-runtime/pkg/log" ) // checks all the http links in a document -var ( - // log is the logger used by the runner - log = ctrl.Log.WithName("linkcheck") -) - const ( ArgFile = "file" ArgExclude = "exclude" @@ -158,7 +153,7 @@ func checkDirectory(dirName string, excludes []string) (int, []string) { fmt.Printf("Checking directory %s\n", dirName) info, err := os.Stat(dirName) if err != nil { - fmt.Printf(err.Error()) + fmt.Print(err.Error()) return 1, failedLinks } if !info.IsDir() { @@ -174,7 +169,7 @@ func checkFileInfo(dir string, info os.FileInfo, excludes []string) (int, []stri if info.IsDir() { files, err := os.ReadDir(dir) if err != nil { - fmt.Printf(err.Error()) + fmt.Print(err.Error()) return 1, failedLinks } @@ -429,8 +424,7 @@ func parseLinks(content string, excludes []string) ([]string, map[string][]strin s = s[0:(len(s) - 1 - len(linkUrl.Fragment))] } - l := append(linkMap[s], linkUrl.Fragment) - linkMap[s] = l + linkMap[s] = append(linkMap[s], linkUrl.Fragment) } links = make([]string, 0)