Skip to content

Commit e4b6446

Browse files
authored
Implement NKG-specific field validation for Gateway resource (#407)
Implement NKG-specific field validation for Gateway resource Fixes #406
1 parent eb9fea2 commit e4b6446

19 files changed

+957
-571
lines changed

internal/state/change_processor_test.go

Lines changed: 36 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -286,12 +286,18 @@ var _ = Describe("ChangeProcessor", func() {
286286
ObservedGeneration: gw1.Generation,
287287
ListenerStatuses: map[string]state.ListenerStatus{
288288
"listener-80-1": {
289-
Valid: false,
290289
AttachedRoutes: 1,
290+
Conditions: append(
291+
conditions.NewDefaultListenerConditions(),
292+
conditions.NewTODO("GatewayClass is invalid or doesn't exist"),
293+
),
291294
},
292295
"listener-443-1": {
293-
Valid: false,
294296
AttachedRoutes: 1,
297+
Conditions: append(
298+
conditions.NewDefaultListenerConditions(),
299+
conditions.NewTODO("GatewayClass is invalid or doesn't exist"),
300+
),
295301
},
296302
},
297303
},
@@ -303,13 +309,13 @@ var _ = Describe("ChangeProcessor", func() {
303309
"listener-80-1": {
304310
Conditions: append(
305311
conditions.NewDefaultRouteConditions(),
306-
conditions.NewRouteTODO("GatewayClass is invalid or doesn't exist"),
312+
conditions.NewTODO("GatewayClass is invalid or doesn't exist"),
307313
),
308314
},
309315
"listener-443-1": {
310316
Conditions: append(
311317
conditions.NewDefaultRouteConditions(),
312-
conditions.NewRouteTODO("GatewayClass is invalid or doesn't exist"),
318+
conditions.NewTODO("GatewayClass is invalid or doesn't exist"),
313319
),
314320
},
315321
},
@@ -391,12 +397,12 @@ var _ = Describe("ChangeProcessor", func() {
391397
ObservedGeneration: gw1.Generation,
392398
ListenerStatuses: map[string]state.ListenerStatus{
393399
"listener-80-1": {
394-
Valid: true,
395400
AttachedRoutes: 1,
401+
Conditions: conditions.NewDefaultListenerConditions(),
396402
},
397403
"listener-443-1": {
398-
Valid: true,
399404
AttachedRoutes: 1,
405+
Conditions: conditions.NewDefaultListenerConditions(),
400406
},
401407
},
402408
},
@@ -500,12 +506,12 @@ var _ = Describe("ChangeProcessor", func() {
500506
ObservedGeneration: gw1.Generation,
501507
ListenerStatuses: map[string]state.ListenerStatus{
502508
"listener-80-1": {
503-
Valid: true,
504509
AttachedRoutes: 1,
510+
Conditions: conditions.NewDefaultListenerConditions(),
505511
},
506512
"listener-443-1": {
507-
Valid: true,
508513
AttachedRoutes: 1,
514+
Conditions: conditions.NewDefaultListenerConditions(),
509515
},
510516
},
511517
},
@@ -610,12 +616,12 @@ var _ = Describe("ChangeProcessor", func() {
610616
ObservedGeneration: gw1Updated.Generation,
611617
ListenerStatuses: map[string]state.ListenerStatus{
612618
"listener-80-1": {
613-
Valid: true,
614619
AttachedRoutes: 1,
620+
Conditions: conditions.NewDefaultListenerConditions(),
615621
},
616622
"listener-443-1": {
617-
Valid: true,
618623
AttachedRoutes: 1,
624+
Conditions: conditions.NewDefaultListenerConditions(),
619625
},
620626
},
621627
},
@@ -719,12 +725,12 @@ var _ = Describe("ChangeProcessor", func() {
719725
ObservedGeneration: gw1Updated.Generation,
720726
ListenerStatuses: map[string]state.ListenerStatus{
721727
"listener-80-1": {
722-
Valid: true,
723728
AttachedRoutes: 1,
729+
Conditions: conditions.NewDefaultListenerConditions(),
724730
},
725731
"listener-443-1": {
726-
Valid: true,
727732
AttachedRoutes: 1,
733+
Conditions: conditions.NewDefaultListenerConditions(),
728734
},
729735
},
730736
},
@@ -827,12 +833,12 @@ var _ = Describe("ChangeProcessor", func() {
827833
ObservedGeneration: gw1Updated.Generation,
828834
ListenerStatuses: map[string]state.ListenerStatus{
829835
"listener-80-1": {
830-
Valid: true,
831836
AttachedRoutes: 1,
837+
Conditions: conditions.NewDefaultListenerConditions(),
832838
},
833839
"listener-443-1": {
834-
Valid: true,
835840
AttachedRoutes: 1,
841+
Conditions: conditions.NewDefaultListenerConditions(),
836842
},
837843
},
838844
},
@@ -928,12 +934,12 @@ var _ = Describe("ChangeProcessor", func() {
928934
ObservedGeneration: gw1Updated.Generation,
929935
ListenerStatuses: map[string]state.ListenerStatus{
930936
"listener-80-1": {
931-
Valid: true,
932937
AttachedRoutes: 1,
938+
Conditions: conditions.NewDefaultListenerConditions(),
933939
},
934940
"listener-443-1": {
935-
Valid: true,
936941
AttachedRoutes: 1,
942+
Conditions: conditions.NewDefaultListenerConditions(),
937943
},
938944
},
939945
},
@@ -960,13 +966,13 @@ var _ = Describe("ChangeProcessor", func() {
960966
"listener-80-1": {
961967
Conditions: append(
962968
conditions.NewDefaultRouteConditions(),
963-
conditions.NewRouteTODO("Gateway is ignored"),
969+
conditions.NewTODO("Gateway is ignored"),
964970
),
965971
},
966972
"listener-443-1": {
967973
Conditions: append(
968974
conditions.NewDefaultRouteConditions(),
969-
conditions.NewRouteTODO("Gateway is ignored"),
975+
conditions.NewTODO("Gateway is ignored"),
970976
),
971977
},
972978
},
@@ -1049,12 +1055,12 @@ var _ = Describe("ChangeProcessor", func() {
10491055
ObservedGeneration: gw2.Generation,
10501056
ListenerStatuses: map[string]state.ListenerStatus{
10511057
"listener-80-1": {
1052-
Valid: true,
10531058
AttachedRoutes: 1,
1059+
Conditions: conditions.NewDefaultListenerConditions(),
10541060
},
10551061
"listener-443-1": {
1056-
Valid: true,
10571062
AttachedRoutes: 1,
1063+
Conditions: conditions.NewDefaultListenerConditions(),
10581064
},
10591065
},
10601066
},
@@ -1113,12 +1119,12 @@ var _ = Describe("ChangeProcessor", func() {
11131119
ObservedGeneration: gw2.Generation,
11141120
ListenerStatuses: map[string]state.ListenerStatus{
11151121
"listener-80-1": {
1116-
Valid: true,
11171122
AttachedRoutes: 0,
1123+
Conditions: conditions.NewDefaultListenerConditions(),
11181124
},
11191125
"listener-443-1": {
1120-
Valid: true,
11211126
AttachedRoutes: 0,
1127+
Conditions: conditions.NewDefaultListenerConditions(),
11221128
},
11231129
},
11241130
},
@@ -1146,12 +1152,18 @@ var _ = Describe("ChangeProcessor", func() {
11461152
ObservedGeneration: gw2.Generation,
11471153
ListenerStatuses: map[string]state.ListenerStatus{
11481154
"listener-80-1": {
1149-
Valid: false,
11501155
AttachedRoutes: 0,
1156+
Conditions: append(
1157+
conditions.NewDefaultListenerConditions(),
1158+
conditions.NewTODO("GatewayClass is invalid or doesn't exist"),
1159+
),
11511160
},
11521161
"listener-443-1": {
1153-
Valid: false,
11541162
AttachedRoutes: 0,
1163+
Conditions: append(
1164+
conditions.NewDefaultListenerConditions(),
1165+
conditions.NewTODO("GatewayClass is invalid or doesn't exist"),
1166+
),
11551167
},
11561168
},
11571169
},

0 commit comments

Comments
 (0)