Skip to content

Commit e38f6a3

Browse files
committed
feat: allow RUNPOD_API_KEY env to overwrite config api key
1 parent 59a34a9 commit e38f6a3

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

api/query.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"bytes"
55
"encoding/json"
66
"net/http"
7+
"os"
78
"time"
89

910
"github.com/spf13/viper"
@@ -19,7 +20,12 @@ func Query(input Input) (res *http.Response, err error) {
1920
if err != nil {
2021
return
2122
}
22-
req, err := http.NewRequest("POST", viper.GetString("apiUrl")+"?api_key="+viper.GetString("apiKey"), bytes.NewBuffer(jsonValue))
23+
24+
apiKey := os.Getenv("RUNPOD_API_KEY")
25+
if apiKey == "" {
26+
apiKey = viper.GetString("apiKey")
27+
}
28+
req, err := http.NewRequest("POST", viper.GetString("apiUrl")+"?api_key="+apiKey, bytes.NewBuffer(jsonValue))
2329
if err != nil {
2430
return
2531
}

0 commit comments

Comments
 (0)