Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(deps): Bump k8s.io/apiextensions-apiserver from 0.28.4 to 0.29.2 #976

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
2 changes: 1 addition & 1 deletion .github/workflows/diff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: '1.20'
go-version: '1.21'
- run: make installer
- name: Checking if YAML installer file is not aligned
run: if [[ $(git diff | wc -l) -gt 0 ]]; then echo ">>> Untracked generated files have not been committed" && git --no-pager diff && exit 1; fi
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
fetch-depth: 0
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: '1.20'
go-version: '1.21'
- run: make manifests
- name: Checking if manifests are disaligned
run: test -z "$(git diff 2> /dev/null)"
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ jobs:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- uses: actions/setup-go@0c52d547c9bc32b1aa3301fd7a9cb496313a4491 # v5.0.0
with:
go-version: '1.21'
- name: Run golangci-lint
uses: golangci/golangci-lint-action@3cfe3a4abbb849e10058ce4af15d205b6da42804 # v4.0.0
with:
version: v1.51.2
version: v1.56.2
only-new-issues: false
args: --timeout 5m --config .golangci.yml
21 changes: 18 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,28 @@ linters-settings:
- standard
- default
- prefix(github.com/projectcapsule/capsule)
gofumpt:
module-path: github.com/projectcapsule/capsule
extra-rules: false
goheader:
template: |-
Copyright 2020-2023 Project Capsule Authors.
SPDX-License-Identifier: Apache-2.0

inamedparam:
# Skips check for interface methods with only a single parameter.
# Default: false
skip-single-param: true
nakedret:
# Make an issue if func has more lines of code than this setting, and it has naked returns.
max-func-lines: 50
linters:
enable-all: true
disable:
- perfsprint
- funlen
- gochecknoinits
- lll
- depguard
- exhaustivestruct
- maligned
- interfacer
Expand All @@ -47,9 +58,13 @@ linters:
- ifshort
- nonamedreturns

service:
golangci-lint-version: 1.51.2

run:
timeout: 3m
go: '1.21'
skip-files:
- "zz_.*\\.go$"
- ".+\\.generated.go"
- ".+_test.go"
- ".+_test_.+.go"

3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,9 @@ goimports:
goimports -w -l -local "github.com/projectcapsule/capsule" .

GOLANGCI_LINT = $(shell pwd)/bin/golangci-lint
GOLANGCI_LINT_VERSION := v1.56.2
golangci-lint: ## Download golangci-lint locally if necessary.
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.2)
$(call go-install-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint@$(GOLANGCI_LINT_VERSION))

# Linting code as PR is expecting
.PHONY: golint
Expand Down
2 changes: 1 addition & 1 deletion api/v1beta2/tenant_conversion_hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ func (in *Tenant) ConvertTo(raw conversion.Hub) error {
dst.Spec.IngressOptions.AllowedHostnames = allowed
}

annotations[capsulev1beta1.DenyWildcard] = fmt.Sprintf("%t", !in.Spec.IngressOptions.AllowWildcardHostnames)
annotations[capsulev1beta1.DenyWildcard] = strconv.FormatBool(!in.Spec.IngressOptions.AllowWildcardHostnames)

if allowed := in.Spec.ContainerRegistries; allowed != nil {
dst.Spec.ContainerRegistries = allowed
Expand Down
3 changes: 2 additions & 1 deletion controllers/rbac/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ type Manager struct {
Configuration configuration.Configuration
}

func (r *Manager) SetupWithManager(ctx context.Context, mgr ctrl.Manager, configurationName string) (err error) {
func (r *Manager) SetupWithManager(_ context.Context, mgr ctrl.Manager, configurationName string) (err error) {
namesPredicate := utils.NamesMatchingPredicate(ProvisionerRoleName, DeleterRoleName)

crErr := ctrl.NewControllerManagedBy(mgr).
Expand All @@ -44,6 +44,7 @@ func (r *Manager) SetupWithManager(ctx context.Context, mgr ctrl.Manager, config
crbErr := ctrl.NewControllerManagedBy(mgr).
For(&rbacv1.ClusterRoleBinding{}, namesPredicate).
Watches(&capsulev1beta2.CapsuleConfiguration{}, handler.Funcs{
//nolint:revive
UpdateFunc: func(ctx context.Context, updateEvent event.UpdateEvent, limitingInterface workqueue.RateLimitingInterface) {
if updateEvent.ObjectNew.GetName() == configurationName {
if crbErr := r.EnsureClusterRoleBindings(ctx); crbErr != nil {
Expand Down
11 changes: 9 additions & 2 deletions controllers/resources/processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package resources
import (
"context"
"fmt"
"strconv"

"github.com/hashicorp/go-multierror"
"github.com/valyala/fasttemplate"
Expand Down Expand Up @@ -122,7 +123,7 @@ func (r *Processor) HandleSection(ctx context.Context, tnt capsulev1beta2.Tenant

objAnnotations[tenantLabel] = tnt.GetName()

objLabels[Label] = fmt.Sprintf("%d", resourceIndex)
objLabels[Label] = strconv.Itoa(resourceIndex)
objLabels[tenantLabel] = tnt.GetName()

// processed will contain the sets of resources replicated, both for the raw and the Namespaced ones:
Expand Down Expand Up @@ -159,7 +160,7 @@ func (r *Processor) HandleSection(ctx context.Context, tnt capsulev1beta2.Tenant
}

objs := unstructured.UnstructuredList{}
objs.SetGroupVersionKind(schema.FromAPIVersionAndKind(item.APIVersion, fmt.Sprintf("%sList", item.Kind)))
objs.SetGroupVersionKind(schema.FromAPIVersionAndKind(item.APIVersion, (item.Kind + "List")))

if clientErr := r.client.List(ctx, &objs, client.InNamespace(item.Namespace), client.MatchingLabelsSelector{Selector: itemSelector}); clientErr != nil {
log.Error(clientErr, "cannot retrieve object for namespacedItem", keysAndValues...)
Expand Down Expand Up @@ -266,21 +267,27 @@ func (r *Processor) createOrUpdate(ctx context.Context, obj *unstructured.Unstru
rv := actual.GetResourceVersion()

actual.SetUnstructuredContent(desired.Object)

combinedLabels := obj.GetLabels()
if combinedLabels == nil {
combinedLabels = make(map[string]string)
}

for key, value := range labels {
combinedLabels[key] = value
}

actual.SetLabels(combinedLabels)

combinedAnnotations := obj.GetAnnotations()
if combinedAnnotations == nil {
combinedAnnotations = make(map[string]string)
}

for key, value := range annotations {
combinedAnnotations[key] = value
}

actual.SetAnnotations(combinedAnnotations)
actual.SetResourceVersion(rv)
actual.SetUID(UID)
Expand Down
3 changes: 2 additions & 1 deletion controllers/tenant/limitranges.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ func (r *Manager) syncLimitRange(ctx context.Context, tenant *capsulev1beta2.Ten
if labels == nil {
labels = map[string]string{}
}

labels[tenantLabel] = tenant.Name
labels[limitRangeLabel] = strconv.Itoa(i)

Expand All @@ -78,7 +79,7 @@ func (r *Manager) syncLimitRange(ctx context.Context, tenant *capsulev1beta2.Ten
return controllerutil.SetControllerReference(tenant, target, r.Client.Scheme())
})

r.emitEvent(tenant, target.GetNamespace(), res, fmt.Sprintf("Ensuring LimitRange %s", target.GetName()), err)
r.emitEvent(tenant, target.GetNamespace(), res, ("Ensuring LimitRange " + target.GetName()), err)

r.Log.Info("LimitRange sync result: "+string(res), "name", target.Name, "namespace", target.Namespace)

Expand Down
22 changes: 11 additions & 11 deletions controllers/tenant/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,19 +52,19 @@ func (r Manager) Reconcile(ctx context.Context, request ctrl.Request) (result ct

r.Log.Error(err, "Error reading the object")

return
return reconcile.Result{}, nil
}
// Ensuring the Tenant Status
if err = r.updateTenantStatus(ctx, instance); err != nil {
r.Log.Error(err, "Cannot update Tenant status")

return
return reconcile.Result{}, nil
}
// Ensuring Metadata
if err = r.ensureMetadata(ctx, instance); err != nil {
r.Log.Error(err, "Cannot ensure metadata")

return
return reconcile.Result{}, nil
}

// Ensuring ResourceQuota
Expand All @@ -73,63 +73,63 @@ func (r Manager) Reconcile(ctx context.Context, request ctrl.Request) (result ct
if err = r.syncCustomResourceQuotaUsages(ctx, instance); err != nil {
r.Log.Error(err, "Cannot count limited resources")

return
return reconcile.Result{}, nil
}
// Ensuring all namespaces are collected
r.Log.Info("Ensuring all Namespaces are collected")

if err = r.collectNamespaces(ctx, instance); err != nil {
r.Log.Error(err, "Cannot collect Namespace resources")

return
return reconcile.Result{}, nil
}
// Ensuring Namespace metadata
r.Log.Info("Starting processing of Namespaces", "items", len(instance.Status.Namespaces))

if err = r.syncNamespaces(ctx, instance); err != nil {
r.Log.Error(err, "Cannot sync Namespace items")

return
return reconcile.Result{}, nil
}
// Ensuring NetworkPolicy resources
r.Log.Info("Starting processing of Network Policies")

if err = r.syncNetworkPolicies(ctx, instance); err != nil {
r.Log.Error(err, "Cannot sync NetworkPolicy items")

return
return reconcile.Result{}, nil
}
// Ensuring LimitRange resources
r.Log.Info("Starting processing of Limit Ranges", "items", len(instance.Spec.LimitRanges.Items))

if err = r.syncLimitRanges(ctx, instance); err != nil {
r.Log.Error(err, "Cannot sync LimitRange items")

return
return reconcile.Result{}, nil
}
// Ensuring ResourceQuota resources
r.Log.Info("Starting processing of Resource Quotas", "items", len(instance.Spec.ResourceQuota.Items))

if err = r.syncResourceQuotas(ctx, instance); err != nil {
r.Log.Error(err, "Cannot sync ResourceQuota items")

return
return reconcile.Result{}, nil
}
// Ensuring RoleBinding resources
r.Log.Info("Ensuring RoleBindings for Owners and Tenant")

if err = r.syncRoleBindings(ctx, instance); err != nil {
r.Log.Error(err, "Cannot sync RoleBindings items")

return
return reconcile.Result{}, nil
}
// Ensuring Namespace count
r.Log.Info("Ensuring Namespace count")

if err = r.ensureNamespaceCount(ctx, instance); err != nil {
r.Log.Error(err, "Cannot sync Namespace count")

return
return reconcile.Result{}, nil
}

r.Log.Info("Tenant reconciling completed")
Expand Down
14 changes: 9 additions & 5 deletions controllers/tenant/namespaces.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright 2020-2023 Project Capsule Authors.
// SPDX-License-Identifier: Apache-2.0

//
//gofumpt:diagnose
package tenant

import (
Expand Down Expand Up @@ -48,8 +49,8 @@ func (r *Manager) syncNamespaceMetadata(ctx context.Context, namespace string, t

err = retry.RetryOnConflict(retry.DefaultBackoff, func() (conflictErr error) {
ns := &corev1.Namespace{}
if conflictErr = r.Client.Get(ctx, types.NamespacedName{Name: namespace}, ns); err != nil {
return
if conflictErr = r.Client.Get(ctx, types.NamespacedName{Name: namespace}, ns); conflictErr != nil {
return conflictErr
}

capsuleLabel, _ := utils.GetTypeLabel(&capsulev1beta2.Tenant{})
Expand Down Expand Up @@ -81,6 +82,7 @@ func (r *Manager) syncNamespaceMetadata(ctx context.Context, namespace string, t
if len(tnt.Spec.IngressOptions.AllowedClasses.Exact) > 0 {
annotations[AvailableIngressClassesAnnotation] = strings.Join(tnt.Spec.IngressOptions.AllowedClasses.Exact, ",")
}

if len(tnt.Spec.IngressOptions.AllowedClasses.Regex) > 0 {
annotations[AvailableIngressClassesRegexpAnnotation] = tnt.Spec.IngressOptions.AllowedClasses.Regex
}
Expand All @@ -90,6 +92,7 @@ func (r *Manager) syncNamespaceMetadata(ctx context.Context, namespace string, t
if len(tnt.Spec.StorageClasses.Exact) > 0 {
annotations[AvailableStorageClassesAnnotation] = strings.Join(tnt.Spec.StorageClasses.Exact, ",")
}

if len(tnt.Spec.StorageClasses.Regex) > 0 {
annotations[AvailableStorageClassesRegexpAnnotation] = tnt.Spec.StorageClasses.Regex
}
Expand All @@ -99,6 +102,7 @@ func (r *Manager) syncNamespaceMetadata(ctx context.Context, namespace string, t
if len(tnt.Spec.ContainerRegistries.Exact) > 0 {
annotations[AllowedRegistriesAnnotation] = strings.Join(tnt.Spec.ContainerRegistries.Exact, ",")
}

if len(tnt.Spec.ContainerRegistries.Regex) > 0 {
annotations[AllowedRegistriesRegexpAnnotation] = tnt.Spec.ContainerRegistries.Regex
}
Expand Down Expand Up @@ -139,7 +143,7 @@ func (r *Manager) syncNamespaceMetadata(ctx context.Context, namespace string, t
return nil
})

return
return conflictErr
})

r.emitEvent(tnt, namespace, res, "Ensuring Namespace metadata", err)
Expand Down Expand Up @@ -170,7 +174,7 @@ func (r *Manager) collectNamespaces(ctx context.Context, tenant *capsulev1beta2.
})

if err != nil {
return
return err
}

_, err = controllerutil.CreateOrUpdate(ctx, r.Client, tenant.DeepCopy(), func() error {
Expand Down
2 changes: 1 addition & 1 deletion controllers/tenant/networkpolicies.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ func (r *Manager) syncNetworkPolicy(ctx context.Context, tenant *capsulev1beta2.
return controllerutil.SetControllerReference(tenant, target, r.Client.Scheme())
})

r.emitEvent(tenant, target.GetNamespace(), res, fmt.Sprintf("Ensuring NetworkPolicy %s", target.GetName()), err)
r.emitEvent(tenant, target.GetNamespace(), res, ("Ensuring NetworkPolicy " + target.GetName()), err)

r.Log.Info("Network Policy sync result: "+string(res), "name", target.Name, "namespace", target.Namespace)

Expand Down
Loading
Loading