Automatic merge from release/2.2.0 -> release/2.3.0

* commit '309a2ca0b459a0466eab0229e8e25a899d888946':
  大部分公有云不需要将安全组拆分为单个单个的规则
This commit is contained in:
邱剑
2018-11-30 23:04:03 +08:00
2 changed files with 8 additions and 2 deletions
+4
View File
@@ -280,6 +280,10 @@ func (self *SSecurityGroupRule) String() string {
return fields[0] + strings.Join(fields[1:], " ")
}
func (self *SSecurityGroupRule) toRule() (*secrules.SecurityRule, error) {
return secrules.ParseSecurityRule(self.String())
}
func (self *SSecurityGroupRule) SingleRules() ([]secrules.SecurityRule, error) {
rules := make([]secrules.SecurityRule, 0)
ruleStr := self.String()
+4 -2
View File
@@ -124,11 +124,13 @@ func (self *SSecurityGroup) getSecurityRules(direction string) (rules []SSecurit
func (self *SSecurityGroup) getSecRules(direction string) []secrules.SecurityRule {
rules := make([]secrules.SecurityRule, 0)
for _, _rule := range self.getSecurityRules(direction) {
singleRules, err := _rule.SingleRules()
//这里没必要拆分为单个单个的端口,到公有云那边适配
rule, err := _rule.toRule()
if err != nil {
log.Errorf(err.Error())
continue
}
rules = append(rules, singleRules...)
rules = append(rules, *rule)
}
return rules
}