Skip to content

Commit bda1660

Browse files
committed
Allow using a shell variable instaid of a env.json file
1 parent 40c6fd5 commit bda1660

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

main.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,17 @@ type EnvUser struct {
7272
}
7373

7474
func main() {
75-
envFile, err := ioutil.ReadFile("env.json")
75+
envFilename := "env.json"
76+
envEnvName := "RTCV_SCRAPER_CLIENT_ENV"
77+
envFile, err := ioutil.ReadFile(envFilename)
7678
if err != nil {
77-
log.Fatal("unable to read env file, error: " + err.Error())
79+
if !os.IsNotExist(err) {
80+
log.Fatal("unable to read env file, error: " + err.Error())
81+
}
82+
envFile = []byte(os.Getenv(envEnvName))
83+
if len(envFile) == 0 {
84+
log.Fatalf("no %s file or %s envourment variable found, cannot continue", envFilename, envEnvName)
85+
}
7886
}
7987

8088
env := Env{}

0 commit comments

Comments
 (0)