go fmt structure files

This commit is contained in:
clint shryock 2015-11-13 13:53:52 -06:00
parent 536ba76b21
commit 7d94c86958
2 changed files with 44 additions and 44 deletions

View File

@ -44,24 +44,24 @@ func expandListeners(configured []interface{}) ([]*elb.Listener, error) {
l.SSLCertificateId = aws.String(v.(string)) l.SSLCertificateId = aws.String(v.(string))
} }
var valid bool var valid bool
if l.SSLCertificateId != nil && *l.SSLCertificateId != "" { if l.SSLCertificateId != nil && *l.SSLCertificateId != "" {
// validate the protocol is correct // validate the protocol is correct
for _, p := range []string{"https", "ssl"} { for _, p := range []string{"https", "ssl"} {
if (*l.InstanceProtocol == p) || (*l.Protocol == p) { if (*l.InstanceProtocol == p) || (*l.Protocol == p) {
valid = true valid = true
} }
} }
} else { } else {
valid = true valid = true
} }
if valid { if valid {
listeners = append(listeners, l) listeners = append(listeners, l)
} else { } else {
return nil, fmt.Errorf("[ERR] ELB Listener: ssl_certificate_id may be set only when protocol is 'https' or 'ssl'") return nil, fmt.Errorf("[ERR] ELB Listener: ssl_certificate_id may be set only when protocol is 'https' or 'ssl'")
} }
} }
return listeners, nil return listeners, nil
} }

View File

@ -2,7 +2,7 @@ package aws
import ( import (
"reflect" "reflect"
"strings" "strings"
"testing" "testing"
"github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws"
@ -296,13 +296,13 @@ func TestExpandListeners(t *testing.T) {
"instance_protocol": "http", "instance_protocol": "http",
"lb_protocol": "http", "lb_protocol": "http",
}, },
map[string]interface{}{ map[string]interface{}{
"instance_port": 8000, "instance_port": 8000,
"lb_port": 80, "lb_port": 80,
"instance_protocol": "https", "instance_protocol": "https",
"lb_protocol": "https", "lb_protocol": "https",
"ssl_certificate_id": "something", "ssl_certificate_id": "something",
}, },
} }
listeners, err := expandListeners(expanded) listeners, err := expandListeners(expanded)
if err != nil { if err != nil {
@ -327,26 +327,26 @@ func TestExpandListeners(t *testing.T) {
// this test should produce an error from expandlisteners on an invalid // this test should produce an error from expandlisteners on an invalid
// combination // combination
func TestExpandListeners_invalid(t *testing.T) { func TestExpandListeners_invalid(t *testing.T) {
expanded := []interface{}{ expanded := []interface{}{
map[string]interface{}{ map[string]interface{}{
"instance_port": 8000, "instance_port": 8000,
"lb_port": 80, "lb_port": 80,
"instance_protocol": "http", "instance_protocol": "http",
"lb_protocol": "http", "lb_protocol": "http",
"ssl_certificate_id": "something", "ssl_certificate_id": "something",
}, },
} }
_, err := expandListeners(expanded) _, err := expandListeners(expanded)
if err != nil { if err != nil {
// Check the error we got // Check the error we got
if !strings.Contains(err.Error(), "ssl_certificate_id may be set only when protocol") { if !strings.Contains(err.Error(), "ssl_certificate_id may be set only when protocol") {
t.Fatalf("Got error in TestExpandListeners_invalid, but not what we expected: %s", err) t.Fatalf("Got error in TestExpandListeners_invalid, but not what we expected: %s", err)
} }
} }
if err == nil { if err == nil {
t.Fatalf("Expected TestExpandListeners_invalid to fail, but passed") t.Fatalf("Expected TestExpandListeners_invalid to fail, but passed")
} }
} }
func TestFlattenHealthCheck(t *testing.T) { func TestFlattenHealthCheck(t *testing.T) {