From 2d810ddfa9c8ee55ebdb001f78b832169204fc79 Mon Sep 17 00:00:00 2001 From: Joe Betz Date: Mon, 10 Mar 2025 18:56:54 -0400 Subject: [PATCH] Apply feedback --- .../apiserver/pkg/cel/library/semverlib.go | 10 +++++----- .../dynamic-resource-allocation/cel/compile.go | 18 ++++++++++++++++-- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/staging/src/k8s.io/apiserver/pkg/cel/library/semverlib.go b/staging/src/k8s.io/apiserver/pkg/cel/library/semverlib.go index 367e0ac8300..93614f849a3 100644 --- a/staging/src/k8s.io/apiserver/pkg/cel/library/semverlib.go +++ b/staging/src/k8s.io/apiserver/pkg/cel/library/semverlib.go @@ -48,8 +48,8 @@ import ( // semver('Three') // error // semver('Mi') // error // semver('v1.0.0', true) // Applies normalization to remove the leading "v". Returns a Semver of "1.0.0". -// semver('1.0') // Applies normalization to add the missing patch version. Returns a Semver of "1.0.0" -// semver('01.01.01') // Applies normalization to remove leading zeros. Returns a Semver of "1.1.1" +// semver('1.0', true) // Applies normalization to add the missing patch version. Returns a Semver of "1.0.0" +// semver('01.01.01', true) // Applies normalization to remove leading zeros. Returns a Semver of "1.1.1" // // isSemver // @@ -66,9 +66,9 @@ import ( // isSemver('1.0.0') // returns true // isSemver('hello') // returns false // isSemver('v1.0') // returns false (leading "v" is not allowed unless normalization is enabled) -// isSemver('v1.0') // Applies normalization to remove leading "v". returns true -// semver('1.0') // Applies normalization to add the missing patch version. Returns true -// semver('01.01.01') // Applies normalization to remove leading zeros. Returns true +// isSemver('v1.0', true) // Applies normalization to remove leading "v". returns true +// semver('1.0', true) // Applies normalization to add the missing patch version. Returns true +// semver('01.01.01', true) // Applies normalization to remove leading zeros. Returns true // // Conversion to Scalars: // diff --git a/staging/src/k8s.io/dynamic-resource-allocation/cel/compile.go b/staging/src/k8s.io/dynamic-resource-allocation/cel/compile.go index 278a85e0d9d..3c3b1265b13 100644 --- a/staging/src/k8s.io/dynamic-resource-allocation/cel/compile.go +++ b/staging/src/k8s.io/dynamic-resource-allocation/cel/compile.go @@ -298,8 +298,6 @@ func newCompiler() *compiler { EnvOptions: []cel.EnvOption{ cel.Variable(deviceVar, deviceType.CelType()), - library.SemverLib(library.SemverVersion(0)), - // https://pkg.go.dev/github.com/google/cel-go/ext#Bindings // // This is useful to simplify attribute lookups because the @@ -312,6 +310,22 @@ func newCompiler() *compiler { deviceType, }, }, + { + IntroducedVersion: version.MajorMinor(1, 31), + // This library has added to base environment of Kubernetes + // in 1.33 at version 1. It will continue to be available for + // use in this environment, but does not need to be included + // directly since it becomes available indirectly via the base + // environment shared across Kubernetes. + // In Kubernetes 1.34, version 1 feature of this library will + // become available, and will be rollback safe to 1.33. + // TODO: In Kubernetes 1.34: Add compile tests that demonstrate that + // `isSemver("v1.0.0", true)` and `semver("v1.0.0", true)` are supported. + RemovedVersion: version.MajorMinor(1, 33), + EnvOptions: []cel.EnvOption{ + library.SemverLib(library.SemverVersion(0)), + }, + }, } envset, err := envset.Extend(versioned...) if err != nil {