5
5
"encoding/json"
6
6
"fmt"
7
7
"net/http"
8
+ "os"
9
+ "strings"
8
10
"time"
9
11
10
12
"github.com/emicklei/go-restful/v3"
@@ -151,7 +153,12 @@ func getAccountFromSettings(admin string) (userid, token string, err error) {
151
153
152
154
func GetAwsAccountFromCloud (ctx context.Context , client dynamic.Interface , bucket string ) (* AWSAccount , error ) {
153
155
// cloudUrl := "https://cloud-dev-api.bttcdn.com/v1/resource/stsToken"
154
- cloudUrl := "https://cloud-api.bttcdn.com/v1/resource/stsToken/setup"
156
+ cloudHost := "https://cloud-api.bttcdn.com"
157
+ cloudHostFromEnv := os .Getenv ("OLARES_SPACE_URL" )
158
+ if cloudHostFromEnv != "" {
159
+ cloudHost = cloudHostFromEnv
160
+ }
161
+ cloudURL := fmt .Sprintf ("%s/v1/resource/stsToken/setup" , strings .TrimSuffix (cloudHost , "/" ))
155
162
156
163
clusterId , ak , sk , st , err := getClusterId (ctx , client )
157
164
if err != nil {
@@ -175,10 +182,10 @@ func GetAwsAccountFromCloud(ctx context.Context, client dynamic.Interface, bucke
175
182
"durationSeconds" : fmt .Sprintf ("%.0f" , duration .Seconds ()),
176
183
}).
177
184
SetResult (& AWSAccountResponse {}).
178
- Post (cloudUrl )
185
+ Post (cloudURL )
179
186
180
187
if err != nil {
181
- klog .Error ("fetch data from cloud error, " , err , ", " , cloudUrl )
188
+ klog .Error ("fetch data from cloud error, " , err , ", " , cloudURL )
182
189
return nil , err
183
190
}
184
191
0 commit comments