From cb65e5dcd2b20a9e6dcaccfa8b0d6502a6e629b4 Mon Sep 17 00:00:00 2001 From: Alan Date: Fri, 26 Apr 2024 12:49:13 +0200 Subject: [PATCH] fix(datastore): oldest run update panic --- internal/controllers/terraformlayer/controller.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/controllers/terraformlayer/controller.go b/internal/controllers/terraformlayer/controller.go index 3a9c886e..86ecf82c 100644 --- a/internal/controllers/terraformlayer/controller.go +++ b/internal/controllers/terraformlayer/controller.go @@ -26,6 +26,7 @@ import ( "github.com/padok-team/burrito/internal/lock" corev1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/api/errors" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/types" "k8s.io/client-go/tools/record" @@ -145,7 +146,9 @@ func getRun(run configv1alpha1.TerraformRun) configv1alpha1.TerraformLayerRun { } func updateLatestRuns(runs []configv1alpha1.TerraformLayerRun, run configv1alpha1.TerraformRun) []configv1alpha1.TerraformLayerRun { - var oldestRun *configv1alpha1.TerraformLayerRun + oldestRun := &configv1alpha1.TerraformLayerRun{ + Date: metav1.NewTime(time.Now()), + } var oldestRunIndex int newRun := getRun(run) for i, r := range runs {