diff --git a/cmd/nvidia-clerk-api-status/nvidia-clerk-api-status.go b/cmd/nvidia-clerk-api-status/nvidia-clerk-api-status.go index 44994ff..fcd0272 100644 --- a/cmd/nvidia-clerk-api-status/nvidia-clerk-api-status.go +++ b/cmd/nvidia-clerk-api-status/nvidia-clerk-api-status.go @@ -3,6 +3,7 @@ package main import ( "fmt" "log" + "os" "sync" "time" @@ -37,8 +38,18 @@ func main() { continue } + dcURL, dcURLOK := os.LookupEnv(fmt.Sprintf("DISCORD_WEBHOOK_URL_%s", tempID)) + if dcURLOK == false { + log.Println(fmt.Sprintf("Error getting discord webhook configuration for %s", tempID)) + wg.Add(-1) + continue + } + + cc := *c + cc.DiscordConfig = &config.DiscordConfig{WebhookURL: dcURL} + log.Println(fmt.Sprintf("Starting goroutine for %s", tempID)) - go alert.StartDiscordAPINotifications(tempID, "checkout", *c, &wg) + go alert.StartDiscordAPINotifications(tempID, "checkout", cc, &wg) } wg.Wait() diff --git a/internal/alert/discord.go b/internal/alert/discord.go index 566dfd5..d10258a 100644 --- a/internal/alert/discord.go +++ b/internal/alert/discord.go @@ -32,7 +32,7 @@ func (d *DiscordAPIMessage) Get() string { // Set takes in an API name and returns the JSON body for a Discord POST request func (d *DiscordAPIMessage) Set(name string, status string) { - d.body = fmt.Sprintf("@here NVIDIA API %s is now %s", name, status) + d.body = fmt.Sprintf("NVIDIA API %s is now %s", name, status) } // JSON returns the JSON encoded bytes of a DiscordAPIMessage