summaryrefslogtreecommitdiff
path: root/internal/run.go
blob: 9583a69e776894185241868b75fb38ef6780dc78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package internal

import "context"

func Run(ctx context.Context, configFile string, renotify bool) {
	config, err := newConfig(configFile)
	if err != nil {
		panic(err)
	}

	if err := config.sanityCheck(); err != nil {
		notifyError(config, err)
	}

	state, err := readState(config)
	if err != nil {
		notifyError(config, err)
	}

	state = runChecks(ctx, state, config)

	if err := state.persist(); err != nil {
		notifyError(config, err)
	}

	if subject, body, doNotify := state.report(renotify); doNotify {
		notify(config, subject, body)
	}
}