Skip to content

Commit

Permalink
Merge pull request #31 from lixiaojun629/develop
Browse files Browse the repository at this point in the history
fixbug
  • Loading branch information
lixiaojun629 authored Jul 4, 2019
2 parents 0d1d15b + 7ccf76c commit bff79e5
Showing 1 changed file with 37 additions and 26 deletions.
63 changes: 37 additions & 26 deletions base/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,20 +178,19 @@ func NewAggConfigManager(cfgFile, credFile io.Reader) (*AggConfigManager, error)
err := manager.Load()
if err != nil {
if !os.IsNotExist(err) {
HandleError(fmt.Errorf("load cli config failed: %v", err))
return nil, err
return manager, err
}

aerr := adaptOldConfig()
if aerr != nil {
HandleError(aerr)
return nil, aerr
return manager, aerr
}

err := manager.Load()
if err != nil {
HandleError(fmt.Errorf("retry to load cli config failed: %v", err))
return nil, err
return manager, err
}
}
return manager, nil
Expand Down Expand Up @@ -506,39 +505,51 @@ func init() {
cfgFile, err := os.Open(ConfigFilePath)
if err != nil {
HandleError(err)
} else {
defer cfgFile.Close()
}
defer cfgFile.Close()

credFile, err := os.Open(CredentialFilePath)
if err != nil {
HandleError(err)
} else {
defer credFile.Close()
}
defer credFile.Close()

AggConfigListIns, err = NewAggConfigManager(cfgFile, credFile)
if err != nil {
HandleError(err)
}

ins, err := AggConfigListIns.GetActiveAggConfig()
if err != nil {
LogInfo(fmt.Sprintf("load active config failed: %v", err))
ins = &AggConfig{
BaseURL: DefaultBaseURL,
Timeout: DefaultTimeoutSec,
ins := &AggConfig{
BaseURL: "https://api.ucloud.cn",
Timeout: 15,
Profile: "default",
}
bc, err := GetBizClient(ins)
if err != nil {
HandleError(err)
} else {
BizClient = bc
}
} else {
ConfigIns = ins
tmpIns := *ins
tmpIns.PublicKey = MosaicString(tmpIns.PublicKey, 5, 5)
tmpIns.PrivateKey = MosaicString(tmpIns.PrivateKey, 5, 5)
LogInfo(fmt.Sprintf("load active config : %#v", tmpIns))
}

bc, err := GetBizClient(ins)
if err != nil {
HandleError(err)
} else {
BizClient = bc
ins, err := AggConfigListIns.GetActiveAggConfig()
if err != nil {
LogInfo(fmt.Sprintf("load active config failed: %v", err))
ins = &AggConfig{
BaseURL: DefaultBaseURL,
Timeout: DefaultTimeoutSec,
}
} else {
ConfigIns = ins
tmpIns := *ins
tmpIns.PublicKey = MosaicString(tmpIns.PublicKey, 5, 5)
tmpIns.PrivateKey = MosaicString(tmpIns.PrivateKey, 5, 5)
LogInfo(fmt.Sprintf("load active config : %#v", tmpIns))
}
bc, err := GetBizClient(ins)
if err != nil {
HandleError(err)
} else {
BizClient = bc
}
}
}

0 comments on commit bff79e5

Please sign in to comment.