Skip to content

Commit

Permalink
Allow flagbot to get token from env (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
devinbhatt authored Feb 17, 2024
1 parent 82ddb10 commit e2e4f91
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ USER nonroot:nonroot

ENV TOKEN=""

ENTRYPOINT /flagbot -t ${TOKEN} -c /config
ENTRYPOINT ["/flagbot", "-c", "/config"]
9 changes: 6 additions & 3 deletions flagbot.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,13 @@ func init() {
flag.StringVar(&configurationPath, "c", "configuration", "Configuration directory path")
flag.Parse()

// Check if discord token was properly parsed. If not exit
// Check if discord token was properly parsed. If not, check env. If not, exit
if token == "" {
log.Error("Error in parsing command. Proper Usage: flagbot -t <bot token> -c <configuration path>")
os.Exit(1)
token = os.Getenv("TOKEN")
if token == "" {
log.Error("No token supplied")
os.Exit(1)
}
}

// Load files into their respective variables
Expand Down

0 comments on commit e2e4f91

Please sign in to comment.