Skip to content

Commit

Permalink
Hotfix for runtime err in RegisterCspNativeRes (#1101)
Browse files Browse the repository at this point in the history
  • Loading branch information
seokho-son authored May 10, 2022
1 parent 2342fed commit bf7229a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/core/common/utility.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ func GetConnConfigList() (ConnConfigList, error) {
if err != nil {
CBLog.Error(err)
content := ConnConfigList{}
err := fmt.Errorf("an error occurred while requesting to CB-Spider")
err := fmt.Errorf("Error from CB-Spider: " + err.Error())
return content, err
}

Expand Down
34 changes: 21 additions & 13 deletions src/core/mcir/securitygroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,27 +193,35 @@ func CreateSecurityGroup(nsId string, u *TbSecurityGroupReq, option string) (TbS

if err != nil {
common.CBLog.Error(err)
err := fmt.Errorf("Cannot ListResourceId securityGroup")
err := fmt.Errorf("Cannot list vNet Ids for securityGroup")
return TbSecurityGroupInfo{}, err
}

var content struct {
VNet []TbVNetInfo `json:"vNet"`
}
content.VNet = resourceList.([]TbVNetInfo) // type assertion (interface{} -> array)
if resourceList != nil {
var content struct {
VNet []TbVNetInfo `json:"vNet"`
}
content.VNet = resourceList.([]TbVNetInfo) // type assertion (interface{} -> array)

if len(resourceList.([]TbVNetInfo)) == 0 {
errString := "There is no " + common.StrVNet + " resource in " + nsId
err := fmt.Errorf(errString)
common.CBLog.Error(err)
return TbSecurityGroupInfo{}, err
}

if len(content.VNet) == 0 {
errString := "There is no " + common.StrVNet + " resource in " + nsId
// Assign random temporal ID to u.VNetId (should be in the same Connection with SG)
for _, r := range content.VNet {
if r.ConnectionName == u.ConnectionName {
u.VNetId = r.Id
}
}
} else {
errString := "nil was returned for vNet list in " + nsId
err := fmt.Errorf(errString)
common.CBLog.Error(err)
return TbSecurityGroupInfo{}, err
}

for _, r := range content.VNet {
if r.ConnectionName == u.ConnectionName {
u.VNetId = r.Id
}
}
}

vNetInfo := TbVNetInfo{}
Expand Down

0 comments on commit bf7229a

Please sign in to comment.