| 1 |
/* |
| 2 |
Copyright 2022 The Kubernetes Authors. |
| 3 |
|
| 4 |
Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 |
you may not use this file except in compliance with the License. |
| 6 |
You may obtain a copy of the License at |
| 7 |
|
| 8 |
http://www.apache.org/licenses/LICENSE-2.0 |
| 9 |
|
| 10 |
Unless required by applicable law or agreed to in writing, software |
| 11 |
distributed under the License is distributed on an "AS IS" BASIS, |
| 12 |
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 |
See the License for the specific language governing permissions and |
| 14 |
limitations under the License. |
| 15 |
*/ |
| 16 |
|
| 17 |
package cel |
| 18 |
|
| 19 |
import celconfig "k8s.io/apiserver/pkg/apis/cel" |
| 20 |
|
| 21 |
const ( |
| 22 |
// DefaultMaxRequestSizeBytes is the size of the largest request that will be accepted |
| 23 |
DefaultMaxRequestSizeBytes = celconfig.MaxRequestSizeBytes |
| 24 |
|
| 25 |
// MaxDurationSizeJSON |
| 26 |
// OpenAPI duration strings follow RFC 3339, section 5.6 - see the comment on maxDatetimeSizeJSON |
| 27 |
MaxDurationSizeJSON = 32 |
| 28 |
// MaxDatetimeSizeJSON |
| 29 |
// OpenAPI datetime strings follow RFC 3339, section 5.6, and the longest possible |
| 30 |
// such string is 9999-12-31T23:59:59.999999999Z, which has length 30 - we add 2 |
| 31 |
// to allow for quotation marks |
| 32 |
MaxDatetimeSizeJSON = 32 |
| 33 |
// MinDurationSizeJSON |
| 34 |
// Golang allows a string of 0 to be parsed as a duration, so that plus 2 to account for |
| 35 |
// quotation marks makes 3 |
| 36 |
MinDurationSizeJSON = 3 |
| 37 |
// JSONDateSize is the size of a date serialized as part of a JSON object |
| 38 |
// RFC 3339 dates require YYYY-MM-DD, and then we add 2 to allow for quotation marks |
| 39 |
JSONDateSize = 12 |
| 40 |
// MinDatetimeSizeJSON is the minimal length of a datetime formatted as RFC 3339 |
| 41 |
// RFC 3339 datetimes require a full date (YYYY-MM-DD) and full time (HH:MM:SS), and we add 3 for |
| 42 |
// quotation marks like always in addition to the capital T that separates the date and time |
| 43 |
MinDatetimeSizeJSON = 21 |
| 44 |
// MinStringSize is the size of literal "" |
| 45 |
MinStringSize = 2 |
| 46 |
// MinBoolSize is the length of literal true |
| 47 |
MinBoolSize = 4 |
| 48 |
// MinNumberSize is the length of literal 0 |
| 49 |
MinNumberSize = 1 |
| 50 |
|
| 51 |
// MaxFormatSize is the maximum size we allow for format strings |
| 52 |
MaxFormatSize = 64 |
| 53 |
MaxNameFormatRegexSize = 128 |
| 54 |
) |