Skip to content

Commit b0f17c2

Browse files
committed
apiserver/pkg/apis/config/validation: Add invalidURLErrFmt
In go1.14, the following change to 'net/url' was made: "When parsing of a URL fails (for example by Parse or ParseRequestURI), the resulting Error message will now quote the unparsable URL. This provides clearer structure and consistency with other parsing errors." Here we add a new const, 'invalidURLErrFmt' to properly handle the now quoted string in validation_test.go. ref: https://golang.org/doc/go1.14#net/url Signed-off-by: Stephen Augustus <[email protected]>
1 parent 236ef23 commit b0f17c2

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

staging/src/k8s.io/apiserver/pkg/apis/config/validation/validation.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const (
3131
keyLenErrFmt = "secret is not of the expected length, got %d, expected one of %v"
3232
unsupportedSchemeErrFmt = "unsupported scheme %q for KMS provider, only unix is supported"
3333
atLeastOneRequiredErrFmt = "at least one %s is required"
34+
invalidURLErrFmt = "invalid endpoint for kms provider, error: parse %s: net/url: invalid control character in URL"
3435
mandatoryFieldErrFmt = "%s is a mandatory field for a %s"
3536
base64EncodingErr = "secrets must be base64 encoded"
3637
zeroOrNegativeErrFmt = "%s should be a positive value"

staging/src/k8s.io/apiserver/pkg/apis/config/validation/validation_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ func TestKMSEndpoint(t *testing.T) {
296296
desc: "invalid url",
297297
in: &config.KMSConfiguration{Endpoint: "unix:///foo\n.socket"},
298298
want: field.ErrorList{
299-
field.Invalid(endpointField, "unix:///foo\n.socket", "invalid endpoint for kms provider, error: parse unix:///foo\n.socket: net/url: invalid control character in URL"),
299+
field.Invalid(endpointField, "unix:///foo\n.socket", fmt.Sprintf(invalidURLErrFmt, `"unix:///foo\n.socket"`)),
300300
},
301301
},
302302
}

0 commit comments

Comments
 (0)