From 5a544b67b7c0bc7ad7bee4fc8282a27c8d748c35 Mon Sep 17 00:00:00 2001 From: m00g3n Date: Wed, 20 Dec 2023 10:58:02 +0100 Subject: [PATCH] fix linter --- internal/controller/find_last_sync_time.go | 9 ++++----- internal/controller/find_last_sync_time_test.go | 2 +- internal/controller/gardener_cluster_controller.go | 4 ++-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/internal/controller/find_last_sync_time.go b/internal/controller/find_last_sync_time.go index cc199ea4..3f03f500 100644 --- a/internal/controller/find_last_sync_time.go +++ b/internal/controller/find_last_sync_time.go @@ -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 } diff --git a/internal/controller/find_last_sync_time_test.go b/internal/controller/find_last_sync_time_test.go index 7fa1d1b4..60c7af33 100644 --- a/internal/controller/find_last_sync_time_test.go +++ b/internal/controller/find_last_sync_time_test.go @@ -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)) }, diff --git a/internal/controller/gardener_cluster_controller.go b/internal/controller/gardener_cluster_controller.go index f670a514..6bd8c859 100644 --- a/internal/controller/gardener_cluster_controller.go +++ b/internal/controller/gardener_cluster_controller.go @@ -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) @@ -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 }