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

chore(deps): update deps #521

Merged
merged 5 commits into from
Sep 13, 2023
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
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version: "1.19"
go-version: "1.21"
- run: make unit-tests

integration_tests:
Expand All @@ -26,7 +26,7 @@ jobs:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version: "1.19"
go-version: "1.21"
- run: make integration-tests

golangci:
Expand All @@ -36,11 +36,11 @@ jobs:
- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
- uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version: "1.19"
go-version: "1.21"
- name: golangci-lint
uses: golangci/golangci-lint-action@3a919529898de77ec3da873e3063ca4b10e7f5cc # v3.7.0
with:
version: v1.49.0
version: v1.54.2

shellcheck:
name: Shellcheck
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
- name: Install Golang
uses: actions/setup-go@93397bea11091df50f3d7e59dc26a7711a8bcfbe # v4.1.0
with:
go-version: "1.19"
go-version: "1.21"

- name: Checkout code
uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4.0.0
Expand Down
29 changes: 29 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,32 @@ linters-settings:
max-complexity: 13
nestif:
min-complexity: 8
depguard:
# Rules to apply.
#
# Variables:
# - File Variables
# you can still use and exclamation mark ! in front of a variable to say not to use it.
# Example !$test will match any file that is not a go test file.
#
# `$all` - matches all go files
# `$test` - matches all go test files
#
# - Package Variables
#
# `$gostd` - matches all of go's standard library (Pulled from `GOROOT`)
#
# Default: Only allow $gostd in all files.
rules:
# Name of a rule.
main:
# List of file globs that will match this list of settings to compare against.
# Default: $all
files:
- $all
- "!$test"
deny:
- pkg: "github.com/sirupsen/logrus"
desc: not allowed
- pkg: "github.com/pkg/errors"
desc: Should be replaced by standard lib errors package
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Build the manager binary
FROM golang:1.19 as builder
FROM golang:1.21 as builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ SETUP_ENVTEST_VER := v0.0.0-20211110210527-619e6b92dab9
SETUP_ENVTEST_BIN := setup-envtest
SETUP_ENVTEST := $(abspath $(BIN_DIR)/$(SETUP_ENVTEST_BIN))

GOLANGCI_LINT_VER := v1.52.2
GOLANGCI_LINT_VER := v1.54.2
GOLANGCI_LINT_BIN := golangci-lint
GOLANGCI_LINT := $(BIN_DIR)/$(GOLANGCI_LINT_BIN)

Expand Down Expand Up @@ -111,7 +111,7 @@ unit-tests: manifests generate fmt vet setup-envtest ## Run unit tests.

.PHONY: setup-envtest integration-tests
integration-tests: manifests generate fmt vet setup-envtest ## Run integration tests.
ACK_GINKGO_DEPRECATIONS=2.9.2 KUBEBUILDER_ASSETS="$(KUBEBUILDER_ASSETS)" go test ./pkg/... ./controllers/... -ginkgo.v -ginkgo.progress -test.v -coverprofile cover.out
ACK_GINKGO_DEPRECATIONS=2.12.0 KUBEBUILDER_ASSETS="$(KUBEBUILDER_ASSETS)" go test ./pkg/... ./controllers/... -ginkgo.v -ginkgo.progress -test.v -coverprofile cover.out

.PHONY: generate-crds
generate-crds: $(KUSTOMIZE) manifests kustomize ## generate final crds with kustomize. Normally shipped in Helm charts.
Expand Down
7 changes: 5 additions & 2 deletions controllers/admissionpolicy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ package controllers

import (
"context"
"errors"
"fmt"

"github.com/go-logr/logr"
"github.com/kubewarden/kubewarden-controller/internal/pkg/admission"
"github.com/kubewarden/kubewarden-controller/internal/pkg/constants"
"github.com/kubewarden/kubewarden-controller/internal/pkg/naming"
policiesv1 "github.com/kubewarden/kubewarden-controller/pkg/apis/policies/v1"
"github.com/pkg/errors"
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -91,7 +91,10 @@ func (r *AdmissionPolicyReconciler) SetupWithManager(mgr ctrl.Manager) error {
).
Complete(r)

return errors.Wrap(err, "failed enrolling controller with manager")
if err != nil {
return errors.Join(errors.New("failed enrolling controller with manager"), err)
}
return nil
}

func (r *AdmissionPolicyReconciler) findAdmissionPoliciesForConfigMap(object client.Object) []reconcile.Request {
Expand Down
7 changes: 5 additions & 2 deletions controllers/clusteradmissionpolicy_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ package controllers

import (
"context"
"errors"
"fmt"

"github.com/go-logr/logr"
"github.com/kubewarden/kubewarden-controller/internal/pkg/admission"
"github.com/kubewarden/kubewarden-controller/internal/pkg/constants"
"github.com/kubewarden/kubewarden-controller/internal/pkg/naming"
policiesv1 "github.com/kubewarden/kubewarden-controller/pkg/apis/policies/v1"
"github.com/pkg/errors"
corev1 "k8s.io/api/core/v1"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -91,7 +91,10 @@ func (r *ClusterAdmissionPolicyReconciler) SetupWithManager(mgr ctrl.Manager) er
).
Complete(r)

return errors.Wrap(err, "failed enrolling controller with manager")
if err != nil {
return errors.Join(errors.New("failed enrolling controller with manager"), err)
}
return nil
}

func (r *ClusterAdmissionPolicyReconciler) findClusterAdmissionPoliciesForConfigMap(object client.Object) []reconcile.Request {
Expand Down
16 changes: 8 additions & 8 deletions controllers/policy_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package controllers

import (
"context"
"errors"
"fmt"
"time"

Expand All @@ -26,7 +27,6 @@ import (
"github.com/kubewarden/kubewarden-controller/internal/pkg/metrics"
"github.com/kubewarden/kubewarden-controller/internal/pkg/naming"
policiesv1 "github.com/kubewarden/kubewarden-controller/pkg/apis/policies/v1"
"github.com/pkg/errors"
admissionregistrationv1 "k8s.io/api/admissionregistration/v1"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
Expand All @@ -42,12 +42,12 @@ import (
func setPolicyStatus(ctx context.Context, deploymentsNamespace string, apiReader client.Reader, policy policiesv1.Policy) error {
policyServerDeployment := appsv1.Deployment{}
if err := apiReader.Get(ctx, types.NamespacedName{Namespace: deploymentsNamespace, Name: naming.PolicyServerDeploymentNameForPolicyServerName(policy.GetPolicyServer())}, &policyServerDeployment); err != nil {
return errors.Wrap(err, "could not get policy server deployment")
return errors.Join(errors.New("could not get policy server deployment"), err)
}

policyServerConfigMap := corev1.ConfigMap{}
if err := apiReader.Get(ctx, types.NamespacedName{Namespace: deploymentsNamespace, Name: naming.PolicyServerDeploymentNameForPolicyServerName(policy.GetPolicyServer())}, &policyServerConfigMap); err != nil {
return errors.Wrap(err, "could not get configmap")
return errors.Join(errors.New("could not get configmap"), err)
}

policyMap, err := getPolicyMapFromConfigMap(&policyServerConfigMap)
Expand Down Expand Up @@ -117,7 +117,7 @@ func reconcilePolicy(ctx context.Context, client client.Client, reconciler admis
if apierrors.IsNotFound(err) {
return ctrl.Result{Requeue: true}, nil
}
return ctrl.Result{}, errors.Wrap(err, "could not read policy server Deployment")
return ctrl.Result{}, errors.Join(errors.New("could not read policy server Deployment"), err)
}

if !isPolicyUniquelyReachable(ctx, client, &policyServerDeployment, policy.GetUniqueName()) {
Expand Down Expand Up @@ -145,16 +145,16 @@ func reconcilePolicy(ctx context.Context, client client.Client, reconciler admis

secret := corev1.Secret{}
if err := client.Get(ctx, types.NamespacedName{Namespace: reconciler.DeploymentsNamespace, Name: constants.PolicyServerCARootSecretName}, &secret); err != nil {
return ctrl.Result{}, errors.Wrap(err, "cannot find policy server secret")
return ctrl.Result{}, errors.Join(errors.New("cannot find policy server secret"), err)
}

if policy.IsMutating() {
if err := reconciler.ReconcileMutatingWebhookConfiguration(ctx, policy, &secret, policyServer.NameWithPrefix()); err != nil {
return ctrl.Result{}, errors.Wrap(err, "error reconciling mutating webhook")
return ctrl.Result{}, errors.Join(errors.New("error reconciling mutating webhook"), err)
}
} else {
if err := reconciler.ReconcileValidatingWebhookConfiguration(ctx, policy, &secret, policyServer.NameWithPrefix()); err != nil {
return ctrl.Result{}, errors.Wrap(err, "error reconciling validating webhook")
return ctrl.Result{}, errors.Join(errors.New("error reconciling validating webhook"), err)
}
}
setPolicyAsActive(policy)
Expand All @@ -178,7 +178,7 @@ func setPolicyAsActive(policy policiesv1.Policy) {
func getPolicyServer(ctx context.Context, client client.Client, policy policiesv1.Policy) (*policiesv1.PolicyServer, error) {
policyServer := policiesv1.PolicyServer{}
if err := client.Get(ctx, types.NamespacedName{Name: policy.GetPolicyServer()}, &policyServer); err != nil {
return nil, errors.Wrap(err, "could not get policy server")
return nil, errors.Join(errors.New("could not get policy server"), err)
}
return &policyServer, nil
}
Expand Down
11 changes: 7 additions & 4 deletions controllers/policyserver_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ package controllers

import (
"context"
"errors"
"fmt"
"time"

"github.com/go-logr/logr"
"github.com/kubewarden/kubewarden-controller/internal/pkg/admission"
"github.com/kubewarden/kubewarden-controller/internal/pkg/constants"
policiesv1 "github.com/kubewarden/kubewarden-controller/pkg/apis/policies/v1"
"github.com/pkg/errors"
apierrors "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/runtime"
ctrl "sigs.k8s.io/controller-runtime"
Expand Down Expand Up @@ -70,7 +70,7 @@ func (r *PolicyServerReconciler) Reconcile(ctx context.Context, req ctrl.Request

policies, err := r.Reconciler.GetPolicies(ctx, &policyServer, admission.SkipDeleted)
if err != nil {
return ctrl.Result{}, errors.Wrap(err, "could not get policies")
return ctrl.Result{}, errors.Join(errors.New("could not get policies"), err)
}

if policyServer.ObjectMeta.DeletionTimestamp != nil {
Expand Down Expand Up @@ -112,7 +112,7 @@ func (r *PolicyServerReconciler) reconcileDeletion(ctx context.Context, policySe
}
if len(policies) == 0 {
if err := r.Reconciler.ReconcileDeletion(ctx, policyServer); err != nil {
return ctrl.Result{}, errors.Wrap(err, "could not reconcile policy server deletion")
return ctrl.Result{}, errors.Join(errors.New("could not reconcile policy server deletion"), err)
}
controllerutil.RemoveFinalizer(policyServer, constants.KubewardenFinalizer)
if err := r.Update(ctx, policyServer); err != nil {
Expand Down Expand Up @@ -193,5 +193,8 @@ func (r *PolicyServerReconciler) SetupWithManager(mgr ctrl.Manager) error {
})).
Complete(r)

return errors.Wrap(err, "failed enrolling controller with manager")
if err != nil {
return errors.Join(errors.New("failed enrolling controller with manager"), err)
}
return nil
}
4 changes: 2 additions & 2 deletions controllers/policystatus_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ package controllers
import (
"context"
"encoding/json"
"errors"
"fmt"

"github.com/kubewarden/kubewarden-controller/internal/pkg/admission"
"github.com/kubewarden/kubewarden-controller/internal/pkg/constants"
policiesv1 "github.com/kubewarden/kubewarden-controller/pkg/apis/policies/v1"
"github.com/pkg/errors"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
apimeta "k8s.io/apimachinery/pkg/api/meta"
Expand All @@ -36,7 +36,7 @@ func getPolicyMapFromConfigMap(configMap *corev1.ConfigMap) (admission.PolicyCon
policyMap := admission.PolicyConfigEntryMap{}
if policies, ok := configMap.Data[constants.PolicyServerConfigPoliciesEntry]; ok {
if err := json.Unmarshal([]byte(policies), &policyMap); err != nil {
return policyMap, errors.Wrap(err, "failed to unmarshal policy mapping")
return policyMap, errors.Join(errors.New("failed to unmarshal policy mapping"), err)
}
} else {
return policyMap, nil
Expand Down
9 changes: 5 additions & 4 deletions controllers/utils_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ limitations under the License.
package controllers

import (
"errors"

policiesv1 "github.com/kubewarden/kubewarden-controller/pkg/apis/policies/v1"
"github.com/onsi/gomega/types"
"github.com/pkg/errors"

. "github.com/onsi/gomega"

Expand Down Expand Up @@ -104,7 +105,7 @@ func admissionPolicyWithPolicyServerName(name, policyServerName string) *policie
func getFreshAdmissionPolicy(namespace, name string) (*policiesv1.AdmissionPolicy, error) {
newAdmissionPolicy := policiesv1.AdmissionPolicy{}
if err := reconciler.APIReader.Get(ctx, client.ObjectKey{Namespace: namespace, Name: name}, &newAdmissionPolicy); err != nil {
return nil, errors.Wrap(err, "could not find admission policy")
return nil, errors.Join(errors.New("could not find admission policy"), err)
}
return &newAdmissionPolicy, nil
}
Expand All @@ -123,15 +124,15 @@ func clusterAdmissionPolicyWithPolicyServerName(name, policyServerName string) *
func getFreshClusterAdmissionPolicy(name string) (*policiesv1.ClusterAdmissionPolicy, error) {
newClusterAdmissionPolicy := policiesv1.ClusterAdmissionPolicy{}
if err := reconciler.APIReader.Get(ctx, client.ObjectKey{Name: name}, &newClusterAdmissionPolicy); err != nil {
return nil, errors.Wrap(err, "could not find cluster admission policy")
return nil, errors.Join(errors.New("could not find cluster admission policy"), err)
}
return &newClusterAdmissionPolicy, nil
}

func getFreshPolicyServer(name string) (*policiesv1.PolicyServer, error) {
newPolicyServer := policiesv1.PolicyServer{}
if err := reconciler.APIReader.Get(ctx, client.ObjectKey{Name: name}, &newPolicyServer); err != nil {
return nil, errors.Wrap(err, "could not find policy server")
return nil, errors.Join(errors.New("could not find policy server"), err)
}
return &newPolicyServer, nil
}
18 changes: 9 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
module github.com/kubewarden/kubewarden-controller

go 1.20
go 1.21

require (
github.com/ereslibre/kube-webhook-wrapper v0.0.2
github.com/go-logr/logr v1.2.4
github.com/google/go-cmp v0.5.9
github.com/onsi/ginkgo/v2 v2.9.2
github.com/onsi/gomega v1.27.4
github.com/pkg/errors v0.9.1
github.com/onsi/ginkgo/v2 v2.12.0
github.com/onsi/gomega v1.27.10
go.opentelemetry.io/otel v1.14.0
go.opentelemetry.io/otel/exporters/otlp/otlpmetric/otlpmetricgrpc v0.37.0
go.opentelemetry.io/otel/metric v0.37.0
Expand Down Expand Up @@ -51,6 +50,7 @@ require (
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/prometheus/client_golang v1.14.0 // indirect
github.com/prometheus/client_model v0.3.0 // indirect
github.com/prometheus/common v0.37.0 // indirect
Expand All @@ -64,13 +64,13 @@ require (
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/net v0.9.0 // indirect
golang.org/x/net v0.14.0 // indirect
golang.org/x/oauth2 v0.5.0 // indirect
golang.org/x/sys v0.7.0 // indirect
golang.org/x/term v0.7.0 // indirect
golang.org/x/text v0.9.0 // indirect
golang.org/x/sys v0.11.0 // indirect
golang.org/x/term v0.11.0 // indirect
golang.org/x/text v0.12.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/tools v0.7.0 // indirect
golang.org/x/tools v0.12.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.2.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect
Expand Down
Loading
Loading