Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
Added regionalized discord notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
ianmarmour committed Sep 29, 2020
1 parent dafe373 commit 92db39f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
13 changes: 12 additions & 1 deletion cmd/nvidia-clerk-api-status/nvidia-clerk-api-status.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"fmt"
"log"
"os"
"sync"
"time"

Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion internal/alert/discord.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 92db39f

Please sign in to comment.