func()

in cmd/lb_create.go [24:60]


func (o *lbCreateOperation) setPorts(inputPorts []string) []error {
	var (
		errs      []error
		protocols []string
	)

	if len(inputPorts) == 0 {
		return append(errs, fmt.Errorf("at least one --port must be specified"))
	}

	ports, errs := inflatePorts(inputPorts)

	if len(errs) > 0 {
		return errs
	}

	for _, port := range ports {
		errs = append(errs, validatePort(port)...)
		protocols = append(protocols, port.Protocol)
	}

	for _, protocol := range protocols {
		if protocol == "TCP" {
			for _, protocol := range protocols {
				if protocol == "HTTP" || protocol == "HTTPS" {
					return append(errs, fmt.Errorf("load balancers do not support commingled TCP and HTTP/HTTPS ports"))
				}
			}
		}
	}

	if len(errs) == 0 {
		o.ports = ports
	}

	return errs
}