Skip to content

Commit

Permalink
Use equality pkg instead of reflect pkg for the DeepEqual function (#…
Browse files Browse the repository at this point in the history
…1363)

Signed-off-by: Yuki Iwai <[email protected]>
  • Loading branch information
tenzen-y authored Nov 24, 2023
1 parent 1ecd79f commit 44ad0d5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
"bytes"
"fmt"
"os"
"reflect"

"k8s.io/apimachinery/pkg/api/equality"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/serializer"
Expand Down Expand Up @@ -116,15 +116,15 @@ func addLeaderElectionTo(o *ctrl.Options, cfg *configapi.Configuration) {
o.LeaderElectionID = cfg.LeaderElection.ResourceName
}

if o.LeaseDuration == nil && !reflect.DeepEqual(cfg.LeaderElection.LeaseDuration, metav1.Duration{}) {
if o.LeaseDuration == nil && !equality.Semantic.DeepEqual(cfg.LeaderElection.LeaseDuration, metav1.Duration{}) {
o.LeaseDuration = &cfg.LeaderElection.LeaseDuration.Duration
}

if o.RenewDeadline == nil && !reflect.DeepEqual(cfg.LeaderElection.RenewDeadline, metav1.Duration{}) {
if o.RenewDeadline == nil && !equality.Semantic.DeepEqual(cfg.LeaderElection.RenewDeadline, metav1.Duration{}) {
o.RenewDeadline = &cfg.LeaderElection.RenewDeadline.Duration
}

if o.RetryPeriod == nil && !reflect.DeepEqual(cfg.LeaderElection.RetryPeriod, metav1.Duration{}) {
if o.RetryPeriod == nil && !equality.Semantic.DeepEqual(cfg.LeaderElection.RetryPeriod, metav1.Duration{}) {
o.RetryPeriod = &cfg.LeaderElection.RetryPeriod.Duration
}
}
Expand Down

0 comments on commit 44ad0d5

Please sign in to comment.