From 50e905591b7d9227e17d8c0122be685636ec989a Mon Sep 17 00:00:00 2001 From: Patrice Ferlet Date: Fri, 10 Jun 2022 15:29:00 +0200 Subject: [PATCH] Fix index and suffix of cronjob names --- generator/crontabs.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/generator/crontabs.go b/generator/crontabs.go index 92b7707..efacb79 100644 --- a/generator/crontabs.go +++ b/generator/crontabs.go @@ -62,7 +62,8 @@ func buildCrontab(deployName string, deployment *helm.Deployment, s *types.Servi fileGeneratorChan <- role fileGeneratorChan <- roleBinding - index := len(crons) - 1 // will be 0 when there is only one cron - made to name crons + numcron := len(crons) - 1 + index := 1 // create crontabs for _, cron := range crons { @@ -84,14 +85,13 @@ func buildCrontab(deployName string, deployment *helm.Deployment, s *types.Servi } name := deployName - if index > 0 { + if numcron > 0 { name = fmt.Sprintf("%s-%d", deployName, index) - index++ } // add crontab suffix := "" - if index > 0 { + if numcron > 0 { suffix = fmt.Sprintf("%d", index) } cronTab := helm.NewCrontab( @@ -103,6 +103,7 @@ func buildCrontab(deployName string, deployment *helm.Deployment, s *types.Servi ) logger.Magenta(ICON_CRON, "Generating crontab", deployName, suffix) fileGeneratorChan <- cronTab + index++ } return