Skip to content

Commit

Permalink
Change default when no BE proto given, add test for that
Browse files Browse the repository at this point in the history
Also improve error message when BE proto is wrong
  • Loading branch information
Rudi Chiarito committed May 10, 2016
1 parent e19c069 commit 5933440
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
6 changes: 3 additions & 3 deletions pkg/cloudprovider/providers/aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -2133,12 +2133,12 @@ func buildListener(port api.ServicePort, annotations map[string]string) (*elb.Li
if certID != "" {
instanceProtocol = annotations[ServiceAnnotationLoadBalancerBEProtocol]
if instanceProtocol == "" {
protocol = "https"
instanceProtocol = "http"
protocol = "ssl"
instanceProtocol = "tcp"
} else {
protocol = backendProtocolMapping[instanceProtocol]
if protocol == "" {
return nil, fmt.Errorf("Invalid backend protocol %s in %s", instanceProtocol, certID)
return nil, fmt.Errorf("Invalid backend protocol %s for %s in %s", instanceProtocol, certID, ServiceAnnotationLoadBalancerBEProtocol)
}
}
listener.SSLCertificateId = &certID
Expand Down
9 changes: 7 additions & 2 deletions pkg/cloudprovider/providers/aws/aws_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1216,9 +1216,14 @@ func TestBuildListener(t *testing.T) {
}{
{
"No cert or BE protocol annotation, passthrough",
80, 8000, "", "",
80, 7999, "", "",
false, "tcp", "tcp", "",
},
{
"Cert annotation without BE protocol specified, SSL->TCP",
80, 8000, "", "cert",
false, "ssl", "tcp", "cert",
},
{
"BE protocol without cert annotation, passthrough",
443, 8001, "https", "",
Expand Down Expand Up @@ -1265,7 +1270,7 @@ func TestBuildListener(t *testing.T) {
if test.certAnnotation != "" {
annotations[ServiceAnnotationLoadBalancerCertificate] = test.certAnnotation
}
l, err := getListener(api.ServicePort{
l, err := buildListener(api.ServicePort{
NodePort: int32(test.instancePort),
Port: int32(test.lbPort),
Protocol: api.Protocol("tcp"),
Expand Down

0 comments on commit 5933440

Please sign in to comment.