summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2023-04-20 23:37:06 +0300
committerPaul Buetow <paul@buetow.org>2023-04-20 23:37:06 +0300
commit7fa1d0c1e3fb7ceb23ba3d88a93905d68522c930 (patch)
tree9bbc3e525b9d74ca3a2e1f7b8e7cb77b83154b11 /internal
parent1770bba5519236198c5d1a597507e1cb79da16e5 (diff)
add renotify
Diffstat (limited to 'internal')
-rw-r--r--internal/run.go4
-rw-r--r--internal/state.go4
2 files changed, 4 insertions, 4 deletions
diff --git a/internal/run.go b/internal/run.go
index e647f7e..2fd1f7c 100644
--- a/internal/run.go
+++ b/internal/run.go
@@ -2,7 +2,7 @@ package internal
import "context"
-func Run(ctx context.Context, configFile string) {
+func Run(ctx context.Context, configFile string, renotify bool) {
config, err := newConfig(configFile)
if err != nil {
panic(err)
@@ -19,7 +19,7 @@ func Run(ctx context.Context, configFile string) {
notifyError(config, err)
}
- if subject, body, doNotify := state.report(); doNotify {
+ if subject, body, doNotify := state.report(renotify); doNotify {
notify(config, subject, body)
}
}
diff --git a/internal/state.go b/internal/state.go
index 0cba723..d318ca9 100644
--- a/internal/state.go
+++ b/internal/state.go
@@ -85,7 +85,7 @@ func (s state) persist() error {
return ioutil.WriteFile(s.stateFile, jsonData, os.ModePerm)
}
-func (s state) report() (string, string, bool) {
+func (s state) report(renotify bool) (string, string, bool) {
var sb strings.Builder
sb.WriteString("This is the recent Gogios report!\n\n")
@@ -101,7 +101,7 @@ func (s state) report() (string, string, bool) {
subject := fmt.Sprintf("GOGIOS Report [C:%d W:%d U:%d OK:%d]",
numCriticals, numWarnings, numUnknown, numOK)
- return subject, sb.String(), changed || numCriticals > 0
+ return subject, sb.String(), changed || (renotify && (numCriticals+numWarnings+numUnknown) > 0)
}
func (s state) reportChanged(sb *strings.Builder) (changed bool) {