MCPcopy Create free account
hub / github.com/ethstorage/es-node / main

Function main

cmd/alert/main.go:75–102  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

73}
74
75func main() {
76 flag.Parse()
77 log.SetDefault(log.NewLogger(log.NewTerminalHandlerWithLevel(os.Stderr, log.LevelInfo, true)))
78
79 var (
80 lg = log.New("app", "alert")
81 needAlert = false
82 contents = ""
83 emailList = make(map[string]struct{})
84 )
85
86 checkers := LoadConfig(*ruleFileFlag, lg)
87
88 for _, checker := range checkers {
89 res, content, emailTo := checker.Check(lg)
90 if res {
91 needAlert = res
92 contents = contents + content + "\n"
93 addToEmailList(emailList, emailTo)
94 }
95 }
96
97 if needAlert {
98 writeHtmlFile(fmt.Sprintf(emailFormat, contents), lg)
99 writeToGitHubEnv(emailList, lg)
100 os.Exit(1)
101 }
102}
103
104func writeHtmlFile(content string, lg log.Logger) {
105 file, err := os.Create(*bodyFileFlag)

Callers

nothing calls this directly

Calls 5

addToEmailListFunction · 0.85
writeHtmlFileFunction · 0.85
writeToGitHubEnvFunction · 0.85
LoadConfigFunction · 0.70
CheckMethod · 0.65

Tested by

no test coverage detected