Skip to content

Commit e568e2a

Browse files
committed
Replacing fmt.Sprintln with plain strings
1 parent 2f86450 commit e568e2a

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

apis/v1beta1/validation/gateway.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ func ValidateTLSCertificateRefs(listeners []gatewayv1b1.Listener, path *field.Pa
121121
for i, c := range listeners {
122122
if isProtocolInSubset(c.Protocol, protocolsTLSRequired) && c.TLS != nil {
123123
if *c.TLS.Mode == gatewayv1b1.TLSModeTerminate && len(c.TLS.CertificateRefs) == 0 {
124-
errs = append(errs, field.Forbidden(path.Index(i).Child("tls").Child("certificateRefs"), fmt.Sprintln("should be set and not empty when TLSModeType is Terminate")))
124+
errs = append(errs, field.Forbidden(path.Index(i).Child("tls").Child("certificateRefs"), "should be set and not empty when TLSModeType is Terminate"))
125125
}
126126
}
127127
}
@@ -135,7 +135,7 @@ func ValidateListenerNames(listeners []gatewayv1b1.Listener, path *field.Path) f
135135
nameMap := make(map[gatewayv1b1.SectionName]struct{}, len(listeners))
136136
for i, c := range listeners {
137137
if _, found := nameMap[c.Name]; found {
138-
errs = append(errs, field.Duplicate(path.Index(i).Child("name"), fmt.Sprintln("must be unique within the Gateway")))
138+
errs = append(errs, field.Duplicate(path.Index(i).Child("name"), "must be unique within the Gateway"))
139139
}
140140
nameMap[c.Name] = struct{}{}
141141
}
@@ -156,7 +156,7 @@ func validateHostnameProtocolPort(listeners []gatewayv1b1.Listener, path *field.
156156
port := listener.Port
157157
hostnameProtocolPort := fmt.Sprintf("%s:%s:%d", *hostname, protocol, port)
158158
if hostnameProtocolPortSets.Has(hostnameProtocolPort) {
159-
errs = append(errs, field.Duplicate(path.Index(i), fmt.Sprintln("combination of port, protocol, and hostname must be unique for each listener")))
159+
errs = append(errs, field.Duplicate(path.Index(i), "combination of port, protocol, and hostname must be unique for each listener"))
160160
} else {
161161
hostnameProtocolPortSets.Insert(hostnameProtocolPort)
162162
}
@@ -173,7 +173,7 @@ func validateGatewayAddresses(addresses []gatewayv1b1.GatewayAddress, path *fiel
173173
if address.Type != nil {
174174
if *address.Type == gatewayv1b1.IPAddressType {
175175
if _, err := netip.ParseAddr(address.Value); err != nil {
176-
errs = append(errs, field.Invalid(path.Index(i), address.Value, fmt.Sprintln("invalid ip address")))
176+
errs = append(errs, field.Invalid(path.Index(i), address.Value, "invalid ip address"))
177177
}
178178
if ipAddrSet.Has(address.Value) {
179179
errs = append(errs, field.Duplicate(path.Index(i), address.Value))

apis/v1beta1/validation/gateway_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ func TestValidateGateway(t *testing.T) {
169169
{
170170
Type: field.ErrorTypeForbidden,
171171
Field: "spec.listeners[0].tls.certificateRefs",
172-
Detail: "should be set and not empty when TLSModeType is Terminate\n",
172+
Detail: "should be set and not empty when TLSModeType is Terminate",
173173
BadValue: "",
174174
},
175175
},
@@ -187,7 +187,7 @@ func TestValidateGateway(t *testing.T) {
187187
{
188188
Type: field.ErrorTypeForbidden,
189189
Field: "spec.listeners[0].tls.certificateRefs",
190-
Detail: "should be set and not empty when TLSModeType is Terminate\n",
190+
Detail: "should be set and not empty when TLSModeType is Terminate",
191191
BadValue: "",
192192
},
193193
},
@@ -209,7 +209,7 @@ func TestValidateGateway(t *testing.T) {
209209
{
210210
Type: field.ErrorTypeDuplicate,
211211
Field: "spec.listeners[1].name",
212-
BadValue: "must be unique within the Gateway\n",
212+
BadValue: "must be unique within the Gateway",
213213
},
214214
},
215215
},
@@ -233,7 +233,7 @@ func TestValidateGateway(t *testing.T) {
233233
{
234234
Type: field.ErrorTypeDuplicate,
235235
Field: "spec.listeners[1]",
236-
BadValue: "combination of port, protocol, and hostname must be unique for each listener\n",
236+
BadValue: "combination of port, protocol, and hostname must be unique for each listener",
237237
},
238238
},
239239
},
@@ -254,7 +254,7 @@ func TestValidateGateway(t *testing.T) {
254254
{
255255
Type: field.ErrorTypeDuplicate,
256256
Field: "spec.listeners[1]",
257-
BadValue: "combination of port, protocol, and hostname must be unique for each listener\n",
257+
BadValue: "combination of port, protocol, and hostname must be unique for each listener",
258258
},
259259
},
260260
},
@@ -363,7 +363,7 @@ func TestValidateGateway(t *testing.T) {
363363
{
364364
Type: field.ErrorTypeInvalid,
365365
Field: "spec.addresses[0]",
366-
Detail: "invalid ip address\n",
366+
Detail: "invalid ip address",
367367
BadValue: "1.2.3.4:8080",
368368
},
369369
{

0 commit comments

Comments
 (0)