Skip to content
Open
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 pkg/controller/istiocsr/certificates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ func TestCreateOrApplyCertificates(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
r := testReconciler(t)
r := testReconciler()
mock := &fakes.FakeCtrlClient{}
if tt.preReq != nil {
tt.preReq(r, mock)
Expand Down
9 changes: 5 additions & 4 deletions pkg/controller/istiocsr/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,14 @@ import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/client-go/tools/record"

"github.com/go-logr/logr"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/handler"
"sigs.k8s.io/controller-runtime/pkg/predicate"
"sigs.k8s.io/controller-runtime/pkg/reconcile"

"github.com/go-logr/logr"

certmanagerv1 "github.com/cert-manager/cert-manager/pkg/apis/certmanager/v1"

v1alpha1 "github.com/openshift/cert-manager-operator/api/operator/v1alpha1"
Expand Down Expand Up @@ -90,7 +88,10 @@ func (r *Reconciler) SetupWithManager(mgr ctrl.Manager) error {
}
key := strings.Split(value, "_")
if len(key) != 2 {
r.log.Error(fmt.Errorf("invalid label format"), "%s label value(%s) not in expected format on %s resource", IstiocsrResourceWatchLabelName, value, obj.GetName())
r.log.V(2).Info("label value not in expected format",
"labelName", IstiocsrResourceWatchLabelName,
"labelValue", value,
"resource", obj.GetName())
return false
}
namespace = key[0]
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/istiocsr/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ func TestReconcile(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
r := testReconciler(t)
r := testReconciler()
mock := &fakes.FakeCtrlClient{}
if tt.preReq != nil {
tt.preReq(r, mock)
Expand Down Expand Up @@ -752,7 +752,7 @@ func TestProcessReconcileRequest(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
r := testReconciler(t)
r := testReconciler()
mock := &fakes.FakeCtrlClient{}
if tt.preReq != nil {
tt.preReq(r, mock)
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/istiocsr/deployments_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1069,7 +1069,7 @@ func TestCreateOrApplyDeployments(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
r := testReconciler(t)
r := testReconciler()
mock := &fakes.FakeCtrlClient{}
if tt.preReq != nil {
tt.preReq(r, mock)
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/istiocsr/install_instiocsr_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func TestReconcileIstioCSRDeployment(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
r := testReconciler(t)
r := testReconciler()
mock := &fakes.FakeCtrlClient{}
if tt.preReq != nil {
tt.preReq(r, mock)
Expand Down
1 change: 0 additions & 1 deletion pkg/controller/istiocsr/networkpolicies.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
networkingv1 "k8s.io/api/networking/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"

"github.com/openshift/cert-manager-operator/api/operator/v1alpha1"
"github.com/openshift/cert-manager-operator/pkg/controller/common"
"github.com/openshift/cert-manager-operator/pkg/operator/assets"
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/istiocsr/rbacs.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ func (r *Reconciler) updateClusterRoleNameInStatus(istiocsr *v1alpha1.IstioCSR,
if existing != nil && existing.GetName() != "" {
name = existing.GetName()
} else {
r.log.Error(fmt.Errorf("error updating clusterrole name in status"), "istiocsr", istiocsr.GetNamespace())
r.log.V(1).Info("unable to determine clusterrole name for status update", "istiocsr", istiocsr.GetNamespace())
}
}
istiocsr.Status.ClusterRole = name
Expand Down Expand Up @@ -261,7 +261,7 @@ func (r *Reconciler) updateClusterRoleBindingNameInStatus(istiocsr *v1alpha1.Ist
if existing != nil && existing.GetName() != "" {
name = existing.GetName()
} else {
r.log.Error(fmt.Errorf("error updating clusterrolebinding name in status"), "istiocsr", istiocsr.GetNamespace())
r.log.V(1).Info("unable to determine clusterrolebinding name for status update", "istiocsr", istiocsr.GetNamespace())
}
}
istiocsr.Status.ClusterRoleBinding = name
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/istiocsr/rbacs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -683,7 +683,7 @@ func TestCreateOrApplyRBACResource(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
r := testReconciler(t)
r := testReconciler()
mock := &fakes.FakeCtrlClient{}
if tt.preReq != nil {
tt.preReq(r, mock)
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/istiocsr/serviceaccounts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ func TestCreateOrApplyServiceAccounts(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
r := testReconciler(t)
r := testReconciler()
mock := &fakes.FakeCtrlClient{}
if tt.preReq != nil {
tt.preReq(r, mock)
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/istiocsr/services_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func TestCreateOrApplyServices(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
r := testReconciler(t)
r := testReconciler()
mock := &fakes.FakeCtrlClient{}
if tt.preReq != nil {
tt.preReq(r, mock)
Expand Down
8 changes: 3 additions & 5 deletions pkg/controller/istiocsr/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,14 @@ import (
"encoding/pem"
"fmt"
"maps"
"testing"
"time"

appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
rbacv1 "k8s.io/api/rbac/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/tools/record"

"github.com/go-logr/logr/testr"
"k8s.io/klog/v2"

cmacme "github.com/cert-manager/cert-manager/pkg/apis/acme/v1"
certmanagerv1 "github.com/cert-manager/cert-manager/pkg/apis/certmanager/v1"
Expand All @@ -42,11 +40,11 @@ var (

type CertificateTweak func(*x509.Certificate)

func testReconciler(t *testing.T) *Reconciler {
func testReconciler() *Reconciler {
return &Reconciler{
ctx: context.Background(),
eventRecorder: record.NewFakeRecorder(100),
log: testr.New(t),
log: klog.NewKlogr().WithName(ControllerName),
scheme: testutil.Scheme,
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/istiocsr/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ func (r *Reconciler) disallowMultipleIstioCSRInstances(istiocsr *v1alpha1.IstioC
statusMessage := fmt.Sprintf("multiple instances of istiocsr exists, %s/%s will not be processed", istiocsr.GetNamespace(), istiocsr.GetName())

if containsProcessingRejectedAnnotation(istiocsr) {
r.log.V(4).Info("%s/%s istiocsr resource contains processing rejected annotation", istiocsr.Namespace, istiocsr.Name)
r.log.V(4).Info("istiocsr resource contains processing rejected annotation", "namespace", istiocsr.Namespace, "name", istiocsr.Name)
// ensure status is updated.
var updateErr error
if istiocsr.Status.SetCondition(v1alpha1.Ready, metav1.ConditionFalse, v1alpha1.ReasonFailed, statusMessage) {
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/trustmanager/certificates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ func TestIssuerReconciliation(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
r := testReconciler(t)
r := testReconciler()
mock := &fakes.FakeCtrlClient{}
if tt.preReq != nil {
tt.preReq(r, mock)
Expand Down Expand Up @@ -398,7 +398,7 @@ func TestCertificateReconciliation(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
r := testReconciler(t)
r := testReconciler()
mock := &fakes.FakeCtrlClient{}
if tt.preReq != nil {
tt.preReq(r, mock)
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/trustmanager/configmaps_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ func TestDefaultCAPackageConfigMapReconciliation(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
r := testReconciler(t)
r := testReconciler()
mock := &fakes.FakeCtrlClient{}
r.CtrlClient = mock

Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/trustmanager/controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func TestReconcile(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
r := testReconciler(t)
r := testReconciler()
mock := &fakes.FakeCtrlClient{}
if tt.preReq != nil {
tt.preReq(r, mock)
Expand Down Expand Up @@ -337,7 +337,7 @@ func TestProcessReconcileRequest(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
r := testReconciler(t)
r := testReconciler()
mock := &fakes.FakeCtrlClient{}
if tt.preReq != nil {
tt.preReq(r, mock)
Expand Down
14 changes: 7 additions & 7 deletions pkg/controller/trustmanager/deployments_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func TestDeploymentObject(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Setenv(trustManagerImageNameEnvVarName, testImage)
r := testReconciler(t)
r := testReconciler()
tm := tt.tm.Build()
dep, err := r.getDeploymentObject(tm, getResourceLabels(tm), getResourceAnnotations(tm), "")
if err != nil {
Expand Down Expand Up @@ -86,7 +86,7 @@ func TestDeploymentObject(t *testing.T) {

func TestDeploymentSpec(t *testing.T) {
t.Setenv(trustManagerImageNameEnvVarName, testImage)
r := testReconciler(t)
r := testReconciler()
tm := testTrustManager().Build()
dep, err := r.getDeploymentObject(tm, getResourceLabels(tm), getResourceAnnotations(tm), "")
if err != nil {
Expand Down Expand Up @@ -215,7 +215,7 @@ func TestDeploymentContainerArgs(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Setenv(trustManagerImageNameEnvVarName, testImage)
r := testReconciler(t)
r := testReconciler()

tmBuilder := tt.tmBuilder
if tmBuilder == nil {
Expand Down Expand Up @@ -247,7 +247,7 @@ func TestDeploymentDefaultCAPackage(t *testing.T) {
t.Setenv(trustManagerImageNameEnvVarName, testImage)

t.Run("adds arg, volume, mount, and hash annotation when enabled", func(t *testing.T) {
r := testReconciler(t)
r := testReconciler()
tm := testTrustManager().WithDefaultCAPackage(v1alpha1.DefaultCAPackagePolicyEnabled).Build()
dep, err := r.getDeploymentObject(tm, testResourceLabels(), testResourceAnnotations(), "abc123hash")
if err != nil {
Expand Down Expand Up @@ -294,7 +294,7 @@ func TestDeploymentDefaultCAPackage(t *testing.T) {
})

t.Run("no arg, volume, or annotation when disabled", func(t *testing.T) {
r := testReconciler(t)
r := testReconciler()
tm := testTrustManager().Build()
dep, err := r.getDeploymentObject(tm, testResourceLabels(), testResourceAnnotations(), "")
if err != nil {
Expand Down Expand Up @@ -384,7 +384,7 @@ func TestDeploymentOverrides(t *testing.T) {
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
t.Setenv(trustManagerImageNameEnvVarName, testImage)
r := testReconciler(t)
r := testReconciler()

tm := testTrustManager().Build()
tt.configure(tm)
Expand Down Expand Up @@ -690,7 +690,7 @@ func TestDeploymentReconciliation(t *testing.T) {
} else {
t.Setenv(trustManagerImageNameEnvVarName, "")
}
r := testReconciler(t)
r := testReconciler()
mock := &fakes.FakeCtrlClient{}
if tt.preReq != nil {
tt.preReq(r, mock)
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/trustmanager/install_trustmanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func TestUpdateStatusObservedState(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
r := testReconciler(t)
r := testReconciler()
mock := &fakes.FakeCtrlClient{}
tm := tt.trustManager()

Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/trustmanager/rbacs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ func TestRBACReconciliation(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
r := testReconciler(t)
r := testReconciler()
mock := &fakes.FakeCtrlClient{}
if tt.preReq != nil {
tt.preReq(r, mock)
Expand Down Expand Up @@ -775,7 +775,7 @@ func TestRBACReconciliationWithSecretTargets(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
r := testReconciler(t)
r := testReconciler()
mock := &fakes.FakeCtrlClient{}
tm := tt.tmBuilder.Build()
if tt.preReq != nil {
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/trustmanager/serviceaccounts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func TestServiceAccountObject(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
r := testReconciler(t)
r := testReconciler()
tm := tt.tm.Build()
sa := r.getServiceAccountObject(getResourceLabels(tm), getResourceAnnotations(tm))

Expand Down Expand Up @@ -171,7 +171,7 @@ func TestServiceAccountReconciliation(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
r := testReconciler(t)
r := testReconciler()
mock := &fakes.FakeCtrlClient{}
if tt.preReq != nil {
tt.preReq(r, mock)
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/trustmanager/services_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ func TestServiceReconciliation(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
r := testReconciler(t)
r := testReconciler()
mock := &fakes.FakeCtrlClient{}
if tt.preReq != nil {
tt.preReq(r, mock)
Expand Down
7 changes: 3 additions & 4 deletions pkg/controller/trustmanager/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/tools/record"

"github.com/go-logr/logr/testr"
"k8s.io/klog/v2"

"github.com/openshift/cert-manager-operator/api/operator/v1alpha1"
"github.com/openshift/cert-manager-operator/pkg/testutil"
Expand Down Expand Up @@ -106,11 +105,11 @@ func (b *trustManagerBuilder) Build() *v1alpha1.TrustManager {
return b.TrustManager
}

func testReconciler(t *testing.T) *Reconciler {
func testReconciler() *Reconciler {
return &Reconciler{
ctx: context.Background(),
eventRecorder: record.NewFakeRecorder(100),
log: testr.New(t),
log: klog.NewKlogr().WithName(ControllerName),
scheme: testutil.Scheme,
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/trustmanager/webhooks_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ func TestValidatingWebhookConfigReconciliation(t *testing.T) {

for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
r := testReconciler(t)
r := testReconciler()
mock := &fakes.FakeCtrlClient{}
if tt.preReq != nil {
tt.preReq(r, mock)
Expand Down