Skip to content

Commit 5a0a507

Browse files
committed
bring up to speed with main, fix ZoneSyncPort test
1 parent 2e08cf6 commit 5a0a507

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

internal/configs/configmaps.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -403,15 +403,15 @@ func ParseConfigMap(ctx context.Context, cfgm *v1.ConfigMap, nginxPlus bool, has
403403
if zoneSync, exists, err := GetMapKeyAsBool(cfgm.Data, "zone-sync", cfgm); exists {
404404
if err != nil {
405405
nl.Error(l, err)
406-
eventLog.Event(cfgm, v1.EventTypeWarning, invalidValueReason, err.Error())
406+
eventLog.Event(cfgm, v1.EventTypeWarning, nl.EventReasonInvalidValue, err.Error())
407407
configOk = false
408408
} else {
409409
if nginxPlus {
410410
cfgParams.ZoneSync.EnableZoneSync = zoneSync
411411
} else {
412412
errorText := fmt.Sprintf("ConfigMap %s/%s key %s requires NGINX Plus", cfgm.Namespace, cfgm.Name, "zone-sync")
413413
nl.Warn(l, errorText)
414-
eventLog.Event(cfgm, v1.EventTypeWarning, invalidValueReason, errorText)
414+
eventLog.Event(cfgm, v1.EventTypeWarning, nl.EventReasonInvalidValue, errorText)
415415
configOk = false
416416
}
417417
}
@@ -420,22 +420,22 @@ func ParseConfigMap(ctx context.Context, cfgm *v1.ConfigMap, nginxPlus bool, has
420420
if zoneSyncPort, exists, err := GetMapKeyAsInt(cfgm.Data, "zone-sync-port", cfgm); exists {
421421
if err != nil {
422422
nl.Error(l, err)
423-
eventLog.Event(cfgm, v1.EventTypeWarning, invalidValueReason, err.Error())
423+
eventLog.Event(cfgm, v1.EventTypeWarning, nl.EventReasonInvalidValue, err.Error())
424424
configOk = false
425425
} else {
426426
if cfgParams.ZoneSync.EnableZoneSync {
427427
portValidationError := validation.ValidatePort(zoneSyncPort)
428428
if portValidationError != nil {
429429
nl.Error(l, portValidationError)
430-
eventLog.Event(cfgm, v1.EventTypeWarning, invalidValueReason, portValidationError.Error())
430+
eventLog.Event(cfgm, v1.EventTypeWarning, nl.EventReasonInvalidValue, portValidationError.Error())
431431
configOk = false
432432
} else {
433433
cfgParams.ZoneSync.Port = zoneSyncPort
434434
}
435435
} else {
436436
errorText := fmt.Sprintf("ConfigMap %s/%s key %s requires 'zone-sync' to be enabled", cfgm.Namespace, cfgm.Name, "zone-sync-port")
437437
nl.Warn(l, errorText)
438-
eventLog.Event(cfgm, v1.EventTypeWarning, invalidValueReason, errorText)
438+
eventLog.Event(cfgm, v1.EventTypeWarning, nl.EventReasonInvalidValue, errorText)
439439
configOk = false
440440
}
441441
}

internal/configs/configmaps_test.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -843,11 +843,13 @@ func TestParseZoneSyncPort(t *testing.T) {
843843
{
844844
configMap: &v1.ConfigMap{
845845
Data: map[string]string{
846+
"zone-sync": "true",
846847
"zone-sync-port": "1234",
847848
},
848849
},
849850
want: &ZoneSync{
850-
Port: 1234,
851+
EnableZoneSync: true,
852+
Port: 1234,
851853
},
852854
msg: "zone-sync-port set to 1234",
853855
},
@@ -862,7 +864,7 @@ func TestParseZoneSyncPort(t *testing.T) {
862864
t.Run(test.msg, func(t *testing.T) {
863865
result, _ := ParseConfigMap(context.Background(), test.configMap, nginxPlus, hasAppProtect, hasAppProtectDos, hasTLSPassthrough, makeEventLogger())
864866
if result.ZoneSync.Port != test.want.Port {
865-
t.Errorf("Port: want %v, got %v", test.want.Port, result.ZoneSync.EnableZoneSync)
867+
t.Errorf("Port: want %v, got %v", test.want.Port, result.ZoneSync.Port)
866868
}
867869
})
868870
}

0 commit comments

Comments
 (0)