Skip to content

Commit

Permalink
fix linter
Browse files Browse the repository at this point in the history
  • Loading branch information
m00g3n committed Dec 20, 2023
1 parent c10b2f5 commit 5a544b6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
9 changes: 4 additions & 5 deletions internal/controller/find_last_sync_time.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@ import (
"time"
)

// TODO replace order
func findLastSyncTime(annotations map[string]string) (bool, time.Time) {
func findLastSyncTime(annotations map[string]string) (time.Time, bool) {
_, found := annotations[lastKubeconfigSyncAnnotation]
if !found {
return false, time.Time{}
return time.Time{}, false
}

lastSyncTimeString := annotations[lastKubeconfigSyncAnnotation]
lastSyncTime, err := time.Parse(time.RFC3339, lastSyncTimeString)
if err != nil {
return false, time.Time{}
return time.Time{}, false
}
return true, lastSyncTime
return lastSyncTime, true
}
2 changes: 1 addition & 1 deletion internal/controller/find_last_sync_time_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ var _ = Describe("findLastSyncTime", func() {

DescribeTable("should return expected values when",
func(annotations map[string]string, expectedFound bool, expectedTime time.Time) {
found, lastSyncTime := findLastSyncTime(annotations)
lastSyncTime, found := findLastSyncTime(annotations)
Expect(found).To(Equal(expectedFound))
Expect(lastSyncTime).To(Equal(expectedTime))
},
Expand Down
4 changes: 2 additions & 2 deletions internal/controller/gardener_cluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ func (controller *GardenerClusterController) Reconcile(ctx context.Context, req
annotations = secret.Annotations
}

_, lastSyncTime := findLastSyncTime(annotations)
lastSyncTime, _ := findLastSyncTime(annotations)
now := time.Now().UTC()
requeueAfter := nextRequeue(now, lastSyncTime, controller.rotationPeriod, rotationPeriodRatio)

Expand Down Expand Up @@ -283,7 +283,7 @@ func secretRotationTimePassed(secret *corev1.Secret, rotationPeriod time.Duratio
}

annotations := secret.GetAnnotations()
found, lastSyncTime := findLastSyncTime(annotations)
lastSyncTime, found := findLastSyncTime(annotations)
if !found {
return true
}
Expand Down

0 comments on commit 5a544b6

Please sign in to comment.