mirror of
https://github.com/kubernetes/client-go.git
synced 2025-08-25 10:18:54 +00:00
DRA API: use DeviceCapacity struct instead of plain Quantity
This enables a future extension where capacity of a single device gets consumed by different claims. The semantic without any additional fields is the same as before: a capacity cannot be split up and is only an attribute of a device. Because its semantically the same as before, two-way conversion to v1alpha3 is possible. Kubernetes-commit: 81fd64256c9cfca47385997e06a694bf98bfb799
This commit is contained in:
parent
98e4506ad9
commit
f65974c297
@ -12754,7 +12754,7 @@ var schemaYAML = typed.YAMLObject(`types:
|
||||
type:
|
||||
map:
|
||||
elementType:
|
||||
namedType: io.k8s.apimachinery.pkg.api.resource.Quantity
|
||||
namedType: io.k8s.api.resource.v1beta1.DeviceCapacity
|
||||
- name: io.k8s.api.resource.v1beta1.CELDeviceSelector
|
||||
map:
|
||||
fields:
|
||||
@ -12818,6 +12818,12 @@ var schemaYAML = typed.YAMLObject(`types:
|
||||
- name: version
|
||||
type:
|
||||
scalar: string
|
||||
- name: io.k8s.api.resource.v1beta1.DeviceCapacity
|
||||
map:
|
||||
fields:
|
||||
- name: quantity
|
||||
type:
|
||||
namedType: io.k8s.apimachinery.pkg.api.resource.Quantity
|
||||
- name: io.k8s.api.resource.v1beta1.DeviceClaim
|
||||
map:
|
||||
fields:
|
||||
|
@ -20,14 +20,13 @@ package v1beta1
|
||||
|
||||
import (
|
||||
resourcev1beta1 "k8s.io/api/resource/v1beta1"
|
||||
resource "k8s.io/apimachinery/pkg/api/resource"
|
||||
)
|
||||
|
||||
// BasicDeviceApplyConfiguration represents a declarative configuration of the BasicDevice type for use
|
||||
// with apply.
|
||||
type BasicDeviceApplyConfiguration struct {
|
||||
Attributes map[resourcev1beta1.QualifiedName]DeviceAttributeApplyConfiguration `json:"attributes,omitempty"`
|
||||
Capacity map[resourcev1beta1.QualifiedName]resource.Quantity `json:"capacity,omitempty"`
|
||||
Capacity map[resourcev1beta1.QualifiedName]DeviceCapacityApplyConfiguration `json:"capacity,omitempty"`
|
||||
}
|
||||
|
||||
// BasicDeviceApplyConfiguration constructs a declarative configuration of the BasicDevice type for use with
|
||||
@ -54,9 +53,9 @@ func (b *BasicDeviceApplyConfiguration) WithAttributes(entries map[resourcev1bet
|
||||
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
|
||||
// If called multiple times, the entries provided by each call will be put on the Capacity field,
|
||||
// overwriting an existing map entries in Capacity field with the same key.
|
||||
func (b *BasicDeviceApplyConfiguration) WithCapacity(entries map[resourcev1beta1.QualifiedName]resource.Quantity) *BasicDeviceApplyConfiguration {
|
||||
func (b *BasicDeviceApplyConfiguration) WithCapacity(entries map[resourcev1beta1.QualifiedName]DeviceCapacityApplyConfiguration) *BasicDeviceApplyConfiguration {
|
||||
if b.Capacity == nil && len(entries) > 0 {
|
||||
b.Capacity = make(map[resourcev1beta1.QualifiedName]resource.Quantity, len(entries))
|
||||
b.Capacity = make(map[resourcev1beta1.QualifiedName]DeviceCapacityApplyConfiguration, len(entries))
|
||||
}
|
||||
for k, v := range entries {
|
||||
b.Capacity[k] = v
|
||||
|
43
applyconfigurations/resource/v1beta1/devicecapacity.go
Normal file
43
applyconfigurations/resource/v1beta1/devicecapacity.go
Normal file
@ -0,0 +1,43 @@
|
||||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by applyconfiguration-gen. DO NOT EDIT.
|
||||
|
||||
package v1beta1
|
||||
|
||||
import (
|
||||
resource "k8s.io/apimachinery/pkg/api/resource"
|
||||
)
|
||||
|
||||
// DeviceCapacityApplyConfiguration represents a declarative configuration of the DeviceCapacity type for use
|
||||
// with apply.
|
||||
type DeviceCapacityApplyConfiguration struct {
|
||||
Quantity *resource.Quantity `json:"quantity,omitempty"`
|
||||
}
|
||||
|
||||
// DeviceCapacityApplyConfiguration constructs a declarative configuration of the DeviceCapacity type for use with
|
||||
// apply.
|
||||
func DeviceCapacity() *DeviceCapacityApplyConfiguration {
|
||||
return &DeviceCapacityApplyConfiguration{}
|
||||
}
|
||||
|
||||
// WithQuantity sets the Quantity 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 Quantity field is set to the value of the last call.
|
||||
func (b *DeviceCapacityApplyConfiguration) WithQuantity(value resource.Quantity) *DeviceCapacityApplyConfiguration {
|
||||
b.Quantity = &value
|
||||
return b
|
||||
}
|
@ -1652,6 +1652,8 @@ func ForKind(kind schema.GroupVersionKind) interface{} {
|
||||
return &applyconfigurationsresourcev1beta1.DeviceAllocationResultApplyConfiguration{}
|
||||
case resourcev1beta1.SchemeGroupVersion.WithKind("DeviceAttribute"):
|
||||
return &applyconfigurationsresourcev1beta1.DeviceAttributeApplyConfiguration{}
|
||||
case resourcev1beta1.SchemeGroupVersion.WithKind("DeviceCapacity"):
|
||||
return &applyconfigurationsresourcev1beta1.DeviceCapacityApplyConfiguration{}
|
||||
case resourcev1beta1.SchemeGroupVersion.WithKind("DeviceClaim"):
|
||||
return &applyconfigurationsresourcev1beta1.DeviceClaimApplyConfiguration{}
|
||||
case resourcev1beta1.SchemeGroupVersion.WithKind("DeviceClaimConfiguration"):
|
||||
|
Loading…
Reference in New Issue
Block a user