Skip to content

Commit 49b3ea1

Browse files
committed
Use new error message
1 parent 791b0ce commit 49b3ea1

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

internal/mode/static/state/graph/nginxproxy.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ func validateRewriteClientIP(npCfg *ngfAPI.NginxProxy) field.ErrorList {
208208
if len(rewriteClientIP.TrustedAddresses) > 16 {
209209
allErrs = append(
210210
allErrs,
211-
field.TooLongMaxLength(trustedAddressesPath, rewriteClientIP.TrustedAddresses, 16),
211+
field.TooMany(trustedAddressesPath, len(rewriteClientIP.TrustedAddresses), 16),
212212
)
213213
}
214214

internal/mode/static/state/graph/nginxproxy_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package graph
22

33
import (
44
"errors"
5+
"fmt"
56
"testing"
67

78
. "github.com/onsi/gomega"
@@ -551,7 +552,7 @@ func TestValidateRewriteClientIP(t *testing.T) {
551552
},
552553
},
553554
expectErrCount: 1,
554-
errorString: "spec.rewriteClientIP.trustedAddresses: Too long: may not be longer than 16",
555+
errorString: "spec.rewriteClientIP.trustedAddresses: Too many: 21: must have at most 16 items",
555556
},
556557
{
557558
name: "invalid when mode is not proxyProtocol or XForwardedFor",
@@ -621,6 +622,7 @@ func TestValidateRewriteClientIP(t *testing.T) {
621622
g := NewWithT(t)
622623

623624
allErrs := validateRewriteClientIP(test.np)
625+
fmt.Println(allErrs)
624626
g.Expect(allErrs).To(HaveLen(test.expectErrCount))
625627
if len(allErrs) > 0 {
626628
g.Expect(allErrs.ToAggregate().Error()).To(Equal(test.errorString))

0 commit comments

Comments
 (0)