Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .go-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.24.4
1.25.0
47 changes: 34 additions & 13 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -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:"
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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


# ----------------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -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.
Expand Down
11 changes: 6 additions & 5 deletions api/v1/coherence_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
Expand Down Expand Up @@ -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":[`)

Expand Down
3 changes: 2 additions & 1 deletion api/v1/coherence_webhook_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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())
}

Expand Down
5 changes: 3 additions & 2 deletions api/v1/coherencejobresource_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion api/v1/coherenceresource_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
}

Expand Down
7 changes: 4 additions & 3 deletions controllers/job/job_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 (
Expand Down Expand Up @@ -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
Expand Down
11 changes: 6 additions & 5 deletions controllers/statefulset/statefulset_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 (
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pkg/management/coherence_management.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
11 changes: 6 additions & 5 deletions pkg/operator/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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 (
Expand Down Expand Up @@ -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 {
Expand Down
7 changes: 4 additions & 3 deletions pkg/runner/cmd_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down Expand Up @@ -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)
Expand Down
33 changes: 17 additions & 16 deletions pkg/runner/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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.
Expand Down Expand Up @@ -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")
}

Expand Down Expand Up @@ -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 {
Expand Down
Loading