()
| 73 | } |
| 74 | |
| 75 | func 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 | |
| 104 | func writeHtmlFile(content string, lg log.Logger) { |
| 105 | file, err := os.Create(*bodyFileFlag) |
nothing calls this directly
no test coverage detected