File tree Expand file tree Collapse file tree 5 files changed +25
-8
lines changed Expand file tree Collapse file tree 5 files changed +25
-8
lines changed Original file line number Diff line number Diff line change @@ -46,9 +46,6 @@ func NewCmdAsyncCheck() *cobra.Command {
46
46
Run : func (cmd * cobra.Command , positionalArgs []string ) {
47
47
bm := iqshell .GetBucketManager ()
48
48
49
- // let API choose APIHOST
50
- bm .Cfg .ApiHost = ""
51
-
52
49
ret , err := bm .CheckAsyncFetchStatus (positionalArgs [0 ], positionalArgs [1 ])
53
50
if err != nil {
54
51
fmt .Fprintf (os .Stderr , "CheckAsyncFetchStatus: %v\n " , err )
Original file line number Diff line number Diff line change @@ -149,7 +149,6 @@ func initConfig() {
149
149
iqshell .SetDefaultAccPath (filepath .Join (rootPath , "account.json" ))
150
150
iqshell .SetDefaultRsHost (storage .DefaultRsHost )
151
151
iqshell .SetDefaultRsfHost (storage .DefaultRsfHost )
152
- iqshell .SetDefaultApiHost (storage .DefaultAPIHost )
153
152
iqshell .SetDefaultUcHost ("https://uc.qbox.me" )
154
153
155
154
if rErr := viper .ReadInConfig (); rErr != nil {
Original file line number Diff line number Diff line change @@ -217,7 +217,8 @@ func (fc *fetchConfig) initFileExporter() {
217
217
func (fc * fetchConfig ) initBucketManager () {
218
218
219
219
cfg := storage.Config {
220
- IoHost : fc .upHost ,
220
+ IoHost : fc .upHost ,
221
+ ApiHost : iqshell .ApiHost (),
221
222
}
222
223
fc .bm = iqshell .GetBucketManagerWithConfig (& cfg )
223
224
}
Original file line number Diff line number Diff line change 4
4
"github.com/spf13/pflag"
5
5
"github.com/spf13/viper"
6
6
"path/filepath"
7
+ "strings"
7
8
)
8
9
9
10
const (
@@ -241,10 +242,14 @@ func SetDefaultApiHost(val string) {
241
242
242
243
func UcHost () string {
243
244
host := viper .GetString (HOST_UC [0 ])
244
- if host != "" {
245
- return host
245
+ if host == "" {
246
+ host = viper .GetString (HOST_UC [1 ])
247
+ }
248
+
249
+ if ! strings .Contains (host , "://" ) {
250
+ host = Endpoint (true , host )
246
251
}
247
- return viper . GetString ( HOST_UC [ 1 ])
252
+ return host
248
253
}
249
254
250
255
func SetUcHost (val string ) {
Original file line number Diff line number Diff line change 5
5
"encoding/base64"
6
6
"encoding/json"
7
7
"errors"
8
+ "fmt"
8
9
"io"
9
10
"net/url"
10
11
"os"
@@ -285,3 +286,17 @@ func SimpleUnescape(s *string) string {
285
286
`\'` , `'` )
286
287
return r .Replace (* s )
287
288
}
289
+
290
+ func Endpoint (useHttps bool , host string ) string {
291
+ host = strings .TrimSpace (host )
292
+ host = strings .TrimLeft (host , "http://" )
293
+ host = strings .TrimLeft (host , "https://" )
294
+ if host == "" {
295
+ return ""
296
+ }
297
+ scheme := "http://"
298
+ if useHttps {
299
+ scheme = "https://"
300
+ }
301
+ return fmt .Sprintf ("%s%s" , scheme , host )
302
+ }
You can’t perform that action at this time.
0 commit comments