Compare commits
2 Commits
dad080aa50
...
42bb6f8bad
Author | SHA1 | Date |
---|---|---|
|
42bb6f8bad | |
|
b59ba24b35 |
35
main.go
35
main.go
|
@ -44,7 +44,7 @@ type Config struct {
|
||||||
ApiUrl string `toml:"api_url"`
|
ApiUrl string `toml:"api_url"`
|
||||||
SharedSecret string `toml:"shared_secret"`
|
SharedSecret string `toml:"shared_secret"`
|
||||||
City string `toml:"city"`
|
City string `toml:"city"`
|
||||||
}
|
} `toml:"hmc"`
|
||||||
Postmark struct {
|
Postmark struct {
|
||||||
ServerToken string `toml:"server_token"`
|
ServerToken string `toml:"server_token"`
|
||||||
ApiUrl string `toml:"api_url"`
|
ApiUrl string `toml:"api_url"`
|
||||||
|
@ -404,6 +404,14 @@ func sendMail(cfg *Config, recipients []string, subject, html string) ([]Postmar
|
||||||
return results, nil
|
return results, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func ComplainEmpty(val string, complaint string) bool {
|
||||||
|
if val == "" {
|
||||||
|
fmt.Println(complaint)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
/* Read in credentials into Config struct */
|
/* Read in credentials into Config struct */
|
||||||
/* *** */
|
/* *** */
|
||||||
|
@ -422,6 +430,31 @@ func main() {
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if config.BatchSize == 0 {
|
||||||
|
config.BatchSize = 500
|
||||||
|
}
|
||||||
|
|
||||||
|
validConfig := true
|
||||||
|
|
||||||
|
validConfig = ComplainEmpty(config.TestEmail, "* Test email address is missing in config") && validConfig
|
||||||
|
validConfig = ComplainEmpty(config.HMC.ApiUrl, "* HMC API url is missing in config") && validConfig
|
||||||
|
validConfig = ComplainEmpty(config.HMC.SharedSecret, "* HMC Shared secret is missing in config") && validConfig
|
||||||
|
validConfig = ComplainEmpty(config.HMC.City, "* HMC City is missing in config") && validConfig
|
||||||
|
validConfig = ComplainEmpty(config.Postmark.ServerToken, "* Postmark server token is missing in config") && validConfig
|
||||||
|
validConfig = ComplainEmpty(config.Postmark.ApiUrl, "* Postmark API url is missing in config") && validConfig
|
||||||
|
if config.Postmark.TemplateId == 0 {
|
||||||
|
fmt.Println("* Postmark template ID is missing in config")
|
||||||
|
validConfig = false
|
||||||
|
}
|
||||||
|
validConfig = ComplainEmpty(config.Postmark.SenderName, "* Sender name is missing in config") && validConfig
|
||||||
|
validConfig = ComplainEmpty(config.Postmark.SenderEmail, "* Sender email is missing in config") && validConfig
|
||||||
|
validConfig = ComplainEmpty(config.Postmark.MessageStream, "* Postmark message stream is missing in config") && validConfig
|
||||||
|
|
||||||
|
if !validConfig {
|
||||||
|
fmt.Println("Please fix your config and try again")
|
||||||
|
os.Exit(1)
|
||||||
|
}
|
||||||
|
|
||||||
/* Setup Cobra */
|
/* Setup Cobra */
|
||||||
/* *** */
|
/* *** */
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
|
|
Loading…
Reference in New Issue