in cmd/service_create.go [96:130]
func (o *ServiceCreateOperation) SetRules(inputRules []string) {
var rules []ELBV2.Rule
var msgs []string
validRuleTypes := regexp.MustCompile(validRuleTypesPattern)
if len(inputRules) > 0 && o.LoadBalancerArn == "" {
msgs = append(msgs, "lb must be configured if rules are specified")
}
for _, inputRule := range inputRules {
splitInputRule := strings.SplitN(inputRule, "=", 2)
if len(splitInputRule) != 2 {
msgs = append(msgs, "rules must be in the form of type=value")
}
if !validRuleTypes.MatchString(splitInputRule[0]) {
msgs = append(msgs, fmt.Sprintf("Invalid rule type %s [must be path or host]", splitInputRule[0]))
}
rules = append(rules,
ELBV2.Rule{
Type: strings.ToUpper(splitInputRule[0]),
Value: splitInputRule[1],
},
)
}
if len(msgs) > 0 {
console.ErrorExit(fmt.Errorf(strings.Join(msgs, ", ")), "Invalid rule")
}
o.Rules = rules
}