Skip to content

Commit

Permalink
Merge pull request #351 from flanksource/fix-serve
Browse files Browse the repository at this point in the history
fix: serve mode
  • Loading branch information
moshloop authored Oct 9, 2021
2 parents c480dd9 + 8f911ce commit e61e26b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 31 deletions.
15 changes: 8 additions & 7 deletions cmd/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,17 +46,19 @@ 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 {
c := _c
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)) {
Expand Down Expand Up @@ -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'")
}
2 changes: 2 additions & 0 deletions fixtures/datasources/_setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
15 changes: 0 additions & 15 deletions fixtures/datasources/restic_pass.yaml

This file was deleted.

18 changes: 9 additions & 9 deletions fixtures/datasources/restic_without_integrity_pass.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
restic:
- repository: s3:http://minio.minio:9000/restic-canary-checker
password:
value: S0m3p@sswd
maxAge: 1h
accessKey:
value: minio
secretKey:
value: minio123

0 comments on commit e61e26b

Please sign in to comment.