Skip to content

Commit 152e114

Browse files
Menekse CeylanMenekse Ceylan
authored andcommitted
Add label related alb tests to alb_spec_test.go
Write gingko test for ingressclass_controller.go update done with "go mod tidy"
1 parent c6cb456 commit 152e114

6 files changed

Lines changed: 748 additions & 228 deletions

File tree

go.mod

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ require (
1414
github.com/spf13/cobra v1.10.2
1515
github.com/spf13/pflag v1.0.10
1616
github.com/stackitcloud/stackit-sdk-go/core v0.26.0
17+
github.com/stackitcloud/stackit-sdk-go/services/alb v0.14.2
18+
github.com/stackitcloud/stackit-sdk-go/services/certificates v1.7.0
1719
github.com/stackitcloud/stackit-sdk-go/services/iaas v1.11.1
1820
github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.13.0
1921
go.uber.org/mock v0.6.0
@@ -30,6 +32,7 @@ require (
3032
k8s.io/klog/v2 v2.140.0
3133
k8s.io/mount-utils v0.36.1
3234
k8s.io/utils v0.0.0-20260507154919-ff6756f316d2
35+
sigs.k8s.io/controller-runtime v0.24.1
3336
)
3437

3538
replace k8s.io/cloud-provider => github.com/stackitcloud/cloud-provider v0.36.0-ske-1
@@ -48,11 +51,13 @@ require (
4851
github.com/coreos/go-systemd/v22 v22.7.0 // indirect
4952
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
5053
github.com/emicklei/go-restful/v3 v3.13.0 // indirect
54+
github.com/evanphx/json-patch/v5 v5.9.11 // indirect
5155
github.com/felixge/httpsnoop v1.0.4 // indirect
5256
github.com/fsnotify/fsnotify v1.9.0 // indirect
5357
github.com/fxamacker/cbor/v2 v2.9.0 // indirect
5458
github.com/go-logr/logr v1.4.3 // indirect
5559
github.com/go-logr/stdr v1.2.2 // indirect
60+
github.com/go-logr/zapr v1.3.0 // indirect
5661
github.com/go-openapi/jsonpointer v0.22.1 // indirect
5762
github.com/go-openapi/jsonreference v0.21.2 // indirect
5863
github.com/go-openapi/swag v0.25.1 // indirect
@@ -121,12 +126,14 @@ require (
121126
golang.org/x/text v0.36.0 // indirect
122127
golang.org/x/time v0.14.0 // indirect
123128
golang.org/x/tools v0.44.0 // indirect
129+
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
124130
google.golang.org/genproto/googleapis/api v0.0.0-20260226221140-a57be14db171 // indirect
125131
google.golang.org/genproto/googleapis/rpc v0.0.0-20260226221140-a57be14db171 // indirect
126132
gopkg.in/evanphx/json-patch.v4 v4.13.0 // indirect
127133
gopkg.in/inf.v0 v0.9.1 // indirect
128134
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
129135
gopkg.in/yaml.v2 v2.4.0 // indirect
136+
k8s.io/apiextensions-apiserver v0.36.0 // indirect
130137
k8s.io/apiserver v0.36.0 // indirect
131138
k8s.io/component-helpers v0.36.0 // indirect
132139
k8s.io/controller-manager v0.36.0 // indirect

go.sum

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,10 @@ github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkp
3333
github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto=
3434
github.com/emicklei/go-restful/v3 v3.13.0 h1:C4Bl2xDndpU6nJ4bc1jXd+uTmYPVUwkD6bFY/oTyCes=
3535
github.com/emicklei/go-restful/v3 v3.13.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc=
36+
github.com/evanphx/json-patch v0.5.2 h1:xVCHIVMUu1wtM/VkR9jVZ45N3FhZfYMMYGorLCR8P3k=
37+
github.com/evanphx/json-patch v0.5.2/go.mod h1:ZWS5hhDbVDyob71nXKNL0+PWn6ToqBHMikGIFbs31qQ=
38+
github.com/evanphx/json-patch/v5 v5.9.11 h1:/8HVnzMq13/3x9TPvjG08wUGqBTmZBsCWzjTM0wiaDU=
39+
github.com/evanphx/json-patch/v5 v5.9.11/go.mod h1:3j+LviiESTElxA4p3EMKAB9HXj3/XEtnUf6OZxqIQTM=
3640
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
3741
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
3842
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
@@ -105,6 +109,8 @@ github.com/google/gnostic-models v0.7.0/go.mod h1:whL5G0m6dmc5cPxKc5bdKdEN3UjI7O
105109
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=
106110
github.com/google/go-cmp v0.7.0/go.mod h1:pXiqmnSA92OHEEa9HXL2W4E7lf9JzCmGVUdgjX3N/iU=
107111
github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
112+
github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0=
113+
github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg=
108114
github.com/google/pprof v0.0.0-20260402051712-545e8a4df936 h1:EwtI+Al+DeppwYX2oXJCETMO23COyaKGP6fHVpkpWpg=
109115
github.com/google/pprof v0.0.0-20260402051712-545e8a4df936/go.mod h1:MxpfABSjhmINe3F1It9d+8exIHFvUqtLIRCdOGNXqiI=
110116
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
@@ -159,6 +165,8 @@ github.com/onsi/ginkgo/v2 v2.29.0 h1:rfh+ZFjgJhYWRoIqVf3Uwx/W20yLrcrE2h2GmYVRaag
159165
github.com/onsi/ginkgo/v2 v2.29.0/go.mod h1:+aXOY+vzZ5mu2iI2HpTZUPmM//oQfsNFX6gU9kNcA44=
160166
github.com/onsi/gomega v1.41.0 h1:OwKp4pXNgVxf6sCplzYo794OFNuoL2q2SBMU5NSWOjA=
161167
github.com/onsi/gomega v1.41.0/go.mod h1:M/Uqpu/8qTjtzCLUA2zJHX9Iilrau25x1PdoSRbWh5A=
168+
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
169+
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
162170
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
163171
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U=
164172
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
@@ -186,6 +194,10 @@ github.com/stackitcloud/cloud-provider v0.36.0-ske-1 h1:CZaL+8FH1rOjPnlPkhmvfKUk
186194
github.com/stackitcloud/cloud-provider v0.36.0-ske-1/go.mod h1:y/3sksoC0taJZR0PcAAYUqVyD6Jzu2X0lD4yCEPXPuI=
187195
github.com/stackitcloud/stackit-sdk-go/core v0.26.0 h1:jQEb9gkehfp6VCP6TcYk7BI10cz4l0KM2L6hqYBH2QA=
188196
github.com/stackitcloud/stackit-sdk-go/core v0.26.0/go.mod h1:WU1hhxnjXw2EV7CYa1nlEvNpMiRY6CvmIOaHuL3pOaA=
197+
github.com/stackitcloud/stackit-sdk-go/services/alb v0.14.2 h1:hGzfOJjlCRoFpri5eYIiwhE27qu02pKZLprKvbsTC/w=
198+
github.com/stackitcloud/stackit-sdk-go/services/alb v0.14.2/go.mod h1:eK6oRB5Tmpt6KbXQ4UYBGg2LgW5bPtVoncL9E8JSRww=
199+
github.com/stackitcloud/stackit-sdk-go/services/certificates v1.7.0 h1:J7BVVHjRTS5YUyGf6DZEIE1uD9f/S4v9dDbpZWVEd3U=
200+
github.com/stackitcloud/stackit-sdk-go/services/certificates v1.7.0/go.mod h1:eJpB3/pukz+KzVPVHQ4g3DVtQkxGga18VbFBhq9ugdY=
189201
github.com/stackitcloud/stackit-sdk-go/services/iaas v1.11.1 h1:HcKqjwIjv4OAW1aWI0U/JWjnzTwzSvdr6DLasH940EU=
190202
github.com/stackitcloud/stackit-sdk-go/services/iaas v1.11.1/go.mod h1:Ts06id0KejUlQWbpR+/rm+tKng6QkTuFV1VQTPJ4dA4=
191203
github.com/stackitcloud/stackit-sdk-go/services/loadbalancer v1.13.0 h1:UuLNwFHjJCpL11y4F7B9oBKtZkxpu01VkNPILNkpex4=
@@ -326,6 +338,8 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T
326338
golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
327339
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
328340
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
341+
gomodules.xyz/jsonpatch/v2 v2.4.0 h1:Ci3iUJyx9UeRx7CeFN8ARgGbkESwJK+KB9lLcWxY/Zw=
342+
gomodules.xyz/jsonpatch/v2 v2.4.0/go.mod h1:AH3dM2RI6uoBZxn3LVrfvJ3E0/9dG4cSrbuBJT4moAY=
329343
gonum.org/v1/gonum v0.17.0 h1:VbpOemQlsSMrYmn7T2OUvQ4dqxQXU+ouZFQsZOx50z4=
330344
gonum.org/v1/gonum v0.17.0/go.mod h1:El3tOrEuMpv2UdMrbNlKEh9vd86bmQ6vqIcDwxEOc1E=
331345
google.golang.org/genproto/googleapis/api v0.0.0-20260226221140-a57be14db171 h1:tu/dtnW1o3wfaxCOjSLn5IRX4YDcJrtlpzYkhHhGaC4=
@@ -352,6 +366,8 @@ gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
352366
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
353367
k8s.io/api v0.36.1 h1:XbL/EMj8K2aJpJtePmqUyQMsM0D4QI2pvl7YKJ20FTY=
354368
k8s.io/api v0.36.1/go.mod h1:KOWo4ey3TINlXjeHVuwB3i+tXXnu+UcwFBHlI/9dvEo=
369+
k8s.io/apiextensions-apiserver v0.36.0 h1:Wt7E8J+VBCbj4FjiBfDTK/neXDDjyJVJc7xfuOHImZ0=
370+
k8s.io/apiextensions-apiserver v0.36.0/go.mod h1:kGDjH0msuiIB3tgsYRV0kS9GqpMYMUsQ3GHv7TApyug=
355371
k8s.io/apimachinery v0.36.1 h1:G63Gjx2W+q0YD+72Vo8oY0nDnePVwnuzTmmy5ENrVSA=
356372
k8s.io/apimachinery v0.36.1/go.mod h1:ibYOR00vW/I1kzvi5SF0dRuJ52BvKtfvRdOn35GPQ+8=
357373
k8s.io/apiserver v0.36.0 h1:Jg5OFAENUACByUCg15CmhZAYrr5ZyJ+jodyA1mHl3YE=
@@ -378,6 +394,8 @@ k8s.io/utils v0.0.0-20260507154919-ff6756f316d2 h1:wU4tMEhLGgIbLvXQb1cfN+EcM0wf7
378394
k8s.io/utils v0.0.0-20260507154919-ff6756f316d2/go.mod h1:xDxuJ0whA3d0I4mf/C4ppKHxXynQ+fxnkmQH0vTHnuk=
379395
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.34.0 h1:hSfpvjjTQXQY2Fol2CS0QHMNs/WI1MOSGzCm1KhM5ec=
380396
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.34.0/go.mod h1:Ve9uj1L+deCXFrPOk1LpFXqTg7LCFzFso6PA48q/XZw=
397+
sigs.k8s.io/controller-runtime v0.24.1 h1:miPEwrmirImAvgME1L9qebGHrOnGJoVmVdtOU9fRfo4=
398+
sigs.k8s.io/controller-runtime v0.24.1/go.mod h1:vFkfY5fGt5xAC/sKb8IBFKgWPNKG9OUG29dR8Y2wImw=
381399
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730 h1:IpInykpT6ceI+QxKBbEflcR5EXP7sU1kvOlxwZh5txg=
382400
sigs.k8s.io/json v0.0.0-20250730193827-2d320260d730/go.mod h1:mdzfpAEoE6DHQEN0uh9ZbOCuHbLK5wOm7dK4ctXE9Tg=
383401
sigs.k8s.io/randfill v1.0.0 h1:JfjMILfT8A6RbawdsK2JXGBR5AQVfd+9TbzrlneTyrU=

pkg/alb/ingress/alb_spec_test.go

Lines changed: 178 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@ import (
66

77
. "github.com/onsi/ginkgo/v2"
88
. "github.com/onsi/gomega"
9+
stackitmocks "github.com/stackitcloud/cloud-provider-stackit/pkg/stackit"
910
stackitconfig "github.com/stackitcloud/cloud-provider-stackit/pkg/stackit/config"
1011
albsdk "github.com/stackitcloud/stackit-sdk-go/services/alb/v2api"
12+
certsdk "github.com/stackitcloud/stackit-sdk-go/services/certificates/v2api"
13+
"go.uber.org/mock/gomock"
1114
corev1 "k8s.io/api/core/v1"
1215
networkingv1 "k8s.io/api/networking/v1"
1316
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -18,7 +21,9 @@ import (
1821

1922
var _ = Describe("Node Controller", func() {
2023
var (
21-
k8sClient client.Client
24+
k8sClient client.Client
25+
mockCtrl *gomock.Controller
26+
certClient *stackitmocks.MockCertificatesClient
2227

2328
ingressClass networkingv1.IngressClass
2429
ingress networkingv1.Ingress
@@ -34,7 +39,7 @@ var _ = Describe("Node Controller", func() {
3439
networkID := "my-network"
3540

3641
ingressClass = networkingv1.IngressClass{
37-
ObjectMeta: metav1.ObjectMeta{Name: "test-ingress-class"},
42+
ObjectMeta: metav1.ObjectMeta{Name: "test-ingress-class", UID: "test-ingress-class-uid"},
3843
Spec: networkingv1.IngressClassSpec{Controller: controllerName},
3944
}
4045

@@ -82,6 +87,7 @@ var _ = Describe("Node Controller", func() {
8287

8388
albSpec = albsdk.CreateLoadBalancerPayload{
8489
DisableTargetSecurityGroupAssignment: new(true),
90+
Labels: new(map[string]string{LabelIngressClassUID: "test-ingress-class-uid"}),
8591
Listeners: []albsdk.Listener{
8692
{
8793
Http: new(albsdk.ProtocolOptionsHTTP{
@@ -145,14 +151,84 @@ var _ = Describe("Node Controller", func() {
145151
It("should work with labels", func() {
146152

147153
reconciler.ALBConfig.ApplicationLoadBalancer.ExtraLabels = map[string]string{"managed-by": "alb-ingressClass"}
154+
// adding extra labels to albSpec.Labels map
155+
for k, v := range reconciler.ALBConfig.ApplicationLoadBalancer.ExtraLabels {
156+
(*albSpec.Labels)[k] = v
157+
}
148158
spec, errorEventList, err := reconciler.getAlbSpecForIngressClass(context.Background(), &ingressClass)
149159
Expect(err).To(Succeed())
150160
Expect(errorEventList).To(BeEmpty())
151161

152-
albSpec.Labels = new(map[string]string{"managed-by": "alb-ingressClass"})
162+
Expect(spec).ToNot(BeNil())
163+
Expect(*spec).To(BeEquivalentTo(albSpec))
164+
})
165+
166+
It("should work with certificates", func() {
167+
168+
mockCtrl = gomock.NewController(GinkgoT())
169+
certClient = stackitmocks.NewMockCertificatesClient(mockCtrl)
170+
171+
// Bind this mock instance to live reconciler reference context
172+
reconciler.CertificateClient = certClient
173+
174+
certSecret := corev1.Secret{
175+
ObjectMeta: metav1.ObjectMeta{
176+
Name: "my-secret-cert",
177+
UID: "dummy-secret-uid-value-1234567",
178+
},
179+
Type: corev1.SecretTypeTLS,
180+
Data: map[string][]byte{
181+
"tls.crt": []byte("mock-public-key"),
182+
"tls.key": []byte("mock-private-key"),
183+
},
184+
}
185+
Expect(k8sClient.Create(context.Background(), &certSecret)).To(Succeed())
186+
187+
actualStoredSecret := &corev1.Secret{}
188+
err := k8sClient.Get(context.Background(), client.ObjectKey{Name: "my-secret-cert"}, actualStoredSecret)
189+
Expect(err).NotTo(HaveOccurred())
190+
191+
expectedGeneratedCertName := getCertName(&ingressClass, actualStoredSecret)
192+
targetCertID := "real-certificate-uuid-abc-123"
193+
194+
mockResponse := &certsdk.GetCertificateResponse{
195+
Id: new(targetCertID),
196+
Name: new(expectedGeneratedCertName),
197+
}
198+
199+
certClient.EXPECT().
200+
CreateCertificate(
201+
gomock.Any(),
202+
"test-project",
203+
"test-region",
204+
gomock.Any(), // Intercepts any incoming *certsdk.CreateCertificatePayload matching
205+
).
206+
Return(mockResponse, nil).
207+
Times(1)
208+
209+
httpsIngress := testHttpsIngress(&ingressClass, &service)
210+
httpsIngress.Annotations = map[string]string{"alb.stackit.cloud/https-only": "true"}
211+
212+
Expect(k8sClient.Create(context.Background(), new(httpsIngress))).To(Succeed())
213+
214+
// expected albSpec should include new https listener
215+
httpListener := testHttpListener(service.Spec.Ports[0].NodePort)
216+
httpsListener := testHttpsListener(service.Spec.Ports[0].NodePort, targetCertID)
217+
albSpec.Listeners = []albsdk.Listener{
218+
httpsListener,
219+
httpListener,
220+
}
221+
222+
// get the specs and compare
223+
spec, errorEventList, err := reconciler.getAlbSpecForIngressClass(context.Background(), &ingressClass)
224+
Expect(err).To(Succeed())
225+
Expect(errorEventList).To(BeEmpty())
153226

154227
Expect(spec).ToNot(BeNil())
228+
229+
// compare
155230
Expect(*spec).To(BeEquivalentTo(albSpec))
231+
156232
})
157233

158234
It("should work with 2 ingresses different path", func() {
@@ -162,13 +238,19 @@ var _ = Describe("Node Controller", func() {
162238

163239
Expect(k8sClient.Create(context.Background(), &ingress2)).To(Succeed())
164240

165-
albSpec.Listeners[0].Http.Hosts[0].Rules = append(
166-
albSpec.Listeners[0].Http.Hosts[0].Rules,
167-
albsdk.Rule{
168-
Path: new(albsdk.Path{Prefix: new("/foobar")}),
169-
TargetPool: albSpec.Listeners[0].Http.Hosts[0].Rules[0].TargetPool,
241+
secTargetPool := *albSpec.Listeners[0].Http.Hosts[0].Rules[0].TargetPool
242+
albSpec.Listeners[0].Http.Hosts[0].Rules = []albsdk.Rule{
243+
{
244+
Path: &albsdk.Path{Prefix: new("/foobar")},
245+
TargetPool: new(secTargetPool),
246+
WebSocket: new(false),
247+
},
248+
{
249+
Path: &albsdk.Path{Prefix: new("/")},
250+
TargetPool: new(secTargetPool),
170251
WebSocket: new(false),
171-
})
252+
},
253+
}
172254

173255
spec, errorEventList, err := reconciler.getAlbSpecForIngressClass(context.Background(), &ingressClass)
174256
Expect(err).To(Succeed())
@@ -209,3 +291,90 @@ func testIngress(class *networkingv1.IngressClass, service *corev1.Service) netw
209291
},
210292
}
211293
}
294+
295+
func testHttpsIngress(class *networkingv1.IngressClass, service *corev1.Service) networkingv1.Ingress {
296+
return networkingv1.Ingress{
297+
ObjectMeta: metav1.ObjectMeta{Name: "test-https-ingress"},
298+
Spec: networkingv1.IngressSpec{
299+
IngressClassName: new(class.Name),
300+
TLS: []networkingv1.IngressTLS{
301+
{
302+
Hosts: []string{"secure.example.com"},
303+
SecretName: "my-secret-cert",
304+
},
305+
},
306+
Rules: []networkingv1.IngressRule{
307+
{
308+
Host: "secure.example.com",
309+
IngressRuleValue: networkingv1.IngressRuleValue{
310+
HTTP: &networkingv1.HTTPIngressRuleValue{
311+
Paths: []networkingv1.HTTPIngressPath{
312+
{
313+
Path: "/",
314+
PathType: new(networkingv1.PathTypePrefix),
315+
Backend: networkingv1.IngressBackend{
316+
Service: &networkingv1.IngressServiceBackend{
317+
Name: service.Name,
318+
Port: networkingv1.ServiceBackendPort{Number: service.Spec.Ports[0].Port},
319+
},
320+
},
321+
},
322+
},
323+
},
324+
},
325+
},
326+
},
327+
},
328+
}
329+
}
330+
331+
// Returns a clean, isolated Port 80 HTTP Listener structure payload
332+
func testHttpListener(nodePort int32) albsdk.Listener {
333+
return albsdk.Listener{
334+
Name: new("80-http"),
335+
Port: new(int32(80)),
336+
Protocol: new("PROTOCOL_HTTP"),
337+
Http: &albsdk.ProtocolOptionsHTTP{
338+
Hosts: []albsdk.HostConfig{
339+
{
340+
Host: new("example.com"),
341+
Rules: []albsdk.Rule{
342+
{
343+
Path: &albsdk.Path{Prefix: new("/")},
344+
TargetPool: new(fmt.Sprintf("port-%d", nodePort)),
345+
WebSocket: new(false),
346+
},
347+
},
348+
},
349+
},
350+
},
351+
}
352+
}
353+
354+
// Returns a clean, isolated Port 443 HTTPS Listener structure payload containing certificate tracking parameters
355+
func testHttpsListener(nodePort int32, certID string) albsdk.Listener {
356+
return albsdk.Listener{
357+
Name: new("443-https"),
358+
Port: new(int32(443)),
359+
Protocol: new("PROTOCOL_HTTPS"),
360+
Https: &albsdk.ProtocolOptionsHTTPS{
361+
CertificateConfig: &albsdk.CertificateConfig{
362+
CertificateIds: []string{certID},
363+
},
364+
},
365+
Http: &albsdk.ProtocolOptionsHTTP{
366+
Hosts: []albsdk.HostConfig{
367+
{
368+
Host: new("secure.example.com"),
369+
Rules: []albsdk.Rule{
370+
{
371+
Path: &albsdk.Path{Prefix: new("/")},
372+
TargetPool: new(fmt.Sprintf("port-%d", nodePort)),
373+
WebSocket: new(false),
374+
},
375+
},
376+
},
377+
},
378+
},
379+
}
380+
}

pkg/alb/ingress/certificate.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,7 @@ func (r *IngressClassReconciler) deleteAllCertsForClass(ctx context.Context, cla
2424

2525
for _, cert := range certificatesList.Items {
2626
if cert.Labels == nil {
27-
// This part will go away when Labels are supported by Cert API
28-
// do I need to check if nil
27+
continue
2928
}
3029

3130
if val, ok := (*cert.Labels)[LabelIngressClassUID]; ok && val == targetUID {

0 commit comments

Comments
 (0)