chore(deps): update dependency golangci/golangci-lint to v2.2.1 (#1521)

* chore(deps): update dependency golangci/golangci-lint to v2.2.1

* chore(deps): update github/codeql-action action to v3.29.1 (#1519)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update github/codeql-action digest to 4c57370 (#1518)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update dependency b1nary-gr0up/nwa to v0.7.4 (#1520)

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>

* chore(deps): update dependency golangci/golangci-lint to v2.2.1

chore(deps): update dependency golangci/golangci-lint to v2.2.1

Signed-off-by: Hristo Hristov <me@hhristov.info>

---------

Signed-off-by: Hristo Hristov <me@hhristov.info>
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Hristo Hristov <me@hhristov.info>
This commit is contained in:
renovate[bot]
2025-06-30 13:41:40 +03:00
committed by GitHub
parent 91b4266573
commit eb121a91f2
30 changed files with 45 additions and 26 deletions

View File

@@ -23,6 +23,8 @@ linters:
- unparam
- varnamelen
- wrapcheck
- noinlineerr
- revive
settings:
cyclop:
max-complexity: 27

View File

@@ -383,7 +383,7 @@ nwa:
$(call go-install-tool,$(NWA),github.com/$(NWA_LOOKUP)@$(NWA_VERSION))
GOLANGCI_LINT := $(LOCALBIN)/golangci-lint
GOLANGCI_LINT_VERSION := v2.1.6
GOLANGCI_LINT_VERSION := v2.2.1
GOLANGCI_LINT_LOOKUP := golangci/golangci-lint
golangci-lint: ## Download golangci-lint locally if necessary.
@test -s $(GOLANGCI_LINT) && $(GOLANGCI_LINT) -h | grep -q $(GOLANGCI_LINT_VERSION) || \

View File

@@ -65,7 +65,8 @@ func (in *Tenant) Hub() {}
type TenantList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Tenant `json:"items"`
Items []Tenant `json:"items"`
}
func init() {

View File

@@ -71,7 +71,8 @@ type CapsuleConfiguration struct {
type CapsuleConfigurationList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []CapsuleConfiguration `json:"items"`
Items []CapsuleConfiguration `json:"items"`
}
func init() {

View File

@@ -59,6 +59,7 @@ func (r *ResourcePoolClaimsList) GetClaimByUID(uid types.UID) *ResourcePoolClaim
type ResourcePoolClaimsItem struct {
// Reference to the GlobalQuota being claimed from
api.StatusNameUID `json:",inline"`
// Claimed resources
Claims corev1.ResourceList `json:"claims,omitempty"`
}

View File

@@ -68,7 +68,8 @@ type ResourcePool struct {
type ResourcePoolList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []ResourcePool `json:"items"`
Items []ResourcePool `json:"items"`
}
func init() {

View File

@@ -50,7 +50,8 @@ type ResourcePoolClaim struct {
type ResourcePoolClaimList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []ResourcePoolClaim `json:"items"`
Items []ResourcePoolClaim `json:"items"`
}
func init() {

View File

@@ -102,7 +102,8 @@ func (in *Tenant) GetNamespaces() (res []string) {
type TenantList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Tenant `json:"items"`
Items []Tenant `json:"items"`
}
func init() {

View File

@@ -10,9 +10,10 @@ import (
// GlobalTenantResourceSpec defines the desired state of GlobalTenantResource.
type GlobalTenantResourceSpec struct {
// Defines the Tenant selector used target the tenants on which resources must be propagated.
TenantSelector metav1.LabelSelector `json:"tenantSelector,omitempty"`
TenantResourceSpec `json:",inline"`
// Defines the Tenant selector used target the tenants on which resources must be propagated.
TenantSelector metav1.LabelSelector `json:"tenantSelector,omitempty"`
}
// GlobalTenantResourceStatus defines the observed state of GlobalTenantResource.
@@ -54,7 +55,8 @@ type GlobalTenantResource struct {
type GlobalTenantResourceList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []GlobalTenantResource `json:"items"`
Items []GlobalTenantResource `json:"items"`
}
func init() {

View File

@@ -69,7 +69,8 @@ type TenantResource struct {
type TenantResourceList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []TenantResource `json:"items"`
Items []TenantResource `json:"items"`
}
func init() {

View File

@@ -23,6 +23,7 @@ type ObjectReferenceAbstract struct {
type ObjectReferenceStatus struct {
ObjectReferenceAbstract `json:",inline"`
// Name of the referent.
// More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names
Name string `json:"name"`
@@ -30,6 +31,7 @@ type ObjectReferenceStatus struct {
type ObjectReference struct {
ObjectReferenceAbstract `json:",inline"`
// Label selector used to select the given resources in the given Namespace.
Selector metav1.LabelSelector `json:"selector"`
}

View File

@@ -237,8 +237,8 @@ func (in *GlobalTenantResourceList) DeepCopyObject() runtime.Object {
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *GlobalTenantResourceSpec) DeepCopyInto(out *GlobalTenantResourceSpec) {
*out = *in
in.TenantSelector.DeepCopyInto(&out.TenantSelector)
in.TenantResourceSpec.DeepCopyInto(&out.TenantResourceSpec)
in.TenantSelector.DeepCopyInto(&out.TenantSelector)
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new GlobalTenantResourceSpec.

View File

@@ -42,8 +42,8 @@ func (m *MetadataReconciler) Reconcile(ctx context.Context, request ctrl.Request
tenant, err := m.getTenant(ctx, request.NamespacedName, m.Client)
if err != nil {
noTenantObjError := &NonTenantObjectError{}
noPodMetaError := &NoPodMetadataError{}
noPodMetaError := &NoPodMetadataError{}
if errors.As(err, &noTenantObjError) || errors.As(err, &noPodMetaError) {
return reconcile.Result{}, nil
}

View File

@@ -53,7 +53,6 @@ func (r *Manager) SetupWithManager(ctx context.Context, mgr ctrl.Manager, config
}
},
}).Complete(r)
if crbErr != nil {
err = errors.Join(err, crbErr)
}

View File

@@ -29,6 +29,7 @@ import (
type resourceClaimController struct {
client.Client
metrics *metrics.ClaimRecorder
log logr.Logger
recorder record.EventRecorder

View File

@@ -33,6 +33,7 @@ import (
type resourcePoolController struct {
client.Client
metrics *metrics.ResourcePoolRecorder
log logr.Logger
recorder record.EventRecorder
@@ -103,7 +104,6 @@ func (r resourcePoolController) Reconcile(ctx context.Context, request ctrl.Requ
return r.Client.Status().Update(ctx, current)
})
if reconcileErr != nil || err != nil {
log.V(3).Info("Failed to reconcile ResourcePool", "error", err)

View File

@@ -202,6 +202,7 @@ func (r *Processor) HandleSection(ctx context.Context, tnt capsulev1beta2.Tenant
if opErr := r.createOrUpdate(ctx, &obj, objLabels, objAnnotations); opErr != nil {
log.Error(opErr, "unable to sync namespacedItems", kv...)
errorsChan <- opErr
return

View File

@@ -34,8 +34,8 @@ func (r *abstractServiceLabelsReconciler) Reconcile(ctx context.Context, request
tenant, err := r.getTenant(ctx, request.NamespacedName, r.client)
if err != nil {
noTenantObjError := &NonTenantObjectError{}
noSvcMetaError := &NoServicesMetadataError{}
noSvcMetaError := &NoServicesMetadataError{}
if errors.As(err, &noTenantObjError) || errors.As(err, &noSvcMetaError) {
return reconcile.Result{}, nil
}

View File

@@ -64,6 +64,7 @@ func (r *Manager) syncLimitRange(ctx context.Context, tenant *capsulev1beta2.Ten
}
var res controllerutil.OperationResult
res, err = controllerutil.CreateOrUpdate(ctx, r.Client, target, func() (err error) {
labels := target.GetLabels()
if labels == nil {

View File

@@ -25,6 +25,7 @@ import (
type Manager struct {
client.Client
Metrics *metrics.TenantRecorder
Log logr.Logger
Recorder record.EventRecorder

View File

@@ -63,6 +63,7 @@ func (r *Manager) syncNetworkPolicy(ctx context.Context, tenant *capsulev1beta2.
}
var res controllerutil.OperationResult
res, err = controllerutil.CreateOrUpdate(ctx, r.Client, target, func() (err error) {
labels := target.GetLabels()
if labels == nil {

View File

@@ -128,6 +128,7 @@ func (r *Manager) syncAdditionalRoleBinding(ctx context.Context, tenant *capsule
}
var res controllerutil.OperationResult
res, err = controllerutil.CreateOrUpdate(ctx, r.Client, target, func() error {
if target.Labels == nil {
target.Labels = map[string]string{}

View File

@@ -41,6 +41,7 @@ const (
type Reconciler struct {
client.Client
Log logr.Logger
Scheme *runtime.Scheme
Namespace string

View File

@@ -17,7 +17,8 @@ import (
type DefaultAllowedListSpec struct {
SelectorAllowedListSpec `json:",inline"`
Default string `json:"default,omitempty"`
Default string `json:"default,omitempty"`
}
func (in *DefaultAllowedListSpec) MatchDefault(value string) bool {
@@ -92,7 +93,8 @@ func (in *AllowedListSpec) RegexMatch(value string) (ok bool) {
// +kubebuilder:object:generate=true
type SelectionListWithDefaultSpec struct {
SelectionListWithSpec `json:",inline"`
Default string `json:"default,omitempty"`
Default string `json:"default,omitempty"`
}
func (in *SelectionListWithDefaultSpec) MatchDefault(value string) bool {

View File

@@ -86,6 +86,7 @@ func ValidateForbidden(metadata map[string]string, forbiddenList ForbiddenListSp
for key := range metadata {
var forbidden, matched bool
forbidden = forbiddenList.ExactMatch(key)
matched = forbiddenList.RegexMatch(key)

View File

@@ -3,9 +3,7 @@
package api
import (
k8stypes "k8s.io/apimachinery/pkg/types"
)
import k8stypes "k8s.io/apimachinery/pkg/types"
// Name must be unique within a namespace. Is required when creating resources, although
// some resources may allow a client to request the generation of an appropriate name
@@ -23,10 +21,11 @@ func (n Name) String() string {
}
type StatusNameUID struct {
// UID of the tracked Tenant to pin point tracking
k8stypes.UID `json:"uid,omitempty" protobuf:"bytes,5,opt,name=uid"`
// Name
Name Name `json:"name,omitempty"`
// Namespace
Namespace Name `json:"namespace,omitempty"`
// UID of the tracked Tenant to pin point tracking
k8stypes.UID `json:"uid,omitempty" protobuf:"bytes,5,opt,name=uid"`
}

View File

@@ -74,7 +74,6 @@ func (r *collision) validate(ctx context.Context, client client.Client, req admi
}
var collisionErr *ingressHostnameCollisionError
if errors.As(err, &collisionErr) {
recorder.Eventf(tenant, corev1.EventTypeWarning, "IngressHostnameCollision", "Ingress %s/%s hostname is colliding", ing.Namespace(), ing.Name())
}

View File

@@ -80,7 +80,6 @@ func (r *hostnames) validate(ctx context.Context, client client.Client, req admi
}
var hostnameNotValidErr *ingressHostnameNotValidError
if errors.As(err, &hostnameNotValidErr) {
recorder.Eventf(tenant, corev1.EventTypeWarning, "IngressHostnameNotValid", "Ingress %s/%s hostname is not valid", ingress.Namespace(), ingress.Name())

View File

@@ -97,6 +97,7 @@ func (r *userMetadataHandler) getForbiddenNodeLabels(node *corev1.Node) map[stri
for label, value := range node.GetLabels() {
var forbidden, matched bool
forbidden = forbiddenLabels.ExactMatch(label)
matched = forbiddenLabels.RegexMatch(label)
@@ -115,6 +116,7 @@ func (r *userMetadataHandler) getForbiddenNodeAnnotations(node *corev1.Node) map
for annotation, value := range node.GetAnnotations() {
var forbidden, matched bool
forbidden = forbiddenAnnotations.ExactMatch(annotation)
matched = forbiddenAnnotations.RegexMatch(annotation)

View File

@@ -36,7 +36,6 @@ func (r *resourceCounterHandler) OnCreate(clt client.Client, _ admission.Decoder
var tntName string
var err error
if tntName, err = r.getTenantName(ctx, clt, req); err != nil {
return utils.ErroredResponse(err)
}
@@ -90,7 +89,6 @@ func (r *resourceCounterHandler) OnDelete(clt client.Client, _ admission.Decoder
var tntName string
var err error
if tntName, err = r.getTenantName(ctx, clt, req); err != nil {
return utils.ErroredResponse(err)
}