in cmd/service_scale.go [20:46]
func (o *ScaleServiceOperation) SetScale(scaleExpression string) {
ecs := ECS.New(sess, clusterName)
validScale := regexp.MustCompile(validScalePattern)
if !validScale.MatchString(scaleExpression) {
console.ErrorExit(fmt.Errorf("Invalid scale expression %s", scaleExpression), "Invalid command line argument")
}
if scaleExpression[0] == '+' || scaleExpression[0] == '-' {
if s, err := strconv.ParseInt(scaleExpression[1:len(scaleExpression)], 10, 64); err == nil {
currentDesiredCount := ecs.GetDesiredCount(o.ServiceName)
if scaleExpression[0] == '+' {
o.DesiredCount = currentDesiredCount + s
} else if scaleExpression[0] == '-' {
o.DesiredCount = currentDesiredCount - s
}
}
} else if s, err := strconv.ParseInt(scaleExpression, 10, 64); err == nil {
o.DesiredCount = s
} else {
console.ErrorExit(fmt.Errorf("Invalid scale expression %s", scaleExpression), "Invalid command line argument")
}
if o.DesiredCount < 0 {
console.ErrorExit(fmt.Errorf("requested scale %d < 0", o.DesiredCount), "Invalid command line argument")
}
}