Skip to content

Commit 98d28b1

Browse files
authored
Merge pull request #418 from khrisrichardson/pull/385/issue/1
Use clusterName in annotation parser
2 parents 4671af2 + 58897bb commit 98d28b1

File tree

4 files changed

+11
-7
lines changed

4 files changed

+11
-7
lines changed

pkg/albingress/albingress_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func TestNewALBIngressFromIngress(t *testing.T) {
7676
}
7777
ingress := NewALBIngressFromIngress(
7878
options,
79-
annotations.NewValidatingAnnotationFactory(annotations.FakeValidator{VpcId: "vpc-1"}),
79+
annotations.NewValidatingAnnotationFactory(annotations.FakeValidator{VpcId: "vpc-1"}, "testCluster"),
8080
)
8181
if ingress == nil {
8282
t.Errorf("NewALBIngressFromIngress returned nil")

pkg/annotations/annotations.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,15 @@ type AnnotationFactory interface {
9393
}
9494

9595
type ValidatingAnnotationFactory struct {
96-
validator Validator
96+
validator Validator
97+
clusterName string
9798
}
9899

99-
func NewValidatingAnnotationFactory(validator Validator) ValidatingAnnotationFactory {
100-
return ValidatingAnnotationFactory{validator: validator}
100+
func NewValidatingAnnotationFactory(validator Validator, clusterName string) ValidatingAnnotationFactory {
101+
return ValidatingAnnotationFactory{
102+
validator: validator,
103+
clusterName: clusterName,
104+
}
101105
}
102106

103107
// ParseAnnotations validates and loads all the annotations provided into the Annotations struct.
@@ -108,7 +112,7 @@ func (vf ValidatingAnnotationFactory) ParseAnnotations(ingress *extensions.Ingre
108112
annotations := ingress.Annotations
109113
ingressNamespace := ingress.Namespace
110114
ingressName := ingress.Name
111-
clusterName := ingress.ClusterName
115+
clusterName := vf.clusterName
112116
if annotations == nil {
113117
return nil, fmt.Errorf("Necessary annotations missing. Must include at least %s, %s, %s", subnetsKey, securityGroupsKey, schemeKey)
114118
}

pkg/annotations/annotations_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func fakeValidator() FakeValidator {
1717
}
1818

1919
func TestParseAnnotations(t *testing.T) {
20-
vf := NewValidatingAnnotationFactory(FakeValidator{VpcId: "vpc-1"})
20+
vf := NewValidatingAnnotationFactory(FakeValidator{VpcId: "vpc-1"}, clusterName)
2121
_, err := vf.ParseAnnotations(&extensions.Ingress{})
2222
if err == nil {
2323
t.Fatalf("ParseAnnotations should not accept nil for annotations")

pkg/controller/alb-controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func NewALBController(awsconfig *aws.Config, conf *config.Config) *albController
9292
ac.syncer = syncALBs
9393
ac.recorderGetter = recorderGetter
9494
ac.classNameGetter = classNameGetter
95-
ac.annotationFactory = annotations.NewValidatingAnnotationFactory(annotations.NewConcreteValidator())
95+
ac.annotationFactory = annotations.NewValidatingAnnotationFactory(annotations.NewConcreteValidator(), ac.clusterName)
9696

9797
return ingress.Controller(ac).(*albController)
9898
}

0 commit comments

Comments
 (0)