mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-31 15:25:57 +00:00
Merge pull request #121307 from cici37/celUpdate
Add cel new validator into Kubernetes
This commit is contained in:
commit
16fc00493b
@ -275,7 +275,7 @@ func TestValidationExpressions(t *testing.T) {
|
||||
},
|
||||
errors: map[string]string{
|
||||
// Invalid regex with a string constant regex pattern is compile time error
|
||||
"self.val1.matches(')')": "compile error: program instantiation failed: error parsing regexp: unexpected ): `)`",
|
||||
"self.val1.matches(')')": "compile error: compilation failed: ERROR: <input>:1:19: invalid matches argument",
|
||||
},
|
||||
},
|
||||
{name: "escaped strings",
|
||||
@ -320,6 +320,11 @@ func TestValidationExpressions(t *testing.T) {
|
||||
"self.val1.getMilliseconds() == 3723004",
|
||||
"type(self.val1) == google.protobuf.Duration",
|
||||
},
|
||||
errors: map[string]string{
|
||||
"duration('1')": "invalid duration argument",
|
||||
"duration('1d')": "invalid duration argument",
|
||||
"duration('1us') < duration('1nns')": "invalid duration argument",
|
||||
},
|
||||
},
|
||||
{name: "date format",
|
||||
obj: objs("1997-07-16", "1997-07-16"),
|
||||
@ -348,6 +353,11 @@ func TestValidationExpressions(t *testing.T) {
|
||||
"self.val1.getHours('UTC') == 18", // TZ in string is 1hr off of UTC
|
||||
"type(self.val1) == google.protobuf.Timestamp",
|
||||
},
|
||||
errors: map[string]string{
|
||||
"timestamp('1000-00-00T00:00:00Z')": "invalid timestamp",
|
||||
"timestamp('1000-01-01T00:00:00ZZ')": "invalid timestamp",
|
||||
"timestamp(-62135596801)": "invalid timestamp",
|
||||
},
|
||||
},
|
||||
{name: "enums",
|
||||
obj: map[string]interface{}{"enumStr": "Pending"},
|
||||
@ -1748,6 +1758,7 @@ func TestValidationExpressions(t *testing.T) {
|
||||
"self.str.find(')') == ''": "compile error: program instantiation failed: error parsing regexp: unexpected ): `)`",
|
||||
"self.str.findAll(')') == []": "compile error: program instantiation failed: error parsing regexp: unexpected ): `)`",
|
||||
"self.str.findAll(')', 1) == []": "compile error: program instantiation failed: error parsing regexp: unexpected ): `)`",
|
||||
"self.str.matches('x++')": "invalid matches argument",
|
||||
},
|
||||
},
|
||||
{name: "URL parsing",
|
||||
|
@ -80,7 +80,18 @@ var baseOpts = []VersionedOptions{
|
||||
library.Quantity(),
|
||||
},
|
||||
},
|
||||
|
||||
// add the new validator in 1.29
|
||||
{
|
||||
IntroducedVersion: version.MajorMinor(1, 29),
|
||||
EnvOptions: []cel.EnvOption{
|
||||
cel.ASTValidators(
|
||||
cel.ValidateDurationLiterals(),
|
||||
cel.ValidateTimestampLiterals(),
|
||||
cel.ValidateRegexLiterals(),
|
||||
cel.ValidateHomogeneousAggregateLiterals(),
|
||||
),
|
||||
},
|
||||
},
|
||||
// String library
|
||||
{
|
||||
IntroducedVersion: version.MajorMinor(1, 0),
|
||||
|
Loading…
Reference in New Issue
Block a user