summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2024-05-02 00:41:48 +0300
committerPaul Buetow <paul@buetow.org>2024-05-02 00:41:48 +0300
commit04f43eb1f910b6b48e38532f5d7cb0055db424a3 (patch)
tree9dc9f37ac1dcff7b6ed17848640ba6081118e949 /internal
parent038546765611dbb3dfab1dd4f1b4a6ff6ac1d3e6 (diff)
add -force flag
Diffstat (limited to 'internal')
-rw-r--r--internal/run.go4
-rw-r--r--internal/state.go5
2 files changed, 5 insertions, 4 deletions
diff --git a/internal/run.go b/internal/run.go
index 00bb129..01f5bae 100644
--- a/internal/run.go
+++ b/internal/run.go
@@ -5,7 +5,7 @@ import (
"log"
)
-func Run(ctx context.Context, configFile string, renotify bool) {
+func Run(ctx context.Context, configFile string, renotify, force bool) {
conf, err := newConfig(configFile)
if err != nil {
log.Fatal(err)
@@ -26,7 +26,7 @@ func Run(ctx context.Context, configFile string, renotify bool) {
notifyError(conf, err)
}
- if subject, body, doNotify := state.report(renotify); doNotify {
+ if subject, body, doNotify := state.report(renotify, force); doNotify {
if err := notify(conf, subject, body); err != nil {
log.Println("error:", err)
}
diff --git a/internal/state.go b/internal/state.go
index f7e03cf..1f92212 100644
--- a/internal/state.go
+++ b/internal/state.go
@@ -94,7 +94,7 @@ func (s state) persist() error {
return os.WriteFile(s.stateFile, jsonData, os.ModePerm)
}
-func (s state) report(renotify bool) (string, string, bool) {
+func (s state) report(renotify, force bool) (string, string, bool) {
var sb strings.Builder
sb.WriteString("This is the recent Gogios report!\n\n")
@@ -117,7 +117,8 @@ func (s state) report(renotify bool) (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 || (renotify && hasUnhandled)
+ doNotify := force || (changed || (renotify && hasUnhandled))
+ return subject, sb.String(), doNotify
}
func (s state) reportChanged(sb *strings.Builder) (changed bool) {