Skip to content
Closed
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
16 changes: 11 additions & 5 deletions .golangci.yaml
Original file line number Diff line number Diff line change
@@ -1,20 +1,26 @@
version: "2"

linters:
# Enable specific linter
# https://golangci-lint.run/usage/linters/#enabled-by-default
enable:
- errorlint
- revive
- ginkgolinter
- gofmt
- govet
- errname
- err113
linters-settings:
revive:
rules:
# https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md#unused-parameter

settings:
revive:
rules:
- name: unused-parameter
severity: warning
disabled: true

formatters:
enable:
- gofmt

run:
timeout: 5m
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ GINKGO ?= $(LOCALBIN)/ginkgo

## Tool Versions
CONTROLLER_TOOLS_VERSION ?= v0.14.0
GOTOOLCHAIN_VERSION ?= go1.21.0
GOLANGCI_VERSION ?= v1.64.8
GOTOOLCHAIN_VERSION ?= go1.23.0
GOLANGCI_LINT_VERSION ?= v2.4.0

# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.29
Expand Down Expand Up @@ -124,7 +124,7 @@ gotest: get-ci-tools envtest ## Run go test via ci-tools script against code
.PHONY: golangci
golangci: get-ci-tools ## Run golangci-lint test via ci-tools script against code
for mod in $(shell find modules/ -maxdepth 1 -mindepth 1 -type d); do \
GOLANGCI_TAG=$(GOLANGCI_VERSION) GOWORK=off $(CI_TOOLS_REPO_DIR)/test-runner/golangci.sh ./$$mod || exit 1 ; \
GOLANGCI_TAG=$(GOLANGCI_LINT_VERSION) GOWORK=off $(CI_TOOLS_REPO_DIR)/test-runner/golangci.sh ./$$mod || exit 1 ; \
done

.PHONY: golint
Expand Down
2 changes: 1 addition & 1 deletion modules/ansible/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/openstack-k8s-operators/lib-common/modules/ansible

go 1.21
go 1.23

require gopkg.in/yaml.v3 v3.0.1

Expand Down
4 changes: 2 additions & 2 deletions modules/certmanager/certificate.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func (c *Certificate) Delete(

err := h.GetClient().Delete(ctx, c.certificate)
if err != nil && !k8s_errors.IsNotFound(err) {
return fmt.Errorf("Error deleting certificate %s: %w", c.certificate.Name, err)
return fmt.Errorf("error deleting certificate %s: %w", c.certificate.Name, err)
}

return nil
Expand All @@ -177,7 +177,7 @@ func EnsureCert(

err := helper.GetClient().Get(ctx, types.NamespacedName{Name: request.IssuerName, Namespace: namespace}, issuer)
if err != nil {
err = fmt.Errorf("Error getting issuer %s/%s - %w", request.IssuerName, namespace, err)
err = fmt.Errorf("error getting issuer %s/%s - %w", request.IssuerName, namespace, err)

return nil, ctrl.Result{}, err
}
Expand Down
2 changes: 1 addition & 1 deletion modules/certmanager/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/openstack-k8s-operators/lib-common/modules/certmanager

go 1.21
go 1.23

require (
github.com/cert-manager/cert-manager v1.11.5
Expand Down
6 changes: 3 additions & 3 deletions modules/certmanager/issuer.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func (i *Issuer) Delete(

err := h.GetClient().Delete(ctx, i.issuer)
if err != nil && !k8s_errors.IsNotFound(err) {
return fmt.Errorf("Error deleting issuer %s: %w", i.issuer.Name, err)
return fmt.Errorf("error deleting issuer %s: %w", i.issuer.Name, err)
}

return nil
Expand All @@ -177,7 +177,7 @@ func GetIssuerByName(

err := h.GetClient().Get(ctx, types.NamespacedName{Name: name, Namespace: namespace}, issuer)
if err != nil {
return nil, fmt.Errorf("Error getting issuer %s: %w", issuer.Name, err)
return nil, fmt.Errorf("error getting issuer %s: %w", issuer.Name, err)
}

return issuer, nil
Expand All @@ -204,7 +204,7 @@ func GetIssuerByLabels(

err := h.GetClient().List(ctx, issuers, listOpts...)
if err != nil {
return nil, fmt.Errorf("Error getting issuer by label: %w", err)
return nil, fmt.Errorf("error getting issuer by label: %w", err)
}

if len(issuers.Items) > 1 {
Expand Down
1 change: 1 addition & 0 deletions modules/common/affinity/affinity.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// Package affinity provides utilities for managing Kubernetes pod affinity and anti-affinity rules
package affinity

import (
Expand Down
2 changes: 1 addition & 1 deletion modules/common/affinity/affinity_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package affinity
import (
"testing"

. "github.com/onsi/gomega"
. "github.com/onsi/gomega" // nolint:revive

corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down
1 change: 1 addition & 0 deletions modules/common/annotations/network.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// Package annotations provides utilities for managing network annotations and network attachment definitions
package annotations

import (
Expand Down
3 changes: 2 additions & 1 deletion modules/common/annotations/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ limitations under the License.
package annotations

import (
. "github.com/onsi/gomega"
"testing"

. "github.com/onsi/gomega" // nolint:revive
)

func TestGetNADAnnotation(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions modules/common/clusterdns/clusterdns.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// Package clusterdns provides utilities for DNS cluster domain operations
package clusterdns

// GetDNSClusterDomain - Return openshift dns Cluster Domain name
Expand Down
1 change: 1 addition & 0 deletions modules/common/condition/conditions.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ limitations under the License.

// +kubebuilder:object:generate:=true

// Package condition provides types and utilities for managing Kubernetes condition objects
package condition

// Common Condition Types used by API objects.
Expand Down
14 changes: 7 additions & 7 deletions modules/common/condition/funcs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"testing"
"time"

. "github.com/onsi/gomega"
. "github.com/onsi/gomega" // nolint:revive
"github.com/onsi/gomega/format"
"github.com/onsi/gomega/types"
"github.com/pkg/errors"
Expand Down Expand Up @@ -148,7 +148,7 @@ func TestSet(t *testing.T) {
g.Expect(conditions).To(haveSameConditionsOf(CreateList(unknownReady)))

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Run(tt.name, func(_ *testing.T) {

conditions.Set(tt.condition)

Expand Down Expand Up @@ -224,7 +224,7 @@ func TestRemove(t *testing.T) {
g := NewWithT(t)

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Run(tt.name, func(_ *testing.T) {
tt.conditions.Remove(tt.cType)
g.Expect(tt.expected).To(haveSameConditionsOf(tt.conditions))
})
Expand Down Expand Up @@ -256,7 +256,7 @@ func TestReset(t *testing.T) {
g := NewWithT(t)

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Run(tt.name, func(_ *testing.T) {
tt.conditions.Reset()
g.Expect(tt.expected).To(haveSameConditionsOf(tt.conditions))
})
Expand Down Expand Up @@ -400,7 +400,7 @@ func TestAllSubConditionIsTrue(t *testing.T) {
g.Expect(conditions).To(haveSameConditionsOf(CreateList(unknownReady)))

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Run(tt.name, func(_ *testing.T) {

conditions.Set(tt.condition)
g.Expect(conditions.AllSubConditionIsTrue()).To(BeIdenticalTo(tt.want))
Expand Down Expand Up @@ -651,14 +651,14 @@ func TestRestoreLastTransitionTimes(t *testing.T) {
// LastTransitionTime should change to time2 when HasSameCondition() passes.
{
name: "Same condition state",
patch: func(condition *Condition) {},
patch: func(_ *Condition) {},
want: time2,
},
}

g := NewWithT(t)
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Run(tt.name, func(_ *testing.T) {
testCond := falseA.DeepCopy()
testCond.LastTransitionTime = time1
conditions := CreateList(testCond)
Expand Down
5 changes: 3 additions & 2 deletions modules/common/configmap/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// Package configmap provides utilities for managing Kubernetes ConfigMap resources
package configmap

import (
Expand Down Expand Up @@ -202,7 +203,7 @@ func EnsureConfigMaps(
func GetConfigMaps(
ctx context.Context,
h *helper.Helper,
obj client.Object,
_ client.Object,
configMaps []string,
namespace string,
envVars *map[string]env.Setter,
Expand Down Expand Up @@ -289,7 +290,7 @@ func VerifyConfigMap(
ctrl.Result{RequeueAfter: requeueTimeout},
nil
}
return "", ctrl.Result{}, fmt.Errorf("Get ConfigMap %s failed: %w", configMapName, err)
return "", ctrl.Result{}, fmt.Errorf("get ConfigMap %s failed: %w", configMapName, err)
}

// collect the ConfigMap values the caller expects to exist
Expand Down
3 changes: 2 additions & 1 deletion modules/common/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

package common
// Package common provides shared constants and utilities used across all operators
package common // nolint:revive

// consts used by all operators
const (
Expand Down
3 changes: 2 additions & 1 deletion modules/common/cronjob/cronjob.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// Package cronjob provides utilities for managing Kubernetes CronJob resources
package cronjob

import (
Expand Down Expand Up @@ -79,7 +80,7 @@ func (cj *CronJob) Delete(
) error {
err := h.GetClient().Delete(ctx, cj.cronjob)
if err != nil && !k8s_errors.IsNotFound(err) {
return fmt.Errorf("Error deleting cronjob %s: %w", cj.cronjob.Name, err)
return fmt.Errorf("error deleting cronjob %s: %w", cj.cronjob.Name, err)
}

return nil
Expand Down
3 changes: 2 additions & 1 deletion modules/common/daemonset/daemonset.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// Package daemonset provides utilities for managing Kubernetes DaemonSet resources
package daemonset

import (
Expand Down Expand Up @@ -57,7 +58,7 @@ func (d *DaemonSet) CreateOrPatch(
op, err := controllerutil.CreateOrPatch(ctx, h.GetClient(), daemonset, func() error {
// DaemonSet selector is immutable so we set this value only if
// a new object is going to be created
if daemonset.ObjectMeta.CreationTimestamp.IsZero() {
if daemonset.CreationTimestamp.IsZero() {
daemonset.Spec.Selector = d.daemonset.Spec.Selector
}
daemonset.Annotations = util.MergeStringMaps(daemonset.Annotations, d.daemonset.Annotations)
Expand Down
5 changes: 3 additions & 2 deletions modules/common/deployment/deployment.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// Package deployment provides utilities for managing Kubernetes Deployment resources
package deployment

import (
Expand Down Expand Up @@ -57,7 +58,7 @@ func (d *Deployment) CreateOrPatch(
op, err := controllerutil.CreateOrPatch(ctx, h.GetClient(), deployment, func() error {
// Deployment selector is immutable so we set this value only if
// a new object is going to be created
if deployment.ObjectMeta.CreationTimestamp.IsZero() {
if deployment.CreationTimestamp.IsZero() {
deployment.Spec.Selector = d.deployment.Spec.Selector
}
deployment.Annotations = util.MergeStringMaps(deployment.Annotations, d.deployment.Annotations)
Expand Down Expand Up @@ -100,7 +101,7 @@ func (d *Deployment) Delete(
) error {
err := h.GetClient().Delete(ctx, d.deployment)
if err != nil && !k8s_errors.IsNotFound(err) {
return fmt.Errorf("Error deleting deployment %s: %w", d.deployment.Name, err)
return fmt.Errorf("error deleting deployment %s: %w", d.deployment.Name, err)
}

return nil
Expand Down
1 change: 1 addition & 0 deletions modules/common/endpoint/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// Package endpoint provides utilities for managing Kubernetes endpoints and service discovery
package endpoint

import (
Expand Down
1 change: 1 addition & 0 deletions modules/common/env/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// Package env provides utilities for managing environment variables in Kubernetes containers
package env

import (
Expand Down
2 changes: 1 addition & 1 deletion modules/common/env/env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package env
import (
"testing"

. "github.com/onsi/gomega"
. "github.com/onsi/gomega" // nolint:revive
corev1 "k8s.io/api/core/v1"
)

Expand Down
2 changes: 1 addition & 1 deletion modules/common/go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/openstack-k8s-operators/lib-common/modules/common

go 1.21
go 1.23

require (
github.com/go-logr/logr v1.4.3
Expand Down
1 change: 1 addition & 0 deletions modules/common/helper/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/

// Package helper provides common helper utilities for Kubernetes operations and client management
package helper

import (
Expand Down
2 changes: 1 addition & 1 deletion modules/common/helper/helper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package helper
import (
"testing"

. "github.com/onsi/gomega"
. "github.com/onsi/gomega" // nolint:revive
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"

Expand Down
Loading