From 47b5ccd5f23287c86eb0a5c151395a58ef60d3e4 Mon Sep 17 00:00:00 2001 From: Tarun Khandelwal Date: Fri, 8 Oct 2021 16:30:00 +0530 Subject: [PATCH 1/2] fix: serve mode --- cmd/serve.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/cmd/serve.go b/cmd/serve.go index cb89b2797..6a4f30984 100644 --- a/cmd/serve.go +++ b/cmd/serve.go @@ -46,8 +46,12 @@ var Serve = &cobra.Command{ cron.Start() for _, canary := range configs { - if canary.Spec.Interval == 0 && canary.Spec.Schedule == "" { - canary.Spec.Schedule = schedule + if schedule == "" { + if canary.Spec.Schedule != "" { + schedule = canary.Spec.Schedule + } else if canary.Spec.Interval > 0 { + schedule = fmt.Sprintf("@every %ds", canary.Spec.Interval) + } } for _, _c := range checks.All { @@ -55,8 +59,6 @@ var Serve = &cobra.Command{ if !checks.Checks(canary.Spec.GetAllChecks()).Includes(c) { continue } - schedule := canary.Spec.Schedule - cron.AddFunc(schedule, func() { // nolint: errcheck go func() { for _, result := range checks.RunChecks(context.New(kommonsClient, canary)) { @@ -129,7 +131,6 @@ func simpleCors(f nethttp.HandlerFunc, allowedOrigin string) nethttp.HandlerFunc func init() { ServerFlags(Serve.Flags()) - Serve.Flags().StringP("configfile", "c", "", "Specify configfile") - Serve.MarkFlagRequired("configfile") // nolint: errcheck - Serve.Flags().StringP("schedule", "s", "", "schedule to run checks on. Supports all cron expression and golang duration support in format: '@every duration'") + Serve.Flags().StringVarP(&configFile, "configfile", "c", "", "Specify configfile") + Serve.Flags().StringVarP(&schedule, "schedule", "s", "", "schedule to run checks on. Supports all cron expression and golang duration support in format: '@every duration'") } From 8f911cea3eb4022b43ebba4c57dcd390b8a9cb8e Mon Sep 17 00:00:00 2001 From: Tarun Khandelwal Date: Fri, 8 Oct 2021 19:17:56 +0530 Subject: [PATCH 2/2] chore: fix restic fixture --- fixtures/datasources/_setup.sh | 2 ++ fixtures/datasources/restic_pass.yaml | 15 --------------- .../restic_without_integrity_pass.yaml | 18 +++++++++--------- 3 files changed, 11 insertions(+), 24 deletions(-) delete mode 100644 fixtures/datasources/restic_pass.yaml diff --git a/fixtures/datasources/_setup.sh b/fixtures/datasources/_setup.sh index 25094605c..6c1d6b3a0 100644 --- a/fixtures/datasources/_setup.sh +++ b/fixtures/datasources/_setup.sh @@ -8,3 +8,5 @@ restic version RESTIC_PASSWORD="S0m3p@sswd" AWS_ACCESS_KEY_ID="minio" AWS_SECRET_ACCESS_KEY="minio123" restic --cacert .certs/ingress-ca.crt -r s3:https://minio.${DOMAIN}/restic-canary-checker init || true #take some backup in restic RESTIC_PASSWORD="S0m3p@sswd" AWS_ACCESS_KEY_ID="minio" AWS_SECRET_ACCESS_KEY="minio123" restic --cacert .certs/ingress-ca.crt -r s3:https://minio.${DOMAIN}/restic-canary-checker backup "$(pwd)" +#Sleep for 5 seconds for restic to be ready +sleep 5 \ No newline at end of file diff --git a/fixtures/datasources/restic_pass.yaml b/fixtures/datasources/restic_pass.yaml deleted file mode 100644 index b20db0a9f..000000000 --- a/fixtures/datasources/restic_pass.yaml +++ /dev/null @@ -1,15 +0,0 @@ -apiVersion: canaries.flanksource.com/v1 -kind: Canary -metadata: - name: restic-pass -spec: - interval: 30 - restic: - - repository: s3:http://minio.minio:9000/restic-canary-checker - password: - value: S0m3p@sswd - maxAge: 1h - accessKey: - value: minio - secretKey: - value: minio123 \ No newline at end of file diff --git a/fixtures/datasources/restic_without_integrity_pass.yaml b/fixtures/datasources/restic_without_integrity_pass.yaml index 7c4779558..f00ddc6ce 100644 --- a/fixtures/datasources/restic_without_integrity_pass.yaml +++ b/fixtures/datasources/restic_without_integrity_pass.yaml @@ -4,12 +4,12 @@ metadata: name: restic-pass-withoutinegrity spec: interval: 30 -restic: - - repository: s3:http://minio.minio:9000/restic-canary-checker - password: - value: S0m3p@sswd - maxAge: 1h - accessKey: - value: minio - secretKey: - value: minio123 \ No newline at end of file + restic: + - repository: s3:http://minio.minio:9000/restic-canary-checker + password: + value: S0m3p@sswd + maxAge: 1h + accessKey: + value: minio + secretKey: + value: minio123 \ No newline at end of file