From 3a2e40e04acab96401397a576fbf3e70514fb643 Mon Sep 17 00:00:00 2001 From: Devin Bhatt <12704239+devinbhatt@users.noreply.github.com> Date: Fri, 16 Feb 2024 16:22:15 -0800 Subject: [PATCH] Allow flagbot to get token from env --- dockerfile | 2 +- flagbot.go | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/dockerfile b/dockerfile index 882e737..d21b46c 100644 --- a/dockerfile +++ b/dockerfile @@ -29,4 +29,4 @@ USER nonroot:nonroot ENV TOKEN="" -ENTRYPOINT /flagbot -t ${TOKEN} -c /config +ENTRYPOINT ["/flagbot", "-c", "/config"] diff --git a/flagbot.go b/flagbot.go index aaaac48..afb65da 100644 --- a/flagbot.go +++ b/flagbot.go @@ -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 -c ") - os.Exit(1) + token = os.Getenv("TOKEN") + if token == "" { + log.Error("No token supplied") + os.Exit(1) + } } // Load files into their respective variables