mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-11 04:52:08 +00:00
dra api: enable new CEL features by faking their version
There are two approaches for making new versioned CEL features available in the release where they get introduced: - Always use the environment for "StoredExpressions". - Use an older version (typically 1.0) and only bump it up later. The second approach was used before, so this is now also done here.
This commit is contained in:
parent
7f5566ac6f
commit
6a361e1f36
@ -149,16 +149,10 @@ func validateSelector(opts Options, selector string, fldPath *field.Path) field.
|
|||||||
if selector == "" {
|
if selector == "" {
|
||||||
allErrs = append(allErrs, field.Required(fldPath, ""))
|
allErrs = append(allErrs, field.Required(fldPath, ""))
|
||||||
} else {
|
} else {
|
||||||
// TODO (https://github.com/kubernetes/kubernetes/issues/123687):
|
envType := environment.NewExpressions
|
||||||
// when this API gets promoted to beta, we have to
|
if opts.StoredExpressions {
|
||||||
// validate new and stored expressions differently.
|
envType = environment.StoredExpressions
|
||||||
// While it is alpha, new expressions are allowed to
|
}
|
||||||
// use everything that is currently available.
|
|
||||||
// envType := environment.NewExpressions
|
|
||||||
// if opts.StoredExpressions {
|
|
||||||
// envType = environment.StoredExpressions
|
|
||||||
// }
|
|
||||||
envType := environment.StoredExpressions
|
|
||||||
result := namedresourcescel.Compiler.CompileCELExpression(selector, envType)
|
result := namedresourcescel.Compiler.CompileCELExpression(selector, envType)
|
||||||
if result.Error != nil {
|
if result.Error != nil {
|
||||||
allErrs = append(allErrs, convertCELErrorToValidationError(fldPath, selector, result.Error))
|
allErrs = append(allErrs, convertCELErrorToValidationError(fldPath, selector, result.Error))
|
||||||
|
@ -187,7 +187,12 @@ func mustBuildEnv() *environment.EnvSet {
|
|||||||
envset := environment.MustBaseEnvSet(environment.DefaultCompatibilityVersion())
|
envset := environment.MustBaseEnvSet(environment.DefaultCompatibilityVersion())
|
||||||
versioned := []environment.VersionedOptions{
|
versioned := []environment.VersionedOptions{
|
||||||
{
|
{
|
||||||
IntroducedVersion: version.MajorMinor(1, 30),
|
// Feature epoch was actually 1.30, but we artificially set it to 1.0 because these
|
||||||
|
// options should always be present.
|
||||||
|
//
|
||||||
|
// TODO (https://github.com/kubernetes/kubernetes/issues/123687): set this
|
||||||
|
// version properly before going to beta.
|
||||||
|
IntroducedVersion: version.MajorMinor(1, 0),
|
||||||
EnvOptions: append(buildVersionedAttributes(),
|
EnvOptions: append(buildVersionedAttributes(),
|
||||||
SemverLib(),
|
SemverLib(),
|
||||||
),
|
),
|
||||||
|
Loading…
Reference in New Issue
Block a user