diff --git a/charts/registry-scanner/Chart.yaml b/charts/registry-scanner/Chart.yaml index 36d51b801..05a23afcc 100644 --- a/charts/registry-scanner/Chart.yaml +++ b/charts/registry-scanner/Chart.yaml @@ -4,7 +4,7 @@ description: Sysdig Registry Scanner type: application home: https://www.sysdig.com/ icon: https://avatars.githubusercontent.com/u/5068817?s=200&v=4 -version: 1.4.1 +version: 1.4.2 appVersion: 0.5.0 maintainers: - name: sysdiglabs diff --git a/charts/registry-scanner/templates/_helpers.tpl b/charts/registry-scanner/templates/_helpers.tpl index 65309d886..3c9062b6c 100644 --- a/charts/registry-scanner/templates/_helpers.tpl +++ b/charts/registry-scanner/templates/_helpers.tpl @@ -152,10 +152,11 @@ Check cronjob value {{- $month := index $parts 3 -}} {{- $dayOfWeek := index $parts 4 -}} - {{- if and (eq $dayOfMonth "*" ) (eq $dayOfWeek "*") (eq $month "*") -}}} - {{- printf "WARNING: You have configured the registry scanner to run on a schedule of '%s'. Running the scanner more often than every 24 hours can increase the load on your registry. The recommended configuration is to perform a scan weekly." $schedule | fail}} + {{- if and (eq $dayOfMonth "*" ) (eq $dayOfWeek "*") (eq $month "*") -}} + {{- if or ($hour | contains "*") ($hour | contains ",") ($hour | contains "-") ($hour | contains "/") -}} + # {{- printf "WARNING: You have configured the registry scanner to run on a schedule of '%s'. Running the scanner more often than every 24 hours can increase the load on your registry. The recommended configuration is to perform a scan weekly." $schedule | fail}} + {{- fail (printf "WARNING: You have configured the registry scanner to run on a schedule of '%s'. Running the scanner more often than every 24 hours can increase the load on your registry. The recommended configuration is to perform a scan weekly." $schedule) }} + {{- end -}} {{- end -}} - {{- else -}} - {{- print "Error: Wrong cronjob format." | quote }} {{- end -}} {{- end -}} diff --git a/charts/registry-scanner/tests/cronjob_test.yaml b/charts/registry-scanner/tests/cronjob_test.yaml index 7f74e94b5..e20c1f07b 100644 --- a/charts/registry-scanner/tests/cronjob_test.yaml +++ b/charts/registry-scanner/tests/cronjob_test.yaml @@ -126,10 +126,9 @@ tests: set: cronjob.schedule: "0 0 * * *" asserts: - - failedTemplate: - errorMessage: "WARNING: You have configured the registry scanner to run on a schedule of '0 0 * * *'. \ - Running the scanner more often than every 24 hours can increase the load on your registry. \ - The recommended configuration is to perform a scan weekly." + - equal: + path: spec.schedule + value: "0 0 * * *" - it: sets cronjob schedule less often than 24h set: @@ -138,3 +137,37 @@ tests: - equal: path: spec.schedule value: "0 0 1 * *" + + - it: sets cronjob schedule less often than 24h + set: + cronjob.schedule: "0 0 1 4 *" + asserts: + - equal: + path: spec.schedule + value: "0 0 1 4 *" + - it: sets cronjob schedule less often than 24h and slash + set: + cronjob.schedule: "0 1/2 * * *" + asserts: + - failedTemplate: + errorMessage: "WARNING: You have configured the registry scanner to run on a schedule of '0 1/2 * * *'. \ + Running the scanner more often than every 24 hours can increase the load on your registry. \ + The recommended configuration is to perform a scan weekly." + + - it: sets cronjob schedule less often than 24h and comma + set: + cronjob.schedule: "0 1,2 * * *" + asserts: + - failedTemplate: + errorMessage: "WARNING: You have configured the registry scanner to run on a schedule of '0 1,2 * * *'. \ + Running the scanner more often than every 24 hours can increase the load on your registry. \ + The recommended configuration is to perform a scan weekly." + + - it: sets cronjob schedule less often than 24h and dash + set: + cronjob.schedule: "0 1-2 * * *" + asserts: + - failedTemplate: + errorMessage: "WARNING: You have configured the registry scanner to run on a schedule of '0 1-2 * * *'. \ + Running the scanner more often than every 24 hours can increase the load on your registry. \ + The recommended configuration is to perform a scan weekly."