dra api: implement semver attribute value type

This adds support for semantic version comparison to the CEL support in the
"named resources" structured parameter model. For example, it can be used to
check that an instance supports a certain API level.

To minimize the risk, the new "semver" type is only defined in the CEL
environment for DRA expressions, not in the base library. See
https://github.com/kubernetes/kubernetes/pull/123664 for a PR which
adds it to the base library.

Validation of semver strings is done with the regular expression from
semver.org. The actual evaluation at runtime then uses semver/v4.

Kubernetes-commit: 42ee56f093133402ed860d4c5f54b049041386c9
This commit is contained in:
Patrick Ohly
2024-03-04 09:13:19 +01:00
committed by Kubernetes Publisher
parent 95cf817801
commit 4c32855540
3 changed files with 20 additions and 0 deletions

View File

@@ -12022,6 +12022,9 @@ var schemaYAML = typed.YAMLObject(`types:
- name: stringSlice
type:
namedType: io.k8s.api.resource.v1alpha2.NamedResourcesStringSlice
- name: version
type:
scalar: string
- name: io.k8s.api.resource.v1alpha2.NamedResourcesFilter
map:
fields:

View File

@@ -90,3 +90,11 @@ func (b *NamedResourcesAttributeApplyConfiguration) WithStringSliceValue(value *
b.StringSliceValue = value
return b
}
// WithVersionValue sets the VersionValue field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the VersionValue field is set to the value of the last call.
func (b *NamedResourcesAttributeApplyConfiguration) WithVersionValue(value string) *NamedResourcesAttributeApplyConfiguration {
b.VersionValue = &value
return b
}

View File

@@ -31,6 +31,7 @@ type NamedResourcesAttributeValueApplyConfiguration struct {
IntSliceValue *NamedResourcesIntSliceApplyConfiguration `json:"intSlice,omitempty"`
StringValue *string `json:"string,omitempty"`
StringSliceValue *NamedResourcesStringSliceApplyConfiguration `json:"stringSlice,omitempty"`
VersionValue *string `json:"version,omitempty"`
}
// NamedResourcesAttributeValueApplyConfiguration constructs an declarative configuration of the NamedResourcesAttributeValue type for use with
@@ -86,3 +87,11 @@ func (b *NamedResourcesAttributeValueApplyConfiguration) WithStringSliceValue(va
b.StringSliceValue = value
return b
}
// WithVersionValue sets the VersionValue field in the declarative configuration to the given value
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
// If called multiple times, the VersionValue field is set to the value of the last call.
func (b *NamedResourcesAttributeValueApplyConfiguration) WithVersionValue(value string) *NamedResourcesAttributeValueApplyConfiguration {
b.VersionValue = &value
return b
}