dra api: add structured parameters

NodeResourceSlice will be used by kubelet to publish resource information on
behalf of DRA drivers on the node. NodeName and DriverName in
NodeResourceSlice must be immutable. This simplifies tracking the different
objects because what they are for cannot change after creation.

The new field in ResourceClass tells scheduler and autoscaler that they are
expected to handle allocation.

ResourceClaimParameters and ResourceClassParameters are new types for telling
in-tree components how to handle claims.
This commit is contained in:
Patrick Ohly
2024-02-14 14:38:42 +01:00
parent eb1470d60d
commit 39bbcedbca
85 changed files with 19855 additions and 120 deletions

View File

@@ -1891,6 +1891,26 @@
{
"freshness": "Current",
"resources": [
{
"resource": "noderesourceslices",
"responseKind": {
"group": "",
"kind": "NodeResourceSlice",
"version": ""
},
"scope": "Cluster",
"singularResource": "noderesourceslice",
"verbs": [
"create",
"delete",
"deletecollection",
"get",
"list",
"patch",
"update",
"watch"
]
},
{
"resource": "podschedulingcontexts",
"responseKind": {
@@ -1926,6 +1946,26 @@
"watch"
]
},
{
"resource": "resourceclaimparameters",
"responseKind": {
"group": "",
"kind": "ResourceClaimParameters",
"version": ""
},
"scope": "Namespaced",
"singularResource": "resourceclaimparameters",
"verbs": [
"create",
"delete",
"deletecollection",
"get",
"list",
"patch",
"update",
"watch"
]
},
{
"resource": "resourceclaims",
"responseKind": {
@@ -2000,6 +2040,26 @@
"update",
"watch"
]
},
{
"resource": "resourceclassparameters",
"responseKind": {
"group": "",
"kind": "ResourceClassParameters",
"version": ""
},
"scope": "Namespaced",
"singularResource": "resourceclassparameters",
"verbs": [
"create",
"delete",
"deletecollection",
"get",
"list",
"patch",
"update",
"watch"
]
}
],
"version": "v1alpha2"

View File

@@ -3,6 +3,23 @@
"groupVersion": "resource.k8s.io/v1alpha2",
"kind": "APIResourceList",
"resources": [
{
"kind": "NodeResourceSlice",
"name": "noderesourceslices",
"namespaced": false,
"singularName": "noderesourceslice",
"storageVersionHash": "KmjmPdo2jrQ=",
"verbs": [
"create",
"delete",
"deletecollection",
"get",
"list",
"patch",
"update",
"watch"
]
},
{
"kind": "PodSchedulingContext",
"name": "podschedulingcontexts",
@@ -31,6 +48,23 @@
"update"
]
},
{
"kind": "ResourceClaimParameters",
"name": "resourceclaimparameters",
"namespaced": true,
"singularName": "resourceclaimparameters",
"storageVersionHash": "DWM408h+ZHE=",
"verbs": [
"create",
"delete",
"deletecollection",
"get",
"list",
"patch",
"update",
"watch"
]
},
{
"kind": "ResourceClaim",
"name": "resourceclaims",
@@ -92,6 +126,23 @@
"update",
"watch"
]
},
{
"kind": "ResourceClassParameters",
"name": "resourceclassparameters",
"namespaced": true,
"singularName": "resourceclassparameters",
"storageVersionHash": "MDq5XoTnXWQ=",
"verbs": [
"create",
"delete",
"deletecollection",
"get",
"list",
"patch",
"update",
"watch"
]
}
]
}

File diff suppressed because it is too large Load Diff

View File

@@ -37,7 +37,7 @@ API_KNOWN_VIOLATIONS_DIR="${API_KNOWN_VIOLATIONS_DIR:-"${KUBE_ROOT}/api/api-rule
OUT_DIR="_output"
BOILERPLATE_FILENAME="hack/boilerplate/boilerplate.generatego.txt"
APPLYCONFIG_PKG="k8s.io/client-go/applyconfigurations"
PLURAL_EXCEPTIONS="Endpoints:Endpoints"
PLURAL_EXCEPTIONS="Endpoints:Endpoints,ResourceClaimParameters:ResourceClaimParameters,ResourceClassParameters:ResourceClassParameters"
# Any time we call sort, we want it in the same locale.
export LC_ALL="C"

View File

@@ -60,6 +60,12 @@ func addKnownTypes(scheme *runtime.Scheme) error {
&ResourceClaimTemplateList{},
&PodSchedulingContext{},
&PodSchedulingContextList{},
&NodeResourceSlice{},
&NodeResourceSliceList{},
&ResourceClaimParameters{},
&ResourceClaimParametersList{},
&ResourceClassParameters{},
&ResourceClassParametersList{},
)
return nil

View File

@@ -18,6 +18,7 @@ package resource
import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
"k8s.io/kubernetes/pkg/apis/core"
)
@@ -185,11 +186,47 @@ type ResourceHandle struct {
// future, but not reduced.
// +optional
Data string
// If StructuredData is set, then it needs to be used instead of Data.
StructuredData *StructuredResourceHandle
}
// ResourceHandleDataMaxSize represents the maximum size of resourceHandle.data.
const ResourceHandleDataMaxSize = 16 * 1024
// StructuredResourceHandle is the in-tree representation of the allocation result.
type StructuredResourceHandle struct {
// VendorClassParameters are the per-claim configuration parameters
// from the resource class at the time that the claim was allocated.
VendorClassParameters runtime.Object
// VendorClaimParameters are the per-claim configuration parameters
// from the resource claim parameters at the time that the claim was
// allocated.
VendorClaimParameters runtime.Object
// NodeName is the name of the node providing the necessary resources.
NodeName string
// Results lists all allocated driver resources.
Results []DriverAllocationResult
}
// DriverAllocationResult contains vendor parameters and the allocation result for
// one request.
type DriverAllocationResult struct {
// VendorRequestParameters are the per-request configuration parameters
// from the time that the claim was allocated.
VendorRequestParameters runtime.Object
AllocationResultModel
}
// AllocationResultModel must have one and only one field set.
type AllocationResultModel struct {
// TODO: implement one structured parameter model
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ResourceClaimList is a collection of claims.
@@ -323,6 +360,10 @@ type ResourceClass struct {
// Setting this field is optional. If null, all nodes are candidates.
// +optional
SuitableNodes *core.NodeSelector
// If and only if allocation of claims using this class is handled
// via structured parameters, then StructuredParameters must be set to true.
StructuredParameters *bool
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
@@ -434,3 +475,168 @@ type ResourceClaimTemplateList struct {
// Items is the list of resource claim templates.
Items []ResourceClaimTemplate
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// NodeResourceSlice provides information about available
// resources on individual nodes.
type NodeResourceSlice struct {
metav1.TypeMeta
// Standard object metadata
metav1.ObjectMeta
// NodeName identifies the node where the capacity is available.
// A field selector can be used to list only NodeResourceSlice
// objects with a certain node name.
NodeName string
// DriverName identifies the DRA driver providing the capacity information.
// A field selector can be used to list only NodeResourceSlice
// objects with a certain driver name.
DriverName string
NodeResourceModel
}
// NodeResourceModel must have one and only one field set.
type NodeResourceModel struct {
// TODO: implement one structured parameter model
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// NodeResourceSliceList is a collection of NodeResourceSlices.
type NodeResourceSliceList struct {
metav1.TypeMeta
// Standard list metadata
metav1.ListMeta
// Items is the list of node resource capacity objects.
Items []NodeResourceSlice
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ResourceClaimParameters defines resource requests for a ResourceClaim in an
// in-tree format understood by Kubernetes.
type ResourceClaimParameters struct {
metav1.TypeMeta
// Standard object metadata
metav1.ObjectMeta
// If this object was created from some other resource, then this links
// back to that resource. This field is used to find the in-tree representation
// of the claim parameters when the parameter reference of the claim refers
// to some unknown type.
GeneratedFrom *ResourceClaimParametersReference
// Shareable indicates whether the allocated claim is meant to be shareable
// by multiple consumers at the same time.
Shareable bool
// DriverRequests describes all resources that are needed for the
// allocated claim. A single claim may use resources coming from
// different drivers. For each driver, this array has at most one
// entry which then may have one or more per-driver requests.
//
// May be empty, in which case the claim can always be allocated.
DriverRequests []DriverRequests
}
// DriverRequests describes all resources that are needed from one particular driver.
type DriverRequests struct {
// DriverName is the name used by the DRA driver kubelet plugin.
DriverName string
// VendorParameters are arbitrary setup parameters for all requests of the
// claim. They are ignored while allocating the claim.
VendorParameters runtime.Object
// Requests describes all resources that are needed from the driver.
Requests []ResourceRequest
}
// ResourceRequest is a request for resources from one particular driver.
type ResourceRequest struct {
// VendorParameters are arbitrary setup parameters for the requested
// resource. They are ignored while allocating a claim.
VendorParameters runtime.Object
ResourceRequestModel
}
// ResourceRequestModel must have one and only one field set.
type ResourceRequestModel struct {
// TODO: implement one structured parameter model
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ResourceClaimParametersList is a collection of ResourceClaimParameters.
type ResourceClaimParametersList struct {
metav1.TypeMeta
// Standard list metadata
metav1.ListMeta
// Items is the list of node resource capacity objects.
Items []ResourceClaimParameters
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ResourceClassParameters defines resource requests for a ResourceClass in an
// in-tree format understood by Kubernetes.
type ResourceClassParameters struct {
metav1.TypeMeta
// Standard object metadata
metav1.ObjectMeta
// If this object was created from some other resource, then this links
// back to that resource. This field is used to find the in-tree representation
// of the class parameters when the parameter reference of the class refers
// to some unknown type.
GeneratedFrom *ResourceClassParametersReference
// VendorParameters are arbitrary setup parameters for all claims using
// this class. They are ignored while allocating the claim. There must
// not be more than one entry per driver.
VendorParameters []VendorParameters
// Filters describes additional contraints that must be met when using the class.
Filters []ResourceFilter
}
// ResourceFilter is a filter for resources from one particular driver.
type ResourceFilter struct {
// DriverName is the name used by the DRA driver kubelet plugin.
DriverName string
ResourceFilterModel
}
// ResourceFilterModel must have one and only one field set.
type ResourceFilterModel struct {
// TODO: implement one structured parameter model
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// ResourceClassParametersList is a collection of ResourceClassParameters.
type ResourceClassParametersList struct {
metav1.TypeMeta
// Standard list metadata
metav1.ListMeta
// Items is the list of node resource capacity objects.
Items []ResourceClassParameters
}
// VendorParameters are opaque parameters for one particular driver.
type VendorParameters struct {
// DriverName is the name used by the DRA driver kubelet plugin.
DriverName string
// Parameters can be arbitrary setup parameters. They are ignored while
// allocating a claim.
Parameters runtime.Object
}

View File

@@ -17,9 +17,23 @@ limitations under the License.
package v1alpha2
import (
"fmt"
"k8s.io/apimachinery/pkg/runtime"
)
func addConversionFuncs(scheme *runtime.Scheme) error {
if err := scheme.AddFieldLabelConversionFunc(SchemeGroupVersion.WithKind("NodeResourceSlice"),
func(label, value string) (string, string, error) {
switch label {
case "metadata.name", "nodeName", "driverName":
return label, value, nil
default:
return "", "", fmt.Errorf("field label not supported for %s: %s", SchemeGroupVersion.WithKind("NodeResourceSlice"), label)
}
}); err != nil {
return err
}
return nil
}

View File

@@ -50,6 +50,66 @@ func RegisterConversions(s *runtime.Scheme) error {
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*v1alpha2.AllocationResultModel)(nil), (*resource.AllocationResultModel)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1alpha2_AllocationResultModel_To_resource_AllocationResultModel(a.(*v1alpha2.AllocationResultModel), b.(*resource.AllocationResultModel), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*resource.AllocationResultModel)(nil), (*v1alpha2.AllocationResultModel)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_resource_AllocationResultModel_To_v1alpha2_AllocationResultModel(a.(*resource.AllocationResultModel), b.(*v1alpha2.AllocationResultModel), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*v1alpha2.DriverAllocationResult)(nil), (*resource.DriverAllocationResult)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1alpha2_DriverAllocationResult_To_resource_DriverAllocationResult(a.(*v1alpha2.DriverAllocationResult), b.(*resource.DriverAllocationResult), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*resource.DriverAllocationResult)(nil), (*v1alpha2.DriverAllocationResult)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_resource_DriverAllocationResult_To_v1alpha2_DriverAllocationResult(a.(*resource.DriverAllocationResult), b.(*v1alpha2.DriverAllocationResult), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*v1alpha2.DriverRequests)(nil), (*resource.DriverRequests)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1alpha2_DriverRequests_To_resource_DriverRequests(a.(*v1alpha2.DriverRequests), b.(*resource.DriverRequests), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*resource.DriverRequests)(nil), (*v1alpha2.DriverRequests)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_resource_DriverRequests_To_v1alpha2_DriverRequests(a.(*resource.DriverRequests), b.(*v1alpha2.DriverRequests), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*v1alpha2.NodeResourceModel)(nil), (*resource.NodeResourceModel)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1alpha2_NodeResourceModel_To_resource_NodeResourceModel(a.(*v1alpha2.NodeResourceModel), b.(*resource.NodeResourceModel), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*resource.NodeResourceModel)(nil), (*v1alpha2.NodeResourceModel)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_resource_NodeResourceModel_To_v1alpha2_NodeResourceModel(a.(*resource.NodeResourceModel), b.(*v1alpha2.NodeResourceModel), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*v1alpha2.NodeResourceSlice)(nil), (*resource.NodeResourceSlice)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1alpha2_NodeResourceSlice_To_resource_NodeResourceSlice(a.(*v1alpha2.NodeResourceSlice), b.(*resource.NodeResourceSlice), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*resource.NodeResourceSlice)(nil), (*v1alpha2.NodeResourceSlice)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_resource_NodeResourceSlice_To_v1alpha2_NodeResourceSlice(a.(*resource.NodeResourceSlice), b.(*v1alpha2.NodeResourceSlice), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*v1alpha2.NodeResourceSliceList)(nil), (*resource.NodeResourceSliceList)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1alpha2_NodeResourceSliceList_To_resource_NodeResourceSliceList(a.(*v1alpha2.NodeResourceSliceList), b.(*resource.NodeResourceSliceList), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*resource.NodeResourceSliceList)(nil), (*v1alpha2.NodeResourceSliceList)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_resource_NodeResourceSliceList_To_v1alpha2_NodeResourceSliceList(a.(*resource.NodeResourceSliceList), b.(*v1alpha2.NodeResourceSliceList), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*v1alpha2.PodSchedulingContext)(nil), (*resource.PodSchedulingContext)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1alpha2_PodSchedulingContext_To_resource_PodSchedulingContext(a.(*v1alpha2.PodSchedulingContext), b.(*resource.PodSchedulingContext), scope)
}); err != nil {
@@ -120,6 +180,26 @@ func RegisterConversions(s *runtime.Scheme) error {
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*v1alpha2.ResourceClaimParameters)(nil), (*resource.ResourceClaimParameters)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1alpha2_ResourceClaimParameters_To_resource_ResourceClaimParameters(a.(*v1alpha2.ResourceClaimParameters), b.(*resource.ResourceClaimParameters), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*resource.ResourceClaimParameters)(nil), (*v1alpha2.ResourceClaimParameters)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_resource_ResourceClaimParameters_To_v1alpha2_ResourceClaimParameters(a.(*resource.ResourceClaimParameters), b.(*v1alpha2.ResourceClaimParameters), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*v1alpha2.ResourceClaimParametersList)(nil), (*resource.ResourceClaimParametersList)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1alpha2_ResourceClaimParametersList_To_resource_ResourceClaimParametersList(a.(*v1alpha2.ResourceClaimParametersList), b.(*resource.ResourceClaimParametersList), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*resource.ResourceClaimParametersList)(nil), (*v1alpha2.ResourceClaimParametersList)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_resource_ResourceClaimParametersList_To_v1alpha2_ResourceClaimParametersList(a.(*resource.ResourceClaimParametersList), b.(*v1alpha2.ResourceClaimParametersList), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*v1alpha2.ResourceClaimParametersReference)(nil), (*resource.ResourceClaimParametersReference)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1alpha2_ResourceClaimParametersReference_To_resource_ResourceClaimParametersReference(a.(*v1alpha2.ResourceClaimParametersReference), b.(*resource.ResourceClaimParametersReference), scope)
}); err != nil {
@@ -210,6 +290,26 @@ func RegisterConversions(s *runtime.Scheme) error {
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*v1alpha2.ResourceClassParameters)(nil), (*resource.ResourceClassParameters)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1alpha2_ResourceClassParameters_To_resource_ResourceClassParameters(a.(*v1alpha2.ResourceClassParameters), b.(*resource.ResourceClassParameters), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*resource.ResourceClassParameters)(nil), (*v1alpha2.ResourceClassParameters)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_resource_ResourceClassParameters_To_v1alpha2_ResourceClassParameters(a.(*resource.ResourceClassParameters), b.(*v1alpha2.ResourceClassParameters), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*v1alpha2.ResourceClassParametersList)(nil), (*resource.ResourceClassParametersList)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1alpha2_ResourceClassParametersList_To_resource_ResourceClassParametersList(a.(*v1alpha2.ResourceClassParametersList), b.(*resource.ResourceClassParametersList), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*resource.ResourceClassParametersList)(nil), (*v1alpha2.ResourceClassParametersList)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_resource_ResourceClassParametersList_To_v1alpha2_ResourceClassParametersList(a.(*resource.ResourceClassParametersList), b.(*v1alpha2.ResourceClassParametersList), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*v1alpha2.ResourceClassParametersReference)(nil), (*resource.ResourceClassParametersReference)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1alpha2_ResourceClassParametersReference_To_resource_ResourceClassParametersReference(a.(*v1alpha2.ResourceClassParametersReference), b.(*resource.ResourceClassParametersReference), scope)
}); err != nil {
@@ -220,6 +320,26 @@ func RegisterConversions(s *runtime.Scheme) error {
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*v1alpha2.ResourceFilter)(nil), (*resource.ResourceFilter)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1alpha2_ResourceFilter_To_resource_ResourceFilter(a.(*v1alpha2.ResourceFilter), b.(*resource.ResourceFilter), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*resource.ResourceFilter)(nil), (*v1alpha2.ResourceFilter)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_resource_ResourceFilter_To_v1alpha2_ResourceFilter(a.(*resource.ResourceFilter), b.(*v1alpha2.ResourceFilter), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*v1alpha2.ResourceFilterModel)(nil), (*resource.ResourceFilterModel)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1alpha2_ResourceFilterModel_To_resource_ResourceFilterModel(a.(*v1alpha2.ResourceFilterModel), b.(*resource.ResourceFilterModel), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*resource.ResourceFilterModel)(nil), (*v1alpha2.ResourceFilterModel)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_resource_ResourceFilterModel_To_v1alpha2_ResourceFilterModel(a.(*resource.ResourceFilterModel), b.(*v1alpha2.ResourceFilterModel), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*v1alpha2.ResourceHandle)(nil), (*resource.ResourceHandle)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1alpha2_ResourceHandle_To_resource_ResourceHandle(a.(*v1alpha2.ResourceHandle), b.(*resource.ResourceHandle), scope)
}); err != nil {
@@ -230,11 +350,61 @@ func RegisterConversions(s *runtime.Scheme) error {
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*v1alpha2.ResourceRequest)(nil), (*resource.ResourceRequest)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1alpha2_ResourceRequest_To_resource_ResourceRequest(a.(*v1alpha2.ResourceRequest), b.(*resource.ResourceRequest), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*resource.ResourceRequest)(nil), (*v1alpha2.ResourceRequest)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_resource_ResourceRequest_To_v1alpha2_ResourceRequest(a.(*resource.ResourceRequest), b.(*v1alpha2.ResourceRequest), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*v1alpha2.ResourceRequestModel)(nil), (*resource.ResourceRequestModel)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1alpha2_ResourceRequestModel_To_resource_ResourceRequestModel(a.(*v1alpha2.ResourceRequestModel), b.(*resource.ResourceRequestModel), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*resource.ResourceRequestModel)(nil), (*v1alpha2.ResourceRequestModel)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_resource_ResourceRequestModel_To_v1alpha2_ResourceRequestModel(a.(*resource.ResourceRequestModel), b.(*v1alpha2.ResourceRequestModel), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*v1alpha2.StructuredResourceHandle)(nil), (*resource.StructuredResourceHandle)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1alpha2_StructuredResourceHandle_To_resource_StructuredResourceHandle(a.(*v1alpha2.StructuredResourceHandle), b.(*resource.StructuredResourceHandle), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*resource.StructuredResourceHandle)(nil), (*v1alpha2.StructuredResourceHandle)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_resource_StructuredResourceHandle_To_v1alpha2_StructuredResourceHandle(a.(*resource.StructuredResourceHandle), b.(*v1alpha2.StructuredResourceHandle), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*v1alpha2.VendorParameters)(nil), (*resource.VendorParameters)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_v1alpha2_VendorParameters_To_resource_VendorParameters(a.(*v1alpha2.VendorParameters), b.(*resource.VendorParameters), scope)
}); err != nil {
return err
}
if err := s.AddGeneratedConversionFunc((*resource.VendorParameters)(nil), (*v1alpha2.VendorParameters)(nil), func(a, b interface{}, scope conversion.Scope) error {
return Convert_resource_VendorParameters_To_v1alpha2_VendorParameters(a.(*resource.VendorParameters), b.(*v1alpha2.VendorParameters), scope)
}); err != nil {
return err
}
return nil
}
func autoConvert_v1alpha2_AllocationResult_To_resource_AllocationResult(in *v1alpha2.AllocationResult, out *resource.AllocationResult, s conversion.Scope) error {
out.ResourceHandles = *(*[]resource.ResourceHandle)(unsafe.Pointer(&in.ResourceHandles))
if in.ResourceHandles != nil {
in, out := &in.ResourceHandles, &out.ResourceHandles
*out = make([]resource.ResourceHandle, len(*in))
for i := range *in {
if err := Convert_v1alpha2_ResourceHandle_To_resource_ResourceHandle(&(*in)[i], &(*out)[i], s); err != nil {
return err
}
}
} else {
out.ResourceHandles = nil
}
out.AvailableOnNodes = (*core.NodeSelector)(unsafe.Pointer(in.AvailableOnNodes))
out.Shareable = in.Shareable
return nil
@@ -246,7 +416,17 @@ func Convert_v1alpha2_AllocationResult_To_resource_AllocationResult(in *v1alpha2
}
func autoConvert_resource_AllocationResult_To_v1alpha2_AllocationResult(in *resource.AllocationResult, out *v1alpha2.AllocationResult, s conversion.Scope) error {
out.ResourceHandles = *(*[]v1alpha2.ResourceHandle)(unsafe.Pointer(&in.ResourceHandles))
if in.ResourceHandles != nil {
in, out := &in.ResourceHandles, &out.ResourceHandles
*out = make([]v1alpha2.ResourceHandle, len(*in))
for i := range *in {
if err := Convert_resource_ResourceHandle_To_v1alpha2_ResourceHandle(&(*in)[i], &(*out)[i], s); err != nil {
return err
}
}
} else {
out.ResourceHandles = nil
}
out.AvailableOnNodes = (*v1.NodeSelector)(unsafe.Pointer(in.AvailableOnNodes))
out.Shareable = in.Shareable
return nil
@@ -257,6 +437,172 @@ func Convert_resource_AllocationResult_To_v1alpha2_AllocationResult(in *resource
return autoConvert_resource_AllocationResult_To_v1alpha2_AllocationResult(in, out, s)
}
func autoConvert_v1alpha2_AllocationResultModel_To_resource_AllocationResultModel(in *v1alpha2.AllocationResultModel, out *resource.AllocationResultModel, s conversion.Scope) error {
return nil
}
// Convert_v1alpha2_AllocationResultModel_To_resource_AllocationResultModel is an autogenerated conversion function.
func Convert_v1alpha2_AllocationResultModel_To_resource_AllocationResultModel(in *v1alpha2.AllocationResultModel, out *resource.AllocationResultModel, s conversion.Scope) error {
return autoConvert_v1alpha2_AllocationResultModel_To_resource_AllocationResultModel(in, out, s)
}
func autoConvert_resource_AllocationResultModel_To_v1alpha2_AllocationResultModel(in *resource.AllocationResultModel, out *v1alpha2.AllocationResultModel, s conversion.Scope) error {
return nil
}
// Convert_resource_AllocationResultModel_To_v1alpha2_AllocationResultModel is an autogenerated conversion function.
func Convert_resource_AllocationResultModel_To_v1alpha2_AllocationResultModel(in *resource.AllocationResultModel, out *v1alpha2.AllocationResultModel, s conversion.Scope) error {
return autoConvert_resource_AllocationResultModel_To_v1alpha2_AllocationResultModel(in, out, s)
}
func autoConvert_v1alpha2_DriverAllocationResult_To_resource_DriverAllocationResult(in *v1alpha2.DriverAllocationResult, out *resource.DriverAllocationResult, s conversion.Scope) error {
if err := runtime.Convert_runtime_RawExtension_To_runtime_Object(&in.VendorRequestParameters, &out.VendorRequestParameters, s); err != nil {
return err
}
if err := Convert_v1alpha2_AllocationResultModel_To_resource_AllocationResultModel(&in.AllocationResultModel, &out.AllocationResultModel, s); err != nil {
return err
}
return nil
}
// Convert_v1alpha2_DriverAllocationResult_To_resource_DriverAllocationResult is an autogenerated conversion function.
func Convert_v1alpha2_DriverAllocationResult_To_resource_DriverAllocationResult(in *v1alpha2.DriverAllocationResult, out *resource.DriverAllocationResult, s conversion.Scope) error {
return autoConvert_v1alpha2_DriverAllocationResult_To_resource_DriverAllocationResult(in, out, s)
}
func autoConvert_resource_DriverAllocationResult_To_v1alpha2_DriverAllocationResult(in *resource.DriverAllocationResult, out *v1alpha2.DriverAllocationResult, s conversion.Scope) error {
if err := runtime.Convert_runtime_Object_To_runtime_RawExtension(&in.VendorRequestParameters, &out.VendorRequestParameters, s); err != nil {
return err
}
if err := Convert_resource_AllocationResultModel_To_v1alpha2_AllocationResultModel(&in.AllocationResultModel, &out.AllocationResultModel, s); err != nil {
return err
}
return nil
}
// Convert_resource_DriverAllocationResult_To_v1alpha2_DriverAllocationResult is an autogenerated conversion function.
func Convert_resource_DriverAllocationResult_To_v1alpha2_DriverAllocationResult(in *resource.DriverAllocationResult, out *v1alpha2.DriverAllocationResult, s conversion.Scope) error {
return autoConvert_resource_DriverAllocationResult_To_v1alpha2_DriverAllocationResult(in, out, s)
}
func autoConvert_v1alpha2_DriverRequests_To_resource_DriverRequests(in *v1alpha2.DriverRequests, out *resource.DriverRequests, s conversion.Scope) error {
out.DriverName = in.DriverName
if err := runtime.Convert_runtime_RawExtension_To_runtime_Object(&in.VendorParameters, &out.VendorParameters, s); err != nil {
return err
}
if in.Requests != nil {
in, out := &in.Requests, &out.Requests
*out = make([]resource.ResourceRequest, len(*in))
for i := range *in {
if err := Convert_v1alpha2_ResourceRequest_To_resource_ResourceRequest(&(*in)[i], &(*out)[i], s); err != nil {
return err
}
}
} else {
out.Requests = nil
}
return nil
}
// Convert_v1alpha2_DriverRequests_To_resource_DriverRequests is an autogenerated conversion function.
func Convert_v1alpha2_DriverRequests_To_resource_DriverRequests(in *v1alpha2.DriverRequests, out *resource.DriverRequests, s conversion.Scope) error {
return autoConvert_v1alpha2_DriverRequests_To_resource_DriverRequests(in, out, s)
}
func autoConvert_resource_DriverRequests_To_v1alpha2_DriverRequests(in *resource.DriverRequests, out *v1alpha2.DriverRequests, s conversion.Scope) error {
out.DriverName = in.DriverName
if err := runtime.Convert_runtime_Object_To_runtime_RawExtension(&in.VendorParameters, &out.VendorParameters, s); err != nil {
return err
}
if in.Requests != nil {
in, out := &in.Requests, &out.Requests
*out = make([]v1alpha2.ResourceRequest, len(*in))
for i := range *in {
if err := Convert_resource_ResourceRequest_To_v1alpha2_ResourceRequest(&(*in)[i], &(*out)[i], s); err != nil {
return err
}
}
} else {
out.Requests = nil
}
return nil
}
// Convert_resource_DriverRequests_To_v1alpha2_DriverRequests is an autogenerated conversion function.
func Convert_resource_DriverRequests_To_v1alpha2_DriverRequests(in *resource.DriverRequests, out *v1alpha2.DriverRequests, s conversion.Scope) error {
return autoConvert_resource_DriverRequests_To_v1alpha2_DriverRequests(in, out, s)
}
func autoConvert_v1alpha2_NodeResourceModel_To_resource_NodeResourceModel(in *v1alpha2.NodeResourceModel, out *resource.NodeResourceModel, s conversion.Scope) error {
return nil
}
// Convert_v1alpha2_NodeResourceModel_To_resource_NodeResourceModel is an autogenerated conversion function.
func Convert_v1alpha2_NodeResourceModel_To_resource_NodeResourceModel(in *v1alpha2.NodeResourceModel, out *resource.NodeResourceModel, s conversion.Scope) error {
return autoConvert_v1alpha2_NodeResourceModel_To_resource_NodeResourceModel(in, out, s)
}
func autoConvert_resource_NodeResourceModel_To_v1alpha2_NodeResourceModel(in *resource.NodeResourceModel, out *v1alpha2.NodeResourceModel, s conversion.Scope) error {
return nil
}
// Convert_resource_NodeResourceModel_To_v1alpha2_NodeResourceModel is an autogenerated conversion function.
func Convert_resource_NodeResourceModel_To_v1alpha2_NodeResourceModel(in *resource.NodeResourceModel, out *v1alpha2.NodeResourceModel, s conversion.Scope) error {
return autoConvert_resource_NodeResourceModel_To_v1alpha2_NodeResourceModel(in, out, s)
}
func autoConvert_v1alpha2_NodeResourceSlice_To_resource_NodeResourceSlice(in *v1alpha2.NodeResourceSlice, out *resource.NodeResourceSlice, s conversion.Scope) error {
out.ObjectMeta = in.ObjectMeta
out.NodeName = in.NodeName
out.DriverName = in.DriverName
if err := Convert_v1alpha2_NodeResourceModel_To_resource_NodeResourceModel(&in.NodeResourceModel, &out.NodeResourceModel, s); err != nil {
return err
}
return nil
}
// Convert_v1alpha2_NodeResourceSlice_To_resource_NodeResourceSlice is an autogenerated conversion function.
func Convert_v1alpha2_NodeResourceSlice_To_resource_NodeResourceSlice(in *v1alpha2.NodeResourceSlice, out *resource.NodeResourceSlice, s conversion.Scope) error {
return autoConvert_v1alpha2_NodeResourceSlice_To_resource_NodeResourceSlice(in, out, s)
}
func autoConvert_resource_NodeResourceSlice_To_v1alpha2_NodeResourceSlice(in *resource.NodeResourceSlice, out *v1alpha2.NodeResourceSlice, s conversion.Scope) error {
out.ObjectMeta = in.ObjectMeta
out.NodeName = in.NodeName
out.DriverName = in.DriverName
if err := Convert_resource_NodeResourceModel_To_v1alpha2_NodeResourceModel(&in.NodeResourceModel, &out.NodeResourceModel, s); err != nil {
return err
}
return nil
}
// Convert_resource_NodeResourceSlice_To_v1alpha2_NodeResourceSlice is an autogenerated conversion function.
func Convert_resource_NodeResourceSlice_To_v1alpha2_NodeResourceSlice(in *resource.NodeResourceSlice, out *v1alpha2.NodeResourceSlice, s conversion.Scope) error {
return autoConvert_resource_NodeResourceSlice_To_v1alpha2_NodeResourceSlice(in, out, s)
}
func autoConvert_v1alpha2_NodeResourceSliceList_To_resource_NodeResourceSliceList(in *v1alpha2.NodeResourceSliceList, out *resource.NodeResourceSliceList, s conversion.Scope) error {
out.ListMeta = in.ListMeta
out.Items = *(*[]resource.NodeResourceSlice)(unsafe.Pointer(&in.Items))
return nil
}
// Convert_v1alpha2_NodeResourceSliceList_To_resource_NodeResourceSliceList is an autogenerated conversion function.
func Convert_v1alpha2_NodeResourceSliceList_To_resource_NodeResourceSliceList(in *v1alpha2.NodeResourceSliceList, out *resource.NodeResourceSliceList, s conversion.Scope) error {
return autoConvert_v1alpha2_NodeResourceSliceList_To_resource_NodeResourceSliceList(in, out, s)
}
func autoConvert_resource_NodeResourceSliceList_To_v1alpha2_NodeResourceSliceList(in *resource.NodeResourceSliceList, out *v1alpha2.NodeResourceSliceList, s conversion.Scope) error {
out.ListMeta = in.ListMeta
out.Items = *(*[]v1alpha2.NodeResourceSlice)(unsafe.Pointer(&in.Items))
return nil
}
// Convert_resource_NodeResourceSliceList_To_v1alpha2_NodeResourceSliceList is an autogenerated conversion function.
func Convert_resource_NodeResourceSliceList_To_v1alpha2_NodeResourceSliceList(in *resource.NodeResourceSliceList, out *v1alpha2.NodeResourceSliceList, s conversion.Scope) error {
return autoConvert_resource_NodeResourceSliceList_To_v1alpha2_NodeResourceSliceList(in, out, s)
}
func autoConvert_v1alpha2_PodSchedulingContext_To_resource_PodSchedulingContext(in *v1alpha2.PodSchedulingContext, out *resource.PodSchedulingContext, s conversion.Scope) error {
out.ObjectMeta = in.ObjectMeta
if err := Convert_v1alpha2_PodSchedulingContextSpec_To_resource_PodSchedulingContextSpec(&in.Spec, &out.Spec, s); err != nil {
@@ -413,7 +759,17 @@ func Convert_resource_ResourceClaimConsumerReference_To_v1alpha2_ResourceClaimCo
func autoConvert_v1alpha2_ResourceClaimList_To_resource_ResourceClaimList(in *v1alpha2.ResourceClaimList, out *resource.ResourceClaimList, s conversion.Scope) error {
out.ListMeta = in.ListMeta
out.Items = *(*[]resource.ResourceClaim)(unsafe.Pointer(&in.Items))
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]resource.ResourceClaim, len(*in))
for i := range *in {
if err := Convert_v1alpha2_ResourceClaim_To_resource_ResourceClaim(&(*in)[i], &(*out)[i], s); err != nil {
return err
}
}
} else {
out.Items = nil
}
return nil
}
@@ -424,7 +780,17 @@ func Convert_v1alpha2_ResourceClaimList_To_resource_ResourceClaimList(in *v1alph
func autoConvert_resource_ResourceClaimList_To_v1alpha2_ResourceClaimList(in *resource.ResourceClaimList, out *v1alpha2.ResourceClaimList, s conversion.Scope) error {
out.ListMeta = in.ListMeta
out.Items = *(*[]v1alpha2.ResourceClaim)(unsafe.Pointer(&in.Items))
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]v1alpha2.ResourceClaim, len(*in))
for i := range *in {
if err := Convert_resource_ResourceClaim_To_v1alpha2_ResourceClaim(&(*in)[i], &(*out)[i], s); err != nil {
return err
}
}
} else {
out.Items = nil
}
return nil
}
@@ -433,6 +799,94 @@ func Convert_resource_ResourceClaimList_To_v1alpha2_ResourceClaimList(in *resour
return autoConvert_resource_ResourceClaimList_To_v1alpha2_ResourceClaimList(in, out, s)
}
func autoConvert_v1alpha2_ResourceClaimParameters_To_resource_ResourceClaimParameters(in *v1alpha2.ResourceClaimParameters, out *resource.ResourceClaimParameters, s conversion.Scope) error {
out.ObjectMeta = in.ObjectMeta
out.GeneratedFrom = (*resource.ResourceClaimParametersReference)(unsafe.Pointer(in.GeneratedFrom))
out.Shareable = in.Shareable
if in.DriverRequests != nil {
in, out := &in.DriverRequests, &out.DriverRequests
*out = make([]resource.DriverRequests, len(*in))
for i := range *in {
if err := Convert_v1alpha2_DriverRequests_To_resource_DriverRequests(&(*in)[i], &(*out)[i], s); err != nil {
return err
}
}
} else {
out.DriverRequests = nil
}
return nil
}
// Convert_v1alpha2_ResourceClaimParameters_To_resource_ResourceClaimParameters is an autogenerated conversion function.
func Convert_v1alpha2_ResourceClaimParameters_To_resource_ResourceClaimParameters(in *v1alpha2.ResourceClaimParameters, out *resource.ResourceClaimParameters, s conversion.Scope) error {
return autoConvert_v1alpha2_ResourceClaimParameters_To_resource_ResourceClaimParameters(in, out, s)
}
func autoConvert_resource_ResourceClaimParameters_To_v1alpha2_ResourceClaimParameters(in *resource.ResourceClaimParameters, out *v1alpha2.ResourceClaimParameters, s conversion.Scope) error {
out.ObjectMeta = in.ObjectMeta
out.GeneratedFrom = (*v1alpha2.ResourceClaimParametersReference)(unsafe.Pointer(in.GeneratedFrom))
out.Shareable = in.Shareable
if in.DriverRequests != nil {
in, out := &in.DriverRequests, &out.DriverRequests
*out = make([]v1alpha2.DriverRequests, len(*in))
for i := range *in {
if err := Convert_resource_DriverRequests_To_v1alpha2_DriverRequests(&(*in)[i], &(*out)[i], s); err != nil {
return err
}
}
} else {
out.DriverRequests = nil
}
return nil
}
// Convert_resource_ResourceClaimParameters_To_v1alpha2_ResourceClaimParameters is an autogenerated conversion function.
func Convert_resource_ResourceClaimParameters_To_v1alpha2_ResourceClaimParameters(in *resource.ResourceClaimParameters, out *v1alpha2.ResourceClaimParameters, s conversion.Scope) error {
return autoConvert_resource_ResourceClaimParameters_To_v1alpha2_ResourceClaimParameters(in, out, s)
}
func autoConvert_v1alpha2_ResourceClaimParametersList_To_resource_ResourceClaimParametersList(in *v1alpha2.ResourceClaimParametersList, out *resource.ResourceClaimParametersList, s conversion.Scope) error {
out.ListMeta = in.ListMeta
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]resource.ResourceClaimParameters, len(*in))
for i := range *in {
if err := Convert_v1alpha2_ResourceClaimParameters_To_resource_ResourceClaimParameters(&(*in)[i], &(*out)[i], s); err != nil {
return err
}
}
} else {
out.Items = nil
}
return nil
}
// Convert_v1alpha2_ResourceClaimParametersList_To_resource_ResourceClaimParametersList is an autogenerated conversion function.
func Convert_v1alpha2_ResourceClaimParametersList_To_resource_ResourceClaimParametersList(in *v1alpha2.ResourceClaimParametersList, out *resource.ResourceClaimParametersList, s conversion.Scope) error {
return autoConvert_v1alpha2_ResourceClaimParametersList_To_resource_ResourceClaimParametersList(in, out, s)
}
func autoConvert_resource_ResourceClaimParametersList_To_v1alpha2_ResourceClaimParametersList(in *resource.ResourceClaimParametersList, out *v1alpha2.ResourceClaimParametersList, s conversion.Scope) error {
out.ListMeta = in.ListMeta
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]v1alpha2.ResourceClaimParameters, len(*in))
for i := range *in {
if err := Convert_resource_ResourceClaimParameters_To_v1alpha2_ResourceClaimParameters(&(*in)[i], &(*out)[i], s); err != nil {
return err
}
}
} else {
out.Items = nil
}
return nil
}
// Convert_resource_ResourceClaimParametersList_To_v1alpha2_ResourceClaimParametersList is an autogenerated conversion function.
func Convert_resource_ResourceClaimParametersList_To_v1alpha2_ResourceClaimParametersList(in *resource.ResourceClaimParametersList, out *v1alpha2.ResourceClaimParametersList, s conversion.Scope) error {
return autoConvert_resource_ResourceClaimParametersList_To_v1alpha2_ResourceClaimParametersList(in, out, s)
}
func autoConvert_v1alpha2_ResourceClaimParametersReference_To_resource_ResourceClaimParametersReference(in *v1alpha2.ResourceClaimParametersReference, out *resource.ResourceClaimParametersReference, s conversion.Scope) error {
out.APIGroup = in.APIGroup
out.Kind = in.Kind
@@ -505,7 +959,15 @@ func Convert_resource_ResourceClaimSpec_To_v1alpha2_ResourceClaimSpec(in *resour
func autoConvert_v1alpha2_ResourceClaimStatus_To_resource_ResourceClaimStatus(in *v1alpha2.ResourceClaimStatus, out *resource.ResourceClaimStatus, s conversion.Scope) error {
out.DriverName = in.DriverName
out.Allocation = (*resource.AllocationResult)(unsafe.Pointer(in.Allocation))
if in.Allocation != nil {
in, out := &in.Allocation, &out.Allocation
*out = new(resource.AllocationResult)
if err := Convert_v1alpha2_AllocationResult_To_resource_AllocationResult(*in, *out, s); err != nil {
return err
}
} else {
out.Allocation = nil
}
out.ReservedFor = *(*[]resource.ResourceClaimConsumerReference)(unsafe.Pointer(&in.ReservedFor))
out.DeallocationRequested = in.DeallocationRequested
return nil
@@ -518,7 +980,15 @@ func Convert_v1alpha2_ResourceClaimStatus_To_resource_ResourceClaimStatus(in *v1
func autoConvert_resource_ResourceClaimStatus_To_v1alpha2_ResourceClaimStatus(in *resource.ResourceClaimStatus, out *v1alpha2.ResourceClaimStatus, s conversion.Scope) error {
out.DriverName = in.DriverName
out.Allocation = (*v1alpha2.AllocationResult)(unsafe.Pointer(in.Allocation))
if in.Allocation != nil {
in, out := &in.Allocation, &out.Allocation
*out = new(v1alpha2.AllocationResult)
if err := Convert_resource_AllocationResult_To_v1alpha2_AllocationResult(*in, *out, s); err != nil {
return err
}
} else {
out.Allocation = nil
}
out.ReservedFor = *(*[]v1alpha2.ResourceClaimConsumerReference)(unsafe.Pointer(&in.ReservedFor))
out.DeallocationRequested = in.DeallocationRequested
return nil
@@ -608,6 +1078,7 @@ func autoConvert_v1alpha2_ResourceClass_To_resource_ResourceClass(in *v1alpha2.R
out.DriverName = in.DriverName
out.ParametersRef = (*resource.ResourceClassParametersReference)(unsafe.Pointer(in.ParametersRef))
out.SuitableNodes = (*core.NodeSelector)(unsafe.Pointer(in.SuitableNodes))
out.StructuredParameters = (*bool)(unsafe.Pointer(in.StructuredParameters))
return nil
}
@@ -621,6 +1092,7 @@ func autoConvert_resource_ResourceClass_To_v1alpha2_ResourceClass(in *resource.R
out.DriverName = in.DriverName
out.ParametersRef = (*v1alpha2.ResourceClassParametersReference)(unsafe.Pointer(in.ParametersRef))
out.SuitableNodes = (*v1.NodeSelector)(unsafe.Pointer(in.SuitableNodes))
out.StructuredParameters = (*bool)(unsafe.Pointer(in.StructuredParameters))
return nil
}
@@ -651,6 +1123,94 @@ func Convert_resource_ResourceClassList_To_v1alpha2_ResourceClassList(in *resour
return autoConvert_resource_ResourceClassList_To_v1alpha2_ResourceClassList(in, out, s)
}
func autoConvert_v1alpha2_ResourceClassParameters_To_resource_ResourceClassParameters(in *v1alpha2.ResourceClassParameters, out *resource.ResourceClassParameters, s conversion.Scope) error {
out.ObjectMeta = in.ObjectMeta
out.GeneratedFrom = (*resource.ResourceClassParametersReference)(unsafe.Pointer(in.GeneratedFrom))
if in.VendorParameters != nil {
in, out := &in.VendorParameters, &out.VendorParameters
*out = make([]resource.VendorParameters, len(*in))
for i := range *in {
if err := Convert_v1alpha2_VendorParameters_To_resource_VendorParameters(&(*in)[i], &(*out)[i], s); err != nil {
return err
}
}
} else {
out.VendorParameters = nil
}
out.Filters = *(*[]resource.ResourceFilter)(unsafe.Pointer(&in.Filters))
return nil
}
// Convert_v1alpha2_ResourceClassParameters_To_resource_ResourceClassParameters is an autogenerated conversion function.
func Convert_v1alpha2_ResourceClassParameters_To_resource_ResourceClassParameters(in *v1alpha2.ResourceClassParameters, out *resource.ResourceClassParameters, s conversion.Scope) error {
return autoConvert_v1alpha2_ResourceClassParameters_To_resource_ResourceClassParameters(in, out, s)
}
func autoConvert_resource_ResourceClassParameters_To_v1alpha2_ResourceClassParameters(in *resource.ResourceClassParameters, out *v1alpha2.ResourceClassParameters, s conversion.Scope) error {
out.ObjectMeta = in.ObjectMeta
out.GeneratedFrom = (*v1alpha2.ResourceClassParametersReference)(unsafe.Pointer(in.GeneratedFrom))
if in.VendorParameters != nil {
in, out := &in.VendorParameters, &out.VendorParameters
*out = make([]v1alpha2.VendorParameters, len(*in))
for i := range *in {
if err := Convert_resource_VendorParameters_To_v1alpha2_VendorParameters(&(*in)[i], &(*out)[i], s); err != nil {
return err
}
}
} else {
out.VendorParameters = nil
}
out.Filters = *(*[]v1alpha2.ResourceFilter)(unsafe.Pointer(&in.Filters))
return nil
}
// Convert_resource_ResourceClassParameters_To_v1alpha2_ResourceClassParameters is an autogenerated conversion function.
func Convert_resource_ResourceClassParameters_To_v1alpha2_ResourceClassParameters(in *resource.ResourceClassParameters, out *v1alpha2.ResourceClassParameters, s conversion.Scope) error {
return autoConvert_resource_ResourceClassParameters_To_v1alpha2_ResourceClassParameters(in, out, s)
}
func autoConvert_v1alpha2_ResourceClassParametersList_To_resource_ResourceClassParametersList(in *v1alpha2.ResourceClassParametersList, out *resource.ResourceClassParametersList, s conversion.Scope) error {
out.ListMeta = in.ListMeta
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]resource.ResourceClassParameters, len(*in))
for i := range *in {
if err := Convert_v1alpha2_ResourceClassParameters_To_resource_ResourceClassParameters(&(*in)[i], &(*out)[i], s); err != nil {
return err
}
}
} else {
out.Items = nil
}
return nil
}
// Convert_v1alpha2_ResourceClassParametersList_To_resource_ResourceClassParametersList is an autogenerated conversion function.
func Convert_v1alpha2_ResourceClassParametersList_To_resource_ResourceClassParametersList(in *v1alpha2.ResourceClassParametersList, out *resource.ResourceClassParametersList, s conversion.Scope) error {
return autoConvert_v1alpha2_ResourceClassParametersList_To_resource_ResourceClassParametersList(in, out, s)
}
func autoConvert_resource_ResourceClassParametersList_To_v1alpha2_ResourceClassParametersList(in *resource.ResourceClassParametersList, out *v1alpha2.ResourceClassParametersList, s conversion.Scope) error {
out.ListMeta = in.ListMeta
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]v1alpha2.ResourceClassParameters, len(*in))
for i := range *in {
if err := Convert_resource_ResourceClassParameters_To_v1alpha2_ResourceClassParameters(&(*in)[i], &(*out)[i], s); err != nil {
return err
}
}
} else {
out.Items = nil
}
return nil
}
// Convert_resource_ResourceClassParametersList_To_v1alpha2_ResourceClassParametersList is an autogenerated conversion function.
func Convert_resource_ResourceClassParametersList_To_v1alpha2_ResourceClassParametersList(in *resource.ResourceClassParametersList, out *v1alpha2.ResourceClassParametersList, s conversion.Scope) error {
return autoConvert_resource_ResourceClassParametersList_To_v1alpha2_ResourceClassParametersList(in, out, s)
}
func autoConvert_v1alpha2_ResourceClassParametersReference_To_resource_ResourceClassParametersReference(in *v1alpha2.ResourceClassParametersReference, out *resource.ResourceClassParametersReference, s conversion.Scope) error {
out.APIGroup = in.APIGroup
out.Kind = in.Kind
@@ -677,9 +1237,62 @@ func Convert_resource_ResourceClassParametersReference_To_v1alpha2_ResourceClass
return autoConvert_resource_ResourceClassParametersReference_To_v1alpha2_ResourceClassParametersReference(in, out, s)
}
func autoConvert_v1alpha2_ResourceFilter_To_resource_ResourceFilter(in *v1alpha2.ResourceFilter, out *resource.ResourceFilter, s conversion.Scope) error {
out.DriverName = in.DriverName
if err := Convert_v1alpha2_ResourceFilterModel_To_resource_ResourceFilterModel(&in.ResourceFilterModel, &out.ResourceFilterModel, s); err != nil {
return err
}
return nil
}
// Convert_v1alpha2_ResourceFilter_To_resource_ResourceFilter is an autogenerated conversion function.
func Convert_v1alpha2_ResourceFilter_To_resource_ResourceFilter(in *v1alpha2.ResourceFilter, out *resource.ResourceFilter, s conversion.Scope) error {
return autoConvert_v1alpha2_ResourceFilter_To_resource_ResourceFilter(in, out, s)
}
func autoConvert_resource_ResourceFilter_To_v1alpha2_ResourceFilter(in *resource.ResourceFilter, out *v1alpha2.ResourceFilter, s conversion.Scope) error {
out.DriverName = in.DriverName
if err := Convert_resource_ResourceFilterModel_To_v1alpha2_ResourceFilterModel(&in.ResourceFilterModel, &out.ResourceFilterModel, s); err != nil {
return err
}
return nil
}
// Convert_resource_ResourceFilter_To_v1alpha2_ResourceFilter is an autogenerated conversion function.
func Convert_resource_ResourceFilter_To_v1alpha2_ResourceFilter(in *resource.ResourceFilter, out *v1alpha2.ResourceFilter, s conversion.Scope) error {
return autoConvert_resource_ResourceFilter_To_v1alpha2_ResourceFilter(in, out, s)
}
func autoConvert_v1alpha2_ResourceFilterModel_To_resource_ResourceFilterModel(in *v1alpha2.ResourceFilterModel, out *resource.ResourceFilterModel, s conversion.Scope) error {
return nil
}
// Convert_v1alpha2_ResourceFilterModel_To_resource_ResourceFilterModel is an autogenerated conversion function.
func Convert_v1alpha2_ResourceFilterModel_To_resource_ResourceFilterModel(in *v1alpha2.ResourceFilterModel, out *resource.ResourceFilterModel, s conversion.Scope) error {
return autoConvert_v1alpha2_ResourceFilterModel_To_resource_ResourceFilterModel(in, out, s)
}
func autoConvert_resource_ResourceFilterModel_To_v1alpha2_ResourceFilterModel(in *resource.ResourceFilterModel, out *v1alpha2.ResourceFilterModel, s conversion.Scope) error {
return nil
}
// Convert_resource_ResourceFilterModel_To_v1alpha2_ResourceFilterModel is an autogenerated conversion function.
func Convert_resource_ResourceFilterModel_To_v1alpha2_ResourceFilterModel(in *resource.ResourceFilterModel, out *v1alpha2.ResourceFilterModel, s conversion.Scope) error {
return autoConvert_resource_ResourceFilterModel_To_v1alpha2_ResourceFilterModel(in, out, s)
}
func autoConvert_v1alpha2_ResourceHandle_To_resource_ResourceHandle(in *v1alpha2.ResourceHandle, out *resource.ResourceHandle, s conversion.Scope) error {
out.DriverName = in.DriverName
out.Data = in.Data
if in.StructuredData != nil {
in, out := &in.StructuredData, &out.StructuredData
*out = new(resource.StructuredResourceHandle)
if err := Convert_v1alpha2_StructuredResourceHandle_To_resource_StructuredResourceHandle(*in, *out, s); err != nil {
return err
}
} else {
out.StructuredData = nil
}
return nil
}
@@ -691,6 +1304,15 @@ func Convert_v1alpha2_ResourceHandle_To_resource_ResourceHandle(in *v1alpha2.Res
func autoConvert_resource_ResourceHandle_To_v1alpha2_ResourceHandle(in *resource.ResourceHandle, out *v1alpha2.ResourceHandle, s conversion.Scope) error {
out.DriverName = in.DriverName
out.Data = in.Data
if in.StructuredData != nil {
in, out := &in.StructuredData, &out.StructuredData
*out = new(v1alpha2.StructuredResourceHandle)
if err := Convert_resource_StructuredResourceHandle_To_v1alpha2_StructuredResourceHandle(*in, *out, s); err != nil {
return err
}
} else {
out.StructuredData = nil
}
return nil
}
@@ -698,3 +1320,131 @@ func autoConvert_resource_ResourceHandle_To_v1alpha2_ResourceHandle(in *resource
func Convert_resource_ResourceHandle_To_v1alpha2_ResourceHandle(in *resource.ResourceHandle, out *v1alpha2.ResourceHandle, s conversion.Scope) error {
return autoConvert_resource_ResourceHandle_To_v1alpha2_ResourceHandle(in, out, s)
}
func autoConvert_v1alpha2_ResourceRequest_To_resource_ResourceRequest(in *v1alpha2.ResourceRequest, out *resource.ResourceRequest, s conversion.Scope) error {
if err := runtime.Convert_runtime_RawExtension_To_runtime_Object(&in.VendorParameters, &out.VendorParameters, s); err != nil {
return err
}
if err := Convert_v1alpha2_ResourceRequestModel_To_resource_ResourceRequestModel(&in.ResourceRequestModel, &out.ResourceRequestModel, s); err != nil {
return err
}
return nil
}
// Convert_v1alpha2_ResourceRequest_To_resource_ResourceRequest is an autogenerated conversion function.
func Convert_v1alpha2_ResourceRequest_To_resource_ResourceRequest(in *v1alpha2.ResourceRequest, out *resource.ResourceRequest, s conversion.Scope) error {
return autoConvert_v1alpha2_ResourceRequest_To_resource_ResourceRequest(in, out, s)
}
func autoConvert_resource_ResourceRequest_To_v1alpha2_ResourceRequest(in *resource.ResourceRequest, out *v1alpha2.ResourceRequest, s conversion.Scope) error {
if err := runtime.Convert_runtime_Object_To_runtime_RawExtension(&in.VendorParameters, &out.VendorParameters, s); err != nil {
return err
}
if err := Convert_resource_ResourceRequestModel_To_v1alpha2_ResourceRequestModel(&in.ResourceRequestModel, &out.ResourceRequestModel, s); err != nil {
return err
}
return nil
}
// Convert_resource_ResourceRequest_To_v1alpha2_ResourceRequest is an autogenerated conversion function.
func Convert_resource_ResourceRequest_To_v1alpha2_ResourceRequest(in *resource.ResourceRequest, out *v1alpha2.ResourceRequest, s conversion.Scope) error {
return autoConvert_resource_ResourceRequest_To_v1alpha2_ResourceRequest(in, out, s)
}
func autoConvert_v1alpha2_ResourceRequestModel_To_resource_ResourceRequestModel(in *v1alpha2.ResourceRequestModel, out *resource.ResourceRequestModel, s conversion.Scope) error {
return nil
}
// Convert_v1alpha2_ResourceRequestModel_To_resource_ResourceRequestModel is an autogenerated conversion function.
func Convert_v1alpha2_ResourceRequestModel_To_resource_ResourceRequestModel(in *v1alpha2.ResourceRequestModel, out *resource.ResourceRequestModel, s conversion.Scope) error {
return autoConvert_v1alpha2_ResourceRequestModel_To_resource_ResourceRequestModel(in, out, s)
}
func autoConvert_resource_ResourceRequestModel_To_v1alpha2_ResourceRequestModel(in *resource.ResourceRequestModel, out *v1alpha2.ResourceRequestModel, s conversion.Scope) error {
return nil
}
// Convert_resource_ResourceRequestModel_To_v1alpha2_ResourceRequestModel is an autogenerated conversion function.
func Convert_resource_ResourceRequestModel_To_v1alpha2_ResourceRequestModel(in *resource.ResourceRequestModel, out *v1alpha2.ResourceRequestModel, s conversion.Scope) error {
return autoConvert_resource_ResourceRequestModel_To_v1alpha2_ResourceRequestModel(in, out, s)
}
func autoConvert_v1alpha2_StructuredResourceHandle_To_resource_StructuredResourceHandle(in *v1alpha2.StructuredResourceHandle, out *resource.StructuredResourceHandle, s conversion.Scope) error {
if err := runtime.Convert_runtime_RawExtension_To_runtime_Object(&in.VendorClassParameters, &out.VendorClassParameters, s); err != nil {
return err
}
if err := runtime.Convert_runtime_RawExtension_To_runtime_Object(&in.VendorClaimParameters, &out.VendorClaimParameters, s); err != nil {
return err
}
out.NodeName = in.NodeName
if in.Results != nil {
in, out := &in.Results, &out.Results
*out = make([]resource.DriverAllocationResult, len(*in))
for i := range *in {
if err := Convert_v1alpha2_DriverAllocationResult_To_resource_DriverAllocationResult(&(*in)[i], &(*out)[i], s); err != nil {
return err
}
}
} else {
out.Results = nil
}
return nil
}
// Convert_v1alpha2_StructuredResourceHandle_To_resource_StructuredResourceHandle is an autogenerated conversion function.
func Convert_v1alpha2_StructuredResourceHandle_To_resource_StructuredResourceHandle(in *v1alpha2.StructuredResourceHandle, out *resource.StructuredResourceHandle, s conversion.Scope) error {
return autoConvert_v1alpha2_StructuredResourceHandle_To_resource_StructuredResourceHandle(in, out, s)
}
func autoConvert_resource_StructuredResourceHandle_To_v1alpha2_StructuredResourceHandle(in *resource.StructuredResourceHandle, out *v1alpha2.StructuredResourceHandle, s conversion.Scope) error {
if err := runtime.Convert_runtime_Object_To_runtime_RawExtension(&in.VendorClassParameters, &out.VendorClassParameters, s); err != nil {
return err
}
if err := runtime.Convert_runtime_Object_To_runtime_RawExtension(&in.VendorClaimParameters, &out.VendorClaimParameters, s); err != nil {
return err
}
out.NodeName = in.NodeName
if in.Results != nil {
in, out := &in.Results, &out.Results
*out = make([]v1alpha2.DriverAllocationResult, len(*in))
for i := range *in {
if err := Convert_resource_DriverAllocationResult_To_v1alpha2_DriverAllocationResult(&(*in)[i], &(*out)[i], s); err != nil {
return err
}
}
} else {
out.Results = nil
}
return nil
}
// Convert_resource_StructuredResourceHandle_To_v1alpha2_StructuredResourceHandle is an autogenerated conversion function.
func Convert_resource_StructuredResourceHandle_To_v1alpha2_StructuredResourceHandle(in *resource.StructuredResourceHandle, out *v1alpha2.StructuredResourceHandle, s conversion.Scope) error {
return autoConvert_resource_StructuredResourceHandle_To_v1alpha2_StructuredResourceHandle(in, out, s)
}
func autoConvert_v1alpha2_VendorParameters_To_resource_VendorParameters(in *v1alpha2.VendorParameters, out *resource.VendorParameters, s conversion.Scope) error {
out.DriverName = in.DriverName
if err := runtime.Convert_runtime_RawExtension_To_runtime_Object(&in.Parameters, &out.Parameters, s); err != nil {
return err
}
return nil
}
// Convert_v1alpha2_VendorParameters_To_resource_VendorParameters is an autogenerated conversion function.
func Convert_v1alpha2_VendorParameters_To_resource_VendorParameters(in *v1alpha2.VendorParameters, out *resource.VendorParameters, s conversion.Scope) error {
return autoConvert_v1alpha2_VendorParameters_To_resource_VendorParameters(in, out, s)
}
func autoConvert_resource_VendorParameters_To_v1alpha2_VendorParameters(in *resource.VendorParameters, out *v1alpha2.VendorParameters, s conversion.Scope) error {
out.DriverName = in.DriverName
if err := runtime.Convert_runtime_Object_To_runtime_RawExtension(&in.Parameters, &out.Parameters, s); err != nil {
return err
}
return nil
}
// Convert_resource_VendorParameters_To_v1alpha2_VendorParameters is an autogenerated conversion function.
func Convert_resource_VendorParameters_To_v1alpha2_VendorParameters(in *resource.VendorParameters, out *v1alpha2.VendorParameters, s conversion.Scope) error {
return autoConvert_resource_VendorParameters_To_v1alpha2_VendorParameters(in, out, s)
}

View File

@@ -17,6 +17,7 @@ limitations under the License.
package validation
import (
apiequality "k8s.io/apimachinery/pkg/api/equality"
apimachineryvalidation "k8s.io/apimachinery/pkg/api/validation"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/sets"
@@ -41,7 +42,7 @@ func validateResourceClaimSpec(spec *resource.ResourceClaimSpec, fldPath *field.
for _, msg := range corevalidation.ValidateClassName(spec.ResourceClassName, false) {
allErrs = append(allErrs, field.Invalid(fldPath.Child("resourceClassName"), spec.ResourceClassName, msg))
}
allErrs = append(allErrs, validateResourceClaimParameters(spec.ParametersRef, fldPath.Child("parametersRef"))...)
allErrs = append(allErrs, validateResourceClaimParametersRef(spec.ParametersRef, fldPath.Child("parametersRef"))...)
if !supportedAllocationModes.Has(string(spec.AllocationMode)) {
allErrs = append(allErrs, field.NotSupported(fldPath.Child("allocationMode"), spec.AllocationMode, supportedAllocationModes.List()))
}
@@ -54,7 +55,7 @@ var supportedAllocationModes = sets.NewString(string(resource.AllocationModeImme
// function for Kind and Name in both types, but generics cannot be used to
// access common fields in structs.
func validateResourceClaimParameters(ref *resource.ResourceClaimParametersReference, fldPath *field.Path) field.ErrorList {
func validateResourceClaimParametersRef(ref *resource.ResourceClaimParametersReference, fldPath *field.Path) field.ErrorList {
var allErrs field.ErrorList
if ref != nil {
if ref.Kind == "" {
@@ -200,6 +201,12 @@ func validateResourceHandles(resourceHandles []resource.ResourceHandle, maxSize
if len(resourceHandle.Data) > resource.ResourceHandleDataMaxSize {
allErrs = append(allErrs, field.TooLongMaxLength(idxPath.Child("data"), len(resourceHandle.Data), resource.ResourceHandleDataMaxSize))
}
if resourceHandle.StructuredData != nil {
allErrs = append(allErrs, validateStructuredResourceHandle(resourceHandle.StructuredData, idxPath.Child("structuredData"))...)
}
if len(resourceHandle.Data) > 0 && resourceHandle.StructuredData != nil {
allErrs = append(allErrs, field.Invalid(idxPath, nil, "data and structuredData are mutually exclusive"))
}
}
if len(resourceHandles) > maxSize {
// Dumping the entire field into the error message is likely to be too long,
@@ -210,6 +217,37 @@ func validateResourceHandles(resourceHandles []resource.ResourceHandle, maxSize
return allErrs
}
func validateStructuredResourceHandle(handle *resource.StructuredResourceHandle, fldPath *field.Path) field.ErrorList {
var allErrs field.ErrorList
allErrs = append(allErrs, validateNodeName(handle.NodeName, fldPath.Child("nodeName"))...)
allErrs = append(allErrs, validateDriverAllocationResults(handle.Results, fldPath.Child("results"))...)
return allErrs
}
func validateDriverAllocationResults(results []resource.DriverAllocationResult, fldPath *field.Path) field.ErrorList {
var allErrs field.ErrorList
for index, result := range results {
idxPath := fldPath.Index(index)
allErrs = append(allErrs, validateAllocationResultModel(&result.AllocationResultModel, idxPath)...)
}
return allErrs
}
func validateAllocationResultModel(model *resource.AllocationResultModel, fldPath *field.Path) field.ErrorList {
var allErrs field.ErrorList
entries := sets.New[string]()
// TODO: implement one structured parameter model
switch len(entries) {
case 0:
// allErrs = append(allErrs, field.Required(fldPath, "exactly one structured model field must be set"))
case 1:
// Okay.
default:
allErrs = append(allErrs, field.Invalid(fldPath, sets.List(entries), "exactly one field must be set, not several"))
}
return allErrs
}
func validateResourceClaimUserReference(ref resource.ResourceClaimConsumerReference, fldPath *field.Path) field.ErrorList {
var allErrs field.ErrorList
if ref.Resource == "" {
@@ -345,3 +383,170 @@ func validateNodeName(name string, fldPath *field.Path) field.ErrorList {
}
return allErrs
}
// ValidateNodeResourceSlice tests if a NodeResourceSlice object is valid.
func ValidateNodeResourceSlice(nodeResourceSlice *resource.NodeResourceSlice) field.ErrorList {
allErrs := corevalidation.ValidateObjectMeta(&nodeResourceSlice.ObjectMeta, false, apimachineryvalidation.NameIsDNSSubdomain, field.NewPath("metadata"))
allErrs = append(allErrs, validateNodeName(nodeResourceSlice.NodeName, field.NewPath("nodeName"))...)
allErrs = append(allErrs, validateResourceDriverName(nodeResourceSlice.DriverName, field.NewPath("driverName"))...)
allErrs = append(allErrs, validateNodeResourceModel(&nodeResourceSlice.NodeResourceModel, nil)...)
return allErrs
}
func validateNodeResourceModel(model *resource.NodeResourceModel, fldPath *field.Path) field.ErrorList {
var allErrs field.ErrorList
entries := sets.New[string]()
// TODO: implement one structured parameter model
switch len(entries) {
case 0:
// allErrs = append(allErrs, field.Required(fldPath, "exactly one structured model field must be set"))
case 1:
// Okay.
default:
allErrs = append(allErrs, field.Invalid(fldPath, sets.List(entries), "exactly one field must be set, not several"))
}
return allErrs
}
// ValidateNodeResourceSlice tests if a NodeResourceSlice update is valid.
func ValidateNodeResourceSliceUpdate(nodeResourceSlice, oldNodeResourceSlice *resource.NodeResourceSlice) field.ErrorList {
allErrs := corevalidation.ValidateObjectMetaUpdate(&nodeResourceSlice.ObjectMeta, &oldNodeResourceSlice.ObjectMeta, field.NewPath("metadata"))
allErrs = append(allErrs, ValidateNodeResourceSlice(nodeResourceSlice)...)
allErrs = append(allErrs, apimachineryvalidation.ValidateImmutableField(nodeResourceSlice.NodeName, oldNodeResourceSlice.NodeName, field.NewPath("nodeName"))...)
allErrs = append(allErrs, apimachineryvalidation.ValidateImmutableField(nodeResourceSlice.DriverName, oldNodeResourceSlice.DriverName, field.NewPath("driverName"))...)
return allErrs
}
// ValidateResourceClaimParameters tests if a ResourceClaimParameters object is valid for creation.
func ValidateResourceClaimParameters(parameters *resource.ResourceClaimParameters) field.ErrorList {
return validateResourceClaimParameters(parameters, false)
}
func validateResourceClaimParameters(parameters *resource.ResourceClaimParameters, requestStored bool) field.ErrorList {
allErrs := corevalidation.ValidateObjectMeta(&parameters.ObjectMeta, true, apimachineryvalidation.NameIsDNSSubdomain, field.NewPath("metadata"))
allErrs = append(allErrs, validateResourceClaimParametersRef(parameters.GeneratedFrom, field.NewPath("generatedFrom"))...)
allErrs = append(allErrs, validateDriverRequests(parameters.DriverRequests, field.NewPath("driverRequests"), requestStored)...)
return allErrs
}
func validateDriverRequests(requests []resource.DriverRequests, fldPath *field.Path, requestStored bool) field.ErrorList {
var allErrs field.ErrorList
driverNames := sets.New[string]()
for i, request := range requests {
idxPath := fldPath.Index(i)
driverName := request.DriverName
allErrs = append(allErrs, validateResourceDriverName(driverName, idxPath.Child("driverName"))...)
if driverNames.Has(driverName) {
allErrs = append(allErrs, field.Duplicate(idxPath.Child("driverName"), driverName))
} else {
driverNames.Insert(driverName)
}
allErrs = append(allErrs, validateResourceRequests(request.Requests, idxPath.Child("requests"), requestStored)...)
}
return allErrs
}
func validateResourceRequests(requests []resource.ResourceRequest, fldPath *field.Path, requestStored bool) field.ErrorList {
var allErrs field.ErrorList
for i, request := range requests {
idxPath := fldPath.Index(i)
allErrs = append(allErrs, validateResourceRequestModel(&request.ResourceRequestModel, idxPath, requestStored)...)
}
if len(requests) == 0 {
// We could allow this, it just doesn't make sense: the entire entry would get ignored and thus
// should have been left out entirely.
allErrs = append(allErrs, field.Required(fldPath, "empty entries with no requests are not allowed"))
}
return allErrs
}
func validateResourceRequestModel(model *resource.ResourceRequestModel, fldPath *field.Path, requestStored bool) field.ErrorList {
var allErrs field.ErrorList
entries := sets.New[string]()
// TODO: implement one structured parameter model
switch len(entries) {
case 0:
// allErrs = append(allErrs, field.Required(fldPath, "exactly one structured model field must be set"))
case 1:
// Okay.
default:
allErrs = append(allErrs, field.Invalid(fldPath, sets.List(entries), "exactly one field must be set, not several"))
}
return allErrs
}
// ValidateResourceClaimParameters tests if a ResourceClaimParameters update is valid.
func ValidateResourceClaimParametersUpdate(resourceClaimParameters, oldResourceClaimParameters *resource.ResourceClaimParameters) field.ErrorList {
allErrs := corevalidation.ValidateObjectMetaUpdate(&resourceClaimParameters.ObjectMeta, &oldResourceClaimParameters.ObjectMeta, field.NewPath("metadata"))
requestStored := apiequality.Semantic.DeepEqual(oldResourceClaimParameters.DriverRequests, resourceClaimParameters.DriverRequests)
allErrs = append(allErrs, validateResourceClaimParameters(resourceClaimParameters, requestStored)...)
return allErrs
}
// ValidateResourceClassParameters tests if a ResourceClassParameters object is valid for creation.
func ValidateResourceClassParameters(parameters *resource.ResourceClassParameters) field.ErrorList {
return validateResourceClassParameters(parameters, false)
}
func validateResourceClassParameters(parameters *resource.ResourceClassParameters, filtersStored bool) field.ErrorList {
allErrs := corevalidation.ValidateObjectMeta(&parameters.ObjectMeta, true, apimachineryvalidation.NameIsDNSSubdomain, field.NewPath("metadata"))
allErrs = append(allErrs, validateClassParameters(parameters.GeneratedFrom, field.NewPath("generatedFrom"))...)
allErrs = append(allErrs, validateResourceFilters(parameters.Filters, field.NewPath("filters"), filtersStored)...)
allErrs = append(allErrs, validateVendorParameters(parameters.VendorParameters, field.NewPath("vendorParameters"))...)
return allErrs
}
func validateResourceFilters(filters []resource.ResourceFilter, fldPath *field.Path, filtersStored bool) field.ErrorList {
var allErrs field.ErrorList
driverNames := sets.New[string]()
for i, filter := range filters {
idxPath := fldPath.Index(i)
driverName := filter.DriverName
allErrs = append(allErrs, validateResourceDriverName(driverName, idxPath.Child("driverName"))...)
if driverNames.Has(driverName) {
allErrs = append(allErrs, field.Duplicate(idxPath.Child("driverName"), driverName))
} else {
driverNames.Insert(driverName)
}
allErrs = append(allErrs, validateResourceFilterModel(&filter.ResourceFilterModel, idxPath, filtersStored)...)
}
return allErrs
}
func validateResourceFilterModel(model *resource.ResourceFilterModel, fldPath *field.Path, filtersStored bool) field.ErrorList {
var allErrs field.ErrorList
entries := sets.New[string]()
// TODO: implement one structured parameter model
switch len(entries) {
case 0:
// allErrs = append(allErrs, field.Required(fldPath, "exactly one structured model field must be set"))
case 1:
// Okay.
default:
allErrs = append(allErrs, field.Invalid(fldPath, sets.List(entries), "exactly one field must be set, not several"))
}
return allErrs
}
func validateVendorParameters(parameters []resource.VendorParameters, fldPath *field.Path) field.ErrorList {
var allErrs field.ErrorList
driverNames := sets.New[string]()
for i, parameters := range parameters {
idxPath := fldPath.Index(i)
driverName := parameters.DriverName
allErrs = append(allErrs, validateResourceDriverName(driverName, idxPath.Child("driverName"))...)
if driverNames.Has(driverName) {
allErrs = append(allErrs, field.Duplicate(idxPath.Child("driverName"), driverName))
} else {
driverNames.Insert(driverName)
}
}
return allErrs
}
// ValidateResourceClassParameters tests if a ResourceClassParameters update is valid.
func ValidateResourceClassParametersUpdate(resourceClassParameters, oldResourceClassParameters *resource.ResourceClassParameters) field.ErrorList {
allErrs := corevalidation.ValidateObjectMetaUpdate(&resourceClassParameters.ObjectMeta, &oldResourceClassParameters.ObjectMeta, field.NewPath("metadata"))
allErrs = append(allErrs, ValidateResourceClassParameters(resourceClassParameters)...)
return allErrs
}

View File

@@ -0,0 +1,256 @@
/*
Copyright 2022 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.
*/
package validation
import (
"testing"
"github.com/stretchr/testify/assert"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/validation/field"
"k8s.io/kubernetes/pkg/apis/resource"
"k8s.io/utils/ptr"
)
func testNodeResourceSlice(name, nodeName, driverName string) *resource.NodeResourceSlice {
return &resource.NodeResourceSlice{
ObjectMeta: metav1.ObjectMeta{
Name: name,
},
NodeName: nodeName,
DriverName: driverName,
NodeResourceModel: resource.NodeResourceModel{
// TODO: implement one structured parameter model
},
}
}
func TestValidateNodeResourceSlice(t *testing.T) {
goodName := "foo"
badName := "!@#$%^"
driverName := "test.example.com"
now := metav1.Now()
badValue := "spaces not allowed"
scenarios := map[string]struct {
slice *resource.NodeResourceSlice
wantFailures field.ErrorList
}{
"good": {
slice: testNodeResourceSlice(goodName, goodName, driverName),
},
"missing-name": {
wantFailures: field.ErrorList{field.Required(field.NewPath("metadata", "name"), "name or generateName is required")},
slice: testNodeResourceSlice("", goodName, driverName),
},
"bad-name": {
wantFailures: field.ErrorList{field.Invalid(field.NewPath("metadata", "name"), badName, "a lowercase RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')")},
slice: testNodeResourceSlice(badName, goodName, driverName),
},
"generate-name": {
slice: func() *resource.NodeResourceSlice {
slice := testNodeResourceSlice(goodName, goodName, driverName)
slice.GenerateName = "prefix-"
return slice
}(),
},
"uid": {
slice: func() *resource.NodeResourceSlice {
slice := testNodeResourceSlice(goodName, goodName, driverName)
slice.UID = "ac051fac-2ead-46d9-b8b4-4e0fbeb7455d"
return slice
}(),
},
"resource-version": {
slice: func() *resource.NodeResourceSlice {
slice := testNodeResourceSlice(goodName, goodName, driverName)
slice.ResourceVersion = "1"
return slice
}(),
},
"generation": {
slice: func() *resource.NodeResourceSlice {
slice := testNodeResourceSlice(goodName, goodName, driverName)
slice.Generation = 100
return slice
}(),
},
"creation-timestamp": {
slice: func() *resource.NodeResourceSlice {
slice := testNodeResourceSlice(goodName, goodName, driverName)
slice.CreationTimestamp = now
return slice
}(),
},
"deletion-grace-period-seconds": {
slice: func() *resource.NodeResourceSlice {
slice := testNodeResourceSlice(goodName, goodName, driverName)
slice.DeletionGracePeriodSeconds = ptr.To[int64](10)
return slice
}(),
},
"owner-references": {
slice: func() *resource.NodeResourceSlice {
slice := testNodeResourceSlice(goodName, goodName, driverName)
slice.OwnerReferences = []metav1.OwnerReference{
{
APIVersion: "v1",
Kind: "pod",
Name: "foo",
UID: "ac051fac-2ead-46d9-b8b4-4e0fbeb7455d",
},
}
return slice
}(),
},
"finalizers": {
slice: func() *resource.NodeResourceSlice {
slice := testNodeResourceSlice(goodName, goodName, driverName)
slice.Finalizers = []string{
"example.com/foo",
}
return slice
}(),
},
"managed-fields": {
slice: func() *resource.NodeResourceSlice {
slice := testNodeResourceSlice(goodName, goodName, driverName)
slice.ManagedFields = []metav1.ManagedFieldsEntry{
{
FieldsType: "FieldsV1",
Operation: "Apply",
APIVersion: "apps/v1",
Manager: "foo",
},
}
return slice
}(),
},
"good-labels": {
slice: func() *resource.NodeResourceSlice {
slice := testNodeResourceSlice(goodName, goodName, driverName)
slice.Labels = map[string]string{
"apps.kubernetes.io/name": "test",
}
return slice
}(),
},
"bad-labels": {
wantFailures: field.ErrorList{field.Invalid(field.NewPath("metadata", "labels"), badValue, "a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue', or 'my_value', or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')")},
slice: func() *resource.NodeResourceSlice {
slice := testNodeResourceSlice(goodName, goodName, driverName)
slice.Labels = map[string]string{
"hello-world": badValue,
}
return slice
}(),
},
"good-annotations": {
slice: func() *resource.NodeResourceSlice {
slice := testNodeResourceSlice(goodName, goodName, driverName)
slice.Annotations = map[string]string{
"foo": "bar",
}
return slice
}(),
},
"bad-annotations": {
wantFailures: field.ErrorList{field.Invalid(field.NewPath("metadata", "annotations"), badName, "name part must consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyName', or 'my.name', or '123-abc', regex used for validation is '([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]')")},
slice: func() *resource.NodeResourceSlice {
slice := testNodeResourceSlice(goodName, goodName, driverName)
slice.Annotations = map[string]string{
badName: "hello world",
}
return slice
}(),
},
"bad-nodename": {
wantFailures: field.ErrorList{field.Invalid(field.NewPath("nodeName"), badName, "a lowercase RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')")},
slice: testNodeResourceSlice(goodName, badName, driverName),
},
"bad-drivername": {
wantFailures: field.ErrorList{field.Invalid(field.NewPath("driverName"), badName, "a lowercase RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')")},
slice: testNodeResourceSlice(goodName, goodName, badName),
},
// TODO: implement one structured parameter model
// "empty-model": {
// wantFailures: field.ErrorList{field.Required(nil, "exactly one structured model field must be set")},
// slice: func() *resource.NodeResourceSlice {
// slice := testNodeResourceSlice(goodName, goodName, driverName)
// slice.NodeResourceModel = resource.NodeResourceModel{}
// return slice
// }(),
// },
}
for name, scenario := range scenarios {
t.Run(name, func(t *testing.T) {
errs := ValidateNodeResourceSlice(scenario.slice)
assert.Equal(t, scenario.wantFailures, errs)
})
}
}
func TestValidateNodeResourceSliceUpdate(t *testing.T) {
name := "valid"
validNodeResourceSlice := testNodeResourceSlice(name, name, name)
scenarios := map[string]struct {
oldNodeResourceSlice *resource.NodeResourceSlice
update func(slice *resource.NodeResourceSlice) *resource.NodeResourceSlice
wantFailures field.ErrorList
}{
"valid-no-op-update": {
oldNodeResourceSlice: validNodeResourceSlice,
update: func(slice *resource.NodeResourceSlice) *resource.NodeResourceSlice { return slice },
},
"invalid-name-update": {
oldNodeResourceSlice: validNodeResourceSlice,
update: func(slice *resource.NodeResourceSlice) *resource.NodeResourceSlice {
slice.Name += "-update"
return slice
},
wantFailures: field.ErrorList{field.Invalid(field.NewPath("metadata", "name"), name+"-update", "field is immutable")},
},
"invalid-update-nodename": {
wantFailures: field.ErrorList{field.Invalid(field.NewPath("nodeName"), name+"-updated", "field is immutable")},
oldNodeResourceSlice: validNodeResourceSlice,
update: func(slice *resource.NodeResourceSlice) *resource.NodeResourceSlice {
slice.NodeName += "-updated"
return slice
},
},
"invalid-update-drivername": {
wantFailures: field.ErrorList{field.Invalid(field.NewPath("driverName"), name+"-updated", "field is immutable")},
oldNodeResourceSlice: validNodeResourceSlice,
update: func(slice *resource.NodeResourceSlice) *resource.NodeResourceSlice {
slice.DriverName += "-updated"
return slice
},
},
}
for name, scenario := range scenarios {
t.Run(name, func(t *testing.T) {
scenario.oldNodeResourceSlice.ResourceVersion = "1"
errs := ValidateNodeResourceSliceUpdate(scenario.update(scenario.oldNodeResourceSlice.DeepCopy()), scenario.oldNodeResourceSlice)
assert.Equal(t, scenario.wantFailures, errs)
})
}
}

View File

@@ -380,6 +380,81 @@ func TestValidateClaimStatusUpdate(t *testing.T) {
return claim
},
},
"valid-add-empty-allocation-structured": {
oldClaim: validClaim,
update: func(claim *resource.ResourceClaim) *resource.ResourceClaim {
claim.Status.DriverName = "valid"
claim.Status.Allocation = &resource.AllocationResult{
ResourceHandles: []resource.ResourceHandle{
{
DriverName: "valid",
StructuredData: &resource.StructuredResourceHandle{
NodeName: "worker",
},
},
},
}
return claim
},
},
"invalid-add-allocation-structured": {
wantFailures: field.ErrorList{
field.Invalid(field.NewPath("status", "allocation", "resourceHandles").Index(0).Child("structuredData", "nodeName"), "", "a lowercase RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')"),
},
oldClaim: validClaim,
update: func(claim *resource.ResourceClaim) *resource.ResourceClaim {
claim.Status.DriverName = "valid"
claim.Status.Allocation = &resource.AllocationResult{
ResourceHandles: []resource.ResourceHandle{
{
DriverName: "valid",
StructuredData: &resource.StructuredResourceHandle{
Results: []resource.DriverAllocationResult{
// TODO: empty AllocationResultMode
},
},
},
},
}
return claim
},
},
"valid-add-allocation-structured": {
oldClaim: validClaim,
update: func(claim *resource.ResourceClaim) *resource.ResourceClaim {
claim.Status.DriverName = "valid"
claim.Status.Allocation = &resource.AllocationResult{
ResourceHandles: []resource.ResourceHandle{
{
DriverName: "valid",
StructuredData: &resource.StructuredResourceHandle{
NodeName: "worker",
},
},
},
}
return claim
},
},
"invalid-duplicated-data": {
wantFailures: field.ErrorList{field.Invalid(field.NewPath("status", "allocation", "resourceHandles").Index(0), nil, "data and structuredData are mutually exclusive")},
oldClaim: validClaim,
update: func(claim *resource.ResourceClaim) *resource.ResourceClaim {
claim.Status.DriverName = "valid"
claim.Status.Allocation = &resource.AllocationResult{
ResourceHandles: []resource.ResourceHandle{
{
DriverName: "valid",
Data: "something",
StructuredData: &resource.StructuredResourceHandle{
NodeName: "worker",
},
},
},
}
return claim
},
},
"invalid-allocation-resourceHandles": {
wantFailures: field.ErrorList{field.TooLongMaxLength(field.NewPath("status", "allocation", "resourceHandles"), resource.AllocationResultResourceHandlesMaxSize+1, resource.AllocationResultResourceHandlesMaxSize)},
oldClaim: validClaim,
@@ -413,7 +488,7 @@ func TestValidateClaimStatusUpdate(t *testing.T) {
},
},
"invalid-allocation-resource-handle-data": {
wantFailures: field.ErrorList{field.TooLongMaxLength(field.NewPath("status", "allocation", "resourceHandles[0]", "data"), resource.ResourceHandleDataMaxSize+1, resource.ResourceHandleDataMaxSize)},
wantFailures: field.ErrorList{field.TooLongMaxLength(field.NewPath("status", "allocation", "resourceHandles").Index(0).Child("data"), resource.ResourceHandleDataMaxSize+1, resource.ResourceHandleDataMaxSize)},
oldClaim: validClaim,
update: func(claim *resource.ResourceClaim) *resource.ResourceClaim {
claim.Status.DriverName = "valid"

View File

@@ -0,0 +1,308 @@
/*
Copyright 2022 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.
*/
package validation
import (
"testing"
"github.com/stretchr/testify/assert"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/validation/field"
"k8s.io/kubernetes/pkg/apis/resource"
"k8s.io/utils/ptr"
)
func testResourceClaimParameters(name, namespace string, requests []resource.DriverRequests) *resource.ResourceClaimParameters {
return &resource.ResourceClaimParameters{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: namespace,
},
DriverRequests: requests,
}
}
var goodRequests []resource.DriverRequests
func TestValidateResourceClaimParameters(t *testing.T) {
goodName := "foo"
badName := "!@#$%^"
badValue := "spaces not allowed"
now := metav1.Now()
scenarios := map[string]struct {
parameters *resource.ResourceClaimParameters
wantFailures field.ErrorList
}{
"good": {
parameters: testResourceClaimParameters(goodName, goodName, goodRequests),
},
"missing-name": {
wantFailures: field.ErrorList{field.Required(field.NewPath("metadata", "name"), "name or generateName is required")},
parameters: testResourceClaimParameters("", goodName, goodRequests),
},
"missing-namespace": {
wantFailures: field.ErrorList{field.Required(field.NewPath("metadata", "namespace"), "")},
parameters: testResourceClaimParameters(goodName, "", goodRequests),
},
"bad-name": {
wantFailures: field.ErrorList{field.Invalid(field.NewPath("metadata", "name"), badName, "a lowercase RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')")},
parameters: testResourceClaimParameters(badName, goodName, goodRequests),
},
"bad-namespace": {
wantFailures: field.ErrorList{field.Invalid(field.NewPath("metadata", "namespace"), badName, "a lowercase RFC 1123 label must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character (e.g. 'my-name', or '123-abc', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?')")},
parameters: testResourceClaimParameters(goodName, badName, goodRequests),
},
"generate-name": {
parameters: func() *resource.ResourceClaimParameters {
parameters := testResourceClaimParameters(goodName, goodName, goodRequests)
parameters.GenerateName = "prefix-"
return parameters
}(),
},
"uid": {
parameters: func() *resource.ResourceClaimParameters {
parameters := testResourceClaimParameters(goodName, goodName, goodRequests)
parameters.UID = "ac051fac-2ead-46d9-b8b4-4e0fbeb7455d"
return parameters
}(),
},
"resource-version": {
parameters: func() *resource.ResourceClaimParameters {
parameters := testResourceClaimParameters(goodName, goodName, goodRequests)
parameters.ResourceVersion = "1"
return parameters
}(),
},
"generation": {
parameters: func() *resource.ResourceClaimParameters {
parameters := testResourceClaimParameters(goodName, goodName, goodRequests)
parameters.Generation = 100
return parameters
}(),
},
"creation-timestamp": {
parameters: func() *resource.ResourceClaimParameters {
parameters := testResourceClaimParameters(goodName, goodName, goodRequests)
parameters.CreationTimestamp = now
return parameters
}(),
},
"deletion-grace-period-seconds": {
parameters: func() *resource.ResourceClaimParameters {
parameters := testResourceClaimParameters(goodName, goodName, goodRequests)
parameters.DeletionGracePeriodSeconds = ptr.To[int64](10)
return parameters
}(),
},
"owner-references": {
parameters: func() *resource.ResourceClaimParameters {
parameters := testResourceClaimParameters(goodName, goodName, goodRequests)
parameters.OwnerReferences = []metav1.OwnerReference{
{
APIVersion: "v1",
Kind: "pod",
Name: "foo",
UID: "ac051fac-2ead-46d9-b8b4-4e0fbeb7455d",
},
}
return parameters
}(),
},
"finalizers": {
parameters: func() *resource.ResourceClaimParameters {
parameters := testResourceClaimParameters(goodName, goodName, goodRequests)
parameters.Finalizers = []string{
"example.com/foo",
}
return parameters
}(),
},
"managed-fields": {
parameters: func() *resource.ResourceClaimParameters {
parameters := testResourceClaimParameters(goodName, goodName, goodRequests)
parameters.ManagedFields = []metav1.ManagedFieldsEntry{
{
FieldsType: "FieldsV1",
Operation: "Apply",
APIVersion: "apps/v1",
Manager: "foo",
},
}
return parameters
}(),
},
"good-labels": {
parameters: func() *resource.ResourceClaimParameters {
parameters := testResourceClaimParameters(goodName, goodName, goodRequests)
parameters.Labels = map[string]string{
"apps.kubernetes.io/name": "test",
}
return parameters
}(),
},
"bad-labels": {
wantFailures: field.ErrorList{field.Invalid(field.NewPath("metadata", "labels"), badValue, "a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue', or 'my_value', or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')")},
parameters: func() *resource.ResourceClaimParameters {
parameters := testResourceClaimParameters(goodName, goodName, goodRequests)
parameters.Labels = map[string]string{
"hello-world": badValue,
}
return parameters
}(),
},
"good-annotations": {
parameters: func() *resource.ResourceClaimParameters {
parameters := testResourceClaimParameters(goodName, goodName, goodRequests)
parameters.Annotations = map[string]string{
"foo": "bar",
}
return parameters
}(),
},
"bad-annotations": {
wantFailures: field.ErrorList{field.Invalid(field.NewPath("metadata", "annotations"), badName, "name part must consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyName', or 'my.name', or '123-abc', regex used for validation is '([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]')")},
parameters: func() *resource.ResourceClaimParameters {
parameters := testResourceClaimParameters(goodName, goodName, goodRequests)
parameters.Annotations = map[string]string{
badName: "hello world",
}
return parameters
}(),
},
// TODO: implement one structured parameter model
// "empty-model": {
// wantFailures: field.ErrorList{field.Required(field.NewPath("driverRequests").Index(0).Child("requests").Index(0), "exactly one structured model field must be set")},
// parameters: func() *resource.ResourceClaimParameters {
// parameters := testResourceClaimParameters(goodName, goodName, goodRequests)
// parameters.DriverRequests = []resource.DriverRequests{{DriverName: goodName, Requests: []resource.ResourceRequest{{}}}}
// return parameters
// }(),
// },
"empty-requests": {
wantFailures: field.ErrorList{field.Required(field.NewPath("driverRequests").Index(0).Child("requests"), "empty entries with no requests are not allowed")},
parameters: func() *resource.ResourceClaimParameters {
parameters := testResourceClaimParameters(goodName, goodName, goodRequests)
parameters.DriverRequests = []resource.DriverRequests{{DriverName: goodName}}
return parameters
}(),
},
"invalid-driver": {
wantFailures: field.ErrorList{field.Invalid(field.NewPath("driverRequests").Index(1).Child("driverName"), badName, "a lowercase RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')")},
parameters: func() *resource.ResourceClaimParameters {
parameters := testResourceClaimParameters(goodName, goodName, goodRequests)
parameters.DriverRequests = []resource.DriverRequests{
{
DriverName: goodName,
Requests: []resource.ResourceRequest{
{
ResourceRequestModel: resource.ResourceRequestModel{
// TODO: implement one structured parameter model
},
},
},
},
{
DriverName: badName,
Requests: []resource.ResourceRequest{
{
ResourceRequestModel: resource.ResourceRequestModel{
// TODO: implement one structured parameter model
},
},
},
},
}
return parameters
}(),
},
"duplicate-driver": {
wantFailures: field.ErrorList{field.Duplicate(field.NewPath("driverRequests").Index(1).Child("driverName"), goodName)},
parameters: func() *resource.ResourceClaimParameters {
parameters := testResourceClaimParameters(goodName, goodName, goodRequests)
parameters.DriverRequests = []resource.DriverRequests{
{
DriverName: goodName,
Requests: []resource.ResourceRequest{
{
ResourceRequestModel: resource.ResourceRequestModel{
// TODO: implement one structured parameter model
},
},
},
},
{
DriverName: goodName,
Requests: []resource.ResourceRequest{
{
ResourceRequestModel: resource.ResourceRequestModel{
// TODO: implement one structured parameter model
},
},
},
},
}
return parameters
}(),
},
}
for name, scenario := range scenarios {
t.Run(name, func(t *testing.T) {
errs := ValidateResourceClaimParameters(scenario.parameters)
assert.Equal(t, scenario.wantFailures, errs)
})
}
}
func TestValidateResourceClaimParametersUpdate(t *testing.T) {
name := "valid"
validResourceClaimParameters := testResourceClaimParameters(name, name, nil)
scenarios := map[string]struct {
oldResourceClaimParameters *resource.ResourceClaimParameters
update func(claim *resource.ResourceClaimParameters) *resource.ResourceClaimParameters
wantFailures field.ErrorList
}{
"valid-no-op-update": {
oldResourceClaimParameters: validResourceClaimParameters,
update: func(claim *resource.ResourceClaimParameters) *resource.ResourceClaimParameters { return claim },
},
"invalid-name-update": {
oldResourceClaimParameters: validResourceClaimParameters,
update: func(claim *resource.ResourceClaimParameters) *resource.ResourceClaimParameters {
claim.Name += "-update"
return claim
},
wantFailures: field.ErrorList{field.Invalid(field.NewPath("metadata", "name"), name+"-update", "field is immutable")},
},
}
for name, scenario := range scenarios {
t.Run(name, func(t *testing.T) {
scenario.oldResourceClaimParameters.ResourceVersion = "1"
errs := ValidateResourceClaimParametersUpdate(scenario.update(scenario.oldResourceClaimParameters.DeepCopy()), scenario.oldResourceClaimParameters)
assert.Equal(t, scenario.wantFailures, errs)
})
}
}

View File

@@ -0,0 +1,312 @@
/*
Copyright 2022 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.
*/
package validation
import (
"testing"
"github.com/stretchr/testify/assert"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/validation/field"
"k8s.io/kubernetes/pkg/apis/resource"
"k8s.io/utils/ptr"
)
func testResourceClassParameters(name, namespace string, filters []resource.ResourceFilter) *resource.ResourceClassParameters {
return &resource.ResourceClassParameters{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: namespace,
},
Filters: filters,
}
}
var goodFilters []resource.ResourceFilter
func TestValidateResourceClassParameters(t *testing.T) {
goodName := "foo"
badName := "!@#$%^"
badValue := "spaces not allowed"
now := metav1.Now()
scenarios := map[string]struct {
parameters *resource.ResourceClassParameters
wantFailures field.ErrorList
}{
"good": {
parameters: testResourceClassParameters(goodName, goodName, goodFilters),
},
"missing-name": {
wantFailures: field.ErrorList{field.Required(field.NewPath("metadata", "name"), "name or generateName is required")},
parameters: testResourceClassParameters("", goodName, goodFilters),
},
"missing-namespace": {
wantFailures: field.ErrorList{field.Required(field.NewPath("metadata", "namespace"), "")},
parameters: testResourceClassParameters(goodName, "", goodFilters),
},
"bad-name": {
wantFailures: field.ErrorList{field.Invalid(field.NewPath("metadata", "name"), badName, "a lowercase RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')")},
parameters: testResourceClassParameters(badName, goodName, goodFilters),
},
"bad-namespace": {
wantFailures: field.ErrorList{field.Invalid(field.NewPath("metadata", "namespace"), badName, "a lowercase RFC 1123 label must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character (e.g. 'my-name', or '123-abc', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?')")},
parameters: testResourceClassParameters(goodName, badName, goodFilters),
},
"generate-name": {
parameters: func() *resource.ResourceClassParameters {
parameters := testResourceClassParameters(goodName, goodName, goodFilters)
parameters.GenerateName = "prefix-"
return parameters
}(),
},
"uid": {
parameters: func() *resource.ResourceClassParameters {
parameters := testResourceClassParameters(goodName, goodName, goodFilters)
parameters.UID = "ac051fac-2ead-46d9-b8b4-4e0fbeb7455d"
return parameters
}(),
},
"resource-version": {
parameters: func() *resource.ResourceClassParameters {
parameters := testResourceClassParameters(goodName, goodName, goodFilters)
parameters.ResourceVersion = "1"
return parameters
}(),
},
"generation": {
parameters: func() *resource.ResourceClassParameters {
parameters := testResourceClassParameters(goodName, goodName, goodFilters)
parameters.Generation = 100
return parameters
}(),
},
"creation-timestamp": {
parameters: func() *resource.ResourceClassParameters {
parameters := testResourceClassParameters(goodName, goodName, goodFilters)
parameters.CreationTimestamp = now
return parameters
}(),
},
"deletion-grace-period-seconds": {
parameters: func() *resource.ResourceClassParameters {
parameters := testResourceClassParameters(goodName, goodName, goodFilters)
parameters.DeletionGracePeriodSeconds = ptr.To[int64](10)
return parameters
}(),
},
"owner-references": {
parameters: func() *resource.ResourceClassParameters {
parameters := testResourceClassParameters(goodName, goodName, goodFilters)
parameters.OwnerReferences = []metav1.OwnerReference{
{
APIVersion: "v1",
Kind: "pod",
Name: "foo",
UID: "ac051fac-2ead-46d9-b8b4-4e0fbeb7455d",
},
}
return parameters
}(),
},
"finalizers": {
parameters: func() *resource.ResourceClassParameters {
parameters := testResourceClassParameters(goodName, goodName, goodFilters)
parameters.Finalizers = []string{
"example.com/foo",
}
return parameters
}(),
},
"managed-fields": {
parameters: func() *resource.ResourceClassParameters {
parameters := testResourceClassParameters(goodName, goodName, goodFilters)
parameters.ManagedFields = []metav1.ManagedFieldsEntry{
{
FieldsType: "FieldsV1",
Operation: "Apply",
APIVersion: "apps/v1",
Manager: "foo",
},
}
return parameters
}(),
},
"good-labels": {
parameters: func() *resource.ResourceClassParameters {
parameters := testResourceClassParameters(goodName, goodName, goodFilters)
parameters.Labels = map[string]string{
"apps.kubernetes.io/name": "test",
}
return parameters
}(),
},
"bad-labels": {
wantFailures: field.ErrorList{field.Invalid(field.NewPath("metadata", "labels"), badValue, "a valid label must be an empty string or consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyValue', or 'my_value', or '12345', regex used for validation is '(([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9])?')")},
parameters: func() *resource.ResourceClassParameters {
parameters := testResourceClassParameters(goodName, goodName, goodFilters)
parameters.Labels = map[string]string{
"hello-world": badValue,
}
return parameters
}(),
},
"good-annotations": {
parameters: func() *resource.ResourceClassParameters {
parameters := testResourceClassParameters(goodName, goodName, goodFilters)
parameters.Annotations = map[string]string{
"foo": "bar",
}
return parameters
}(),
},
"bad-annotations": {
wantFailures: field.ErrorList{field.Invalid(field.NewPath("metadata", "annotations"), badName, "name part must consist of alphanumeric characters, '-', '_' or '.', and must start and end with an alphanumeric character (e.g. 'MyName', or 'my.name', or '123-abc', regex used for validation is '([A-Za-z0-9][-A-Za-z0-9_.]*)?[A-Za-z0-9]')")},
parameters: func() *resource.ResourceClassParameters {
parameters := testResourceClassParameters(goodName, goodName, goodFilters)
parameters.Annotations = map[string]string{
badName: "hello world",
}
return parameters
}(),
},
// TODO: implement one structured parameter model
// "empty-model": {
// wantFailures: field.ErrorList{field.Required(field.NewPath("filters").Index(0), "exactly one structured model field must be set")},
// parameters: func() *resource.ResourceClassParameters {
// parameters := testResourceClassParameters(goodName, goodName, goodFilters)
// parameters.Filters = []resource.ResourceFilter{{DriverName: goodName}}
// return parameters
// }(),
// },
"filters-invalid-driver": {
wantFailures: field.ErrorList{field.Invalid(field.NewPath("filters").Index(1).Child("driverName"), badName, "a lowercase RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')")},
parameters: func() *resource.ResourceClassParameters {
parameters := testResourceClassParameters(goodName, goodName, goodFilters)
parameters.Filters = []resource.ResourceFilter{
{
DriverName: goodName,
ResourceFilterModel: resource.ResourceFilterModel{
// TODO: implement one structured parameter model
},
},
{
DriverName: badName,
ResourceFilterModel: resource.ResourceFilterModel{
// TODO: implement one structured parameter model
},
},
}
return parameters
}(),
},
"filters-duplicate-driver": {
wantFailures: field.ErrorList{field.Duplicate(field.NewPath("filters").Index(1).Child("driverName"), goodName)},
parameters: func() *resource.ResourceClassParameters {
parameters := testResourceClassParameters(goodName, goodName, goodFilters)
parameters.Filters = []resource.ResourceFilter{
{
DriverName: goodName,
ResourceFilterModel: resource.ResourceFilterModel{
// TODO: implement one structured parameter model
},
},
{
DriverName: goodName,
ResourceFilterModel: resource.ResourceFilterModel{},
},
}
return parameters
}(),
},
"parameters-invalid-driver": {
wantFailures: field.ErrorList{field.Invalid(field.NewPath("vendorParameters").Index(1).Child("driverName"), badName, "a lowercase RFC 1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')")},
parameters: func() *resource.ResourceClassParameters {
parameters := testResourceClassParameters(goodName, goodName, goodFilters)
parameters.VendorParameters = []resource.VendorParameters{
{
DriverName: goodName,
},
{
DriverName: badName,
},
}
return parameters
}(),
},
"parameters-duplicate-driver": {
wantFailures: field.ErrorList{field.Duplicate(field.NewPath("vendorParameters").Index(1).Child("driverName"), goodName)},
parameters: func() *resource.ResourceClassParameters {
parameters := testResourceClassParameters(goodName, goodName, goodFilters)
parameters.VendorParameters = []resource.VendorParameters{
{
DriverName: goodName,
},
{
DriverName: goodName,
},
}
return parameters
}(),
},
}
for name, scenario := range scenarios {
t.Run(name, func(t *testing.T) {
errs := ValidateResourceClassParameters(scenario.parameters)
assert.Equal(t, scenario.wantFailures, errs)
})
}
}
func TestValidateResourceClassParametersUpdate(t *testing.T) {
name := "valid"
validResourceClassParameters := testResourceClassParameters(name, name, nil)
scenarios := map[string]struct {
oldResourceClassParameters *resource.ResourceClassParameters
update func(class *resource.ResourceClassParameters) *resource.ResourceClassParameters
wantFailures field.ErrorList
}{
"valid-no-op-update": {
oldResourceClassParameters: validResourceClassParameters,
update: func(class *resource.ResourceClassParameters) *resource.ResourceClassParameters { return class },
},
"invalid-name-update": {
oldResourceClassParameters: validResourceClassParameters,
update: func(class *resource.ResourceClassParameters) *resource.ResourceClassParameters {
class.Name += "-update"
return class
},
wantFailures: field.ErrorList{field.Invalid(field.NewPath("metadata", "name"), name+"-update", "field is immutable")},
},
}
for name, scenario := range scenarios {
t.Run(name, func(t *testing.T) {
scenario.oldResourceClassParameters.ResourceVersion = "1"
errs := ValidateResourceClassParametersUpdate(scenario.update(scenario.oldResourceClassParameters.DeepCopy()), scenario.oldResourceClassParameters)
assert.Equal(t, scenario.wantFailures, errs)
})
}
}

View File

@@ -32,7 +32,9 @@ func (in *AllocationResult) DeepCopyInto(out *AllocationResult) {
if in.ResourceHandles != nil {
in, out := &in.ResourceHandles, &out.ResourceHandles
*out = make([]ResourceHandle, len(*in))
copy(*out, *in)
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
if in.AvailableOnNodes != nil {
in, out := &in.AvailableOnNodes, &out.AvailableOnNodes
@@ -52,6 +54,144 @@ func (in *AllocationResult) DeepCopy() *AllocationResult {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *AllocationResultModel) DeepCopyInto(out *AllocationResultModel) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AllocationResultModel.
func (in *AllocationResultModel) DeepCopy() *AllocationResultModel {
if in == nil {
return nil
}
out := new(AllocationResultModel)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *DriverAllocationResult) DeepCopyInto(out *DriverAllocationResult) {
*out = *in
if in.VendorRequestParameters != nil {
out.VendorRequestParameters = in.VendorRequestParameters.DeepCopyObject()
}
out.AllocationResultModel = in.AllocationResultModel
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DriverAllocationResult.
func (in *DriverAllocationResult) DeepCopy() *DriverAllocationResult {
if in == nil {
return nil
}
out := new(DriverAllocationResult)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *DriverRequests) DeepCopyInto(out *DriverRequests) {
*out = *in
if in.VendorParameters != nil {
out.VendorParameters = in.VendorParameters.DeepCopyObject()
}
if in.Requests != nil {
in, out := &in.Requests, &out.Requests
*out = make([]ResourceRequest, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DriverRequests.
func (in *DriverRequests) DeepCopy() *DriverRequests {
if in == nil {
return nil
}
out := new(DriverRequests)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *NodeResourceModel) DeepCopyInto(out *NodeResourceModel) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeResourceModel.
func (in *NodeResourceModel) DeepCopy() *NodeResourceModel {
if in == nil {
return nil
}
out := new(NodeResourceModel)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *NodeResourceSlice) DeepCopyInto(out *NodeResourceSlice) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
out.NodeResourceModel = in.NodeResourceModel
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeResourceSlice.
func (in *NodeResourceSlice) DeepCopy() *NodeResourceSlice {
if in == nil {
return nil
}
out := new(NodeResourceSlice)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *NodeResourceSlice) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *NodeResourceSliceList) DeepCopyInto(out *NodeResourceSliceList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]NodeResourceSlice, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeResourceSliceList.
func (in *NodeResourceSliceList) DeepCopy() *NodeResourceSliceList {
if in == nil {
return nil
}
out := new(NodeResourceSliceList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *NodeResourceSliceList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *PodSchedulingContext) DeepCopyInto(out *PodSchedulingContext) {
*out = *in
@@ -234,6 +374,77 @@ func (in *ResourceClaimList) DeepCopyObject() runtime.Object {
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ResourceClaimParameters) DeepCopyInto(out *ResourceClaimParameters) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
if in.GeneratedFrom != nil {
in, out := &in.GeneratedFrom, &out.GeneratedFrom
*out = new(ResourceClaimParametersReference)
**out = **in
}
if in.DriverRequests != nil {
in, out := &in.DriverRequests, &out.DriverRequests
*out = make([]DriverRequests, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceClaimParameters.
func (in *ResourceClaimParameters) DeepCopy() *ResourceClaimParameters {
if in == nil {
return nil
}
out := new(ResourceClaimParameters)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *ResourceClaimParameters) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ResourceClaimParametersList) DeepCopyInto(out *ResourceClaimParametersList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]ResourceClaimParameters, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceClaimParametersList.
func (in *ResourceClaimParametersList) DeepCopy() *ResourceClaimParametersList {
if in == nil {
return nil
}
out := new(ResourceClaimParametersList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *ResourceClaimParametersList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ResourceClaimParametersReference) DeepCopyInto(out *ResourceClaimParametersReference) {
*out = *in
@@ -411,6 +622,11 @@ func (in *ResourceClass) DeepCopyInto(out *ResourceClass) {
*out = new(core.NodeSelector)
(*in).DeepCopyInto(*out)
}
if in.StructuredParameters != nil {
in, out := &in.StructuredParameters, &out.StructuredParameters
*out = new(bool)
**out = **in
}
return
}
@@ -465,6 +681,82 @@ func (in *ResourceClassList) DeepCopyObject() runtime.Object {
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ResourceClassParameters) DeepCopyInto(out *ResourceClassParameters) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
if in.GeneratedFrom != nil {
in, out := &in.GeneratedFrom, &out.GeneratedFrom
*out = new(ResourceClassParametersReference)
**out = **in
}
if in.VendorParameters != nil {
in, out := &in.VendorParameters, &out.VendorParameters
*out = make([]VendorParameters, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
if in.Filters != nil {
in, out := &in.Filters, &out.Filters
*out = make([]ResourceFilter, len(*in))
copy(*out, *in)
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceClassParameters.
func (in *ResourceClassParameters) DeepCopy() *ResourceClassParameters {
if in == nil {
return nil
}
out := new(ResourceClassParameters)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *ResourceClassParameters) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ResourceClassParametersList) DeepCopyInto(out *ResourceClassParametersList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]ResourceClassParameters, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceClassParametersList.
func (in *ResourceClassParametersList) DeepCopy() *ResourceClassParametersList {
if in == nil {
return nil
}
out := new(ResourceClassParametersList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *ResourceClassParametersList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ResourceClassParametersReference) DeepCopyInto(out *ResourceClassParametersReference) {
*out = *in
@@ -481,9 +773,47 @@ func (in *ResourceClassParametersReference) DeepCopy() *ResourceClassParametersR
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ResourceFilter) DeepCopyInto(out *ResourceFilter) {
*out = *in
out.ResourceFilterModel = in.ResourceFilterModel
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceFilter.
func (in *ResourceFilter) DeepCopy() *ResourceFilter {
if in == nil {
return nil
}
out := new(ResourceFilter)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ResourceFilterModel) DeepCopyInto(out *ResourceFilterModel) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceFilterModel.
func (in *ResourceFilterModel) DeepCopy() *ResourceFilterModel {
if in == nil {
return nil
}
out := new(ResourceFilterModel)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ResourceHandle) DeepCopyInto(out *ResourceHandle) {
*out = *in
if in.StructuredData != nil {
in, out := &in.StructuredData, &out.StructuredData
*out = new(StructuredResourceHandle)
(*in).DeepCopyInto(*out)
}
return
}
@@ -496,3 +826,87 @@ func (in *ResourceHandle) DeepCopy() *ResourceHandle {
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ResourceRequest) DeepCopyInto(out *ResourceRequest) {
*out = *in
if in.VendorParameters != nil {
out.VendorParameters = in.VendorParameters.DeepCopyObject()
}
out.ResourceRequestModel = in.ResourceRequestModel
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceRequest.
func (in *ResourceRequest) DeepCopy() *ResourceRequest {
if in == nil {
return nil
}
out := new(ResourceRequest)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ResourceRequestModel) DeepCopyInto(out *ResourceRequestModel) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceRequestModel.
func (in *ResourceRequestModel) DeepCopy() *ResourceRequestModel {
if in == nil {
return nil
}
out := new(ResourceRequestModel)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *StructuredResourceHandle) DeepCopyInto(out *StructuredResourceHandle) {
*out = *in
if in.VendorClassParameters != nil {
out.VendorClassParameters = in.VendorClassParameters.DeepCopyObject()
}
if in.VendorClaimParameters != nil {
out.VendorClaimParameters = in.VendorClaimParameters.DeepCopyObject()
}
if in.Results != nil {
in, out := &in.Results, &out.Results
*out = make([]DriverAllocationResult, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StructuredResourceHandle.
func (in *StructuredResourceHandle) DeepCopy() *StructuredResourceHandle {
if in == nil {
return nil
}
out := new(StructuredResourceHandle)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *VendorParameters) DeepCopyInto(out *VendorParameters) {
*out = *in
if in.Parameters != nil {
out.Parameters = in.Parameters.DeepCopyObject()
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VendorParameters.
func (in *VendorParameters) DeepCopy() *VendorParameters {
if in == nil {
return nil
}
out := new(VendorParameters)
in.DeepCopyInto(out)
return out
}

View File

@@ -868,6 +868,12 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
"k8s.io/api/rbac/v1beta1.RoleRef": schema_k8sio_api_rbac_v1beta1_RoleRef(ref),
"k8s.io/api/rbac/v1beta1.Subject": schema_k8sio_api_rbac_v1beta1_Subject(ref),
"k8s.io/api/resource/v1alpha2.AllocationResult": schema_k8sio_api_resource_v1alpha2_AllocationResult(ref),
"k8s.io/api/resource/v1alpha2.AllocationResultModel": schema_k8sio_api_resource_v1alpha2_AllocationResultModel(ref),
"k8s.io/api/resource/v1alpha2.DriverAllocationResult": schema_k8sio_api_resource_v1alpha2_DriverAllocationResult(ref),
"k8s.io/api/resource/v1alpha2.DriverRequests": schema_k8sio_api_resource_v1alpha2_DriverRequests(ref),
"k8s.io/api/resource/v1alpha2.NodeResourceModel": schema_k8sio_api_resource_v1alpha2_NodeResourceModel(ref),
"k8s.io/api/resource/v1alpha2.NodeResourceSlice": schema_k8sio_api_resource_v1alpha2_NodeResourceSlice(ref),
"k8s.io/api/resource/v1alpha2.NodeResourceSliceList": schema_k8sio_api_resource_v1alpha2_NodeResourceSliceList(ref),
"k8s.io/api/resource/v1alpha2.PodSchedulingContext": schema_k8sio_api_resource_v1alpha2_PodSchedulingContext(ref),
"k8s.io/api/resource/v1alpha2.PodSchedulingContextList": schema_k8sio_api_resource_v1alpha2_PodSchedulingContextList(ref),
"k8s.io/api/resource/v1alpha2.PodSchedulingContextSpec": schema_k8sio_api_resource_v1alpha2_PodSchedulingContextSpec(ref),
@@ -875,6 +881,8 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
"k8s.io/api/resource/v1alpha2.ResourceClaim": schema_k8sio_api_resource_v1alpha2_ResourceClaim(ref),
"k8s.io/api/resource/v1alpha2.ResourceClaimConsumerReference": schema_k8sio_api_resource_v1alpha2_ResourceClaimConsumerReference(ref),
"k8s.io/api/resource/v1alpha2.ResourceClaimList": schema_k8sio_api_resource_v1alpha2_ResourceClaimList(ref),
"k8s.io/api/resource/v1alpha2.ResourceClaimParameters": schema_k8sio_api_resource_v1alpha2_ResourceClaimParameters(ref),
"k8s.io/api/resource/v1alpha2.ResourceClaimParametersList": schema_k8sio_api_resource_v1alpha2_ResourceClaimParametersList(ref),
"k8s.io/api/resource/v1alpha2.ResourceClaimParametersReference": schema_k8sio_api_resource_v1alpha2_ResourceClaimParametersReference(ref),
"k8s.io/api/resource/v1alpha2.ResourceClaimSchedulingStatus": schema_k8sio_api_resource_v1alpha2_ResourceClaimSchedulingStatus(ref),
"k8s.io/api/resource/v1alpha2.ResourceClaimSpec": schema_k8sio_api_resource_v1alpha2_ResourceClaimSpec(ref),
@@ -884,8 +892,16 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA
"k8s.io/api/resource/v1alpha2.ResourceClaimTemplateSpec": schema_k8sio_api_resource_v1alpha2_ResourceClaimTemplateSpec(ref),
"k8s.io/api/resource/v1alpha2.ResourceClass": schema_k8sio_api_resource_v1alpha2_ResourceClass(ref),
"k8s.io/api/resource/v1alpha2.ResourceClassList": schema_k8sio_api_resource_v1alpha2_ResourceClassList(ref),
"k8s.io/api/resource/v1alpha2.ResourceClassParameters": schema_k8sio_api_resource_v1alpha2_ResourceClassParameters(ref),
"k8s.io/api/resource/v1alpha2.ResourceClassParametersList": schema_k8sio_api_resource_v1alpha2_ResourceClassParametersList(ref),
"k8s.io/api/resource/v1alpha2.ResourceClassParametersReference": schema_k8sio_api_resource_v1alpha2_ResourceClassParametersReference(ref),
"k8s.io/api/resource/v1alpha2.ResourceFilter": schema_k8sio_api_resource_v1alpha2_ResourceFilter(ref),
"k8s.io/api/resource/v1alpha2.ResourceFilterModel": schema_k8sio_api_resource_v1alpha2_ResourceFilterModel(ref),
"k8s.io/api/resource/v1alpha2.ResourceHandle": schema_k8sio_api_resource_v1alpha2_ResourceHandle(ref),
"k8s.io/api/resource/v1alpha2.ResourceRequest": schema_k8sio_api_resource_v1alpha2_ResourceRequest(ref),
"k8s.io/api/resource/v1alpha2.ResourceRequestModel": schema_k8sio_api_resource_v1alpha2_ResourceRequestModel(ref),
"k8s.io/api/resource/v1alpha2.StructuredResourceHandle": schema_k8sio_api_resource_v1alpha2_StructuredResourceHandle(ref),
"k8s.io/api/resource/v1alpha2.VendorParameters": schema_k8sio_api_resource_v1alpha2_VendorParameters(ref),
"k8s.io/api/scheduling/v1.PriorityClass": schema_k8sio_api_scheduling_v1_PriorityClass(ref),
"k8s.io/api/scheduling/v1.PriorityClassList": schema_k8sio_api_scheduling_v1_PriorityClassList(ref),
"k8s.io/api/scheduling/v1alpha1.PriorityClass": schema_k8sio_api_scheduling_v1alpha1_PriorityClass(ref),
@@ -44711,6 +44727,200 @@ func schema_k8sio_api_resource_v1alpha2_AllocationResult(ref common.ReferenceCal
}
}
func schema_k8sio_api_resource_v1alpha2_AllocationResultModel(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "AllocationResultModel must have one and only one field set.",
Type: []string{"object"},
},
},
}
}
func schema_k8sio_api_resource_v1alpha2_DriverAllocationResult(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "DriverAllocationResult contains vendor parameters and the allocation result for one request.",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"vendorRequestParameters": {
SchemaProps: spec.SchemaProps{
Description: "VendorRequestParameters are the per-request configuration parameters from the time that the claim was allocated.",
Ref: ref("k8s.io/apimachinery/pkg/runtime.RawExtension"),
},
},
},
},
},
Dependencies: []string{
"k8s.io/apimachinery/pkg/runtime.RawExtension"},
}
}
func schema_k8sio_api_resource_v1alpha2_DriverRequests(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "DriverRequests describes all resources that are needed from one particular driver.",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"driverName": {
SchemaProps: spec.SchemaProps{
Description: "DriverName is the name used by the DRA driver kubelet plugin.",
Type: []string{"string"},
Format: "",
},
},
"vendorParameters": {
SchemaProps: spec.SchemaProps{
Description: "VendorParameters are arbitrary setup parameters for all requests of the claim. They are ignored while allocating the claim.",
Ref: ref("k8s.io/apimachinery/pkg/runtime.RawExtension"),
},
},
"requests": {
VendorExtensible: spec.VendorExtensible{
Extensions: spec.Extensions{
"x-kubernetes-list-type": "atomic",
},
},
SchemaProps: spec.SchemaProps{
Description: "Requests describes all resources that are needed from the driver.",
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("k8s.io/api/resource/v1alpha2.ResourceRequest"),
},
},
},
},
},
},
},
},
Dependencies: []string{
"k8s.io/api/resource/v1alpha2.ResourceRequest", "k8s.io/apimachinery/pkg/runtime.RawExtension"},
}
}
func schema_k8sio_api_resource_v1alpha2_NodeResourceModel(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "NodeResourceModel must have one and only one field set.",
Type: []string{"object"},
},
},
}
}
func schema_k8sio_api_resource_v1alpha2_NodeResourceSlice(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "NodeResourceSlice provides information about available resources on individual nodes.",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"kind": {
SchemaProps: spec.SchemaProps{
Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds",
Type: []string{"string"},
Format: "",
},
},
"apiVersion": {
SchemaProps: spec.SchemaProps{
Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources",
Type: []string{"string"},
Format: "",
},
},
"metadata": {
SchemaProps: spec.SchemaProps{
Description: "Standard object metadata",
Default: map[string]interface{}{},
Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"),
},
},
"nodeName": {
SchemaProps: spec.SchemaProps{
Description: "NodeName identifies the node where the capacity is available. A field selector can be used to list only NodeResourceSlice objects with a certain node name.",
Default: "",
Type: []string{"string"},
Format: "",
},
},
"driverName": {
SchemaProps: spec.SchemaProps{
Description: "DriverName identifies the DRA driver providing the capacity information. A field selector can be used to list only NodeResourceSlice objects with a certain driver name.",
Default: "",
Type: []string{"string"},
Format: "",
},
},
},
Required: []string{"nodeName", "driverName"},
},
},
Dependencies: []string{
"k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"},
}
}
func schema_k8sio_api_resource_v1alpha2_NodeResourceSliceList(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "NodeResourceSliceList is a collection of NodeResourceSlices.",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"kind": {
SchemaProps: spec.SchemaProps{
Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds",
Type: []string{"string"},
Format: "",
},
},
"apiVersion": {
SchemaProps: spec.SchemaProps{
Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources",
Type: []string{"string"},
Format: "",
},
},
"metadata": {
SchemaProps: spec.SchemaProps{
Description: "Standard list metadata",
Default: map[string]interface{}{},
Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"),
},
},
"items": {
SchemaProps: spec.SchemaProps{
Description: "Items is the list of node resource capacity objects.",
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("k8s.io/api/resource/v1alpha2.NodeResourceSlice"),
},
},
},
},
},
},
Required: []string{"items"},
},
},
Dependencies: []string{
"k8s.io/api/resource/v1alpha2.NodeResourceSlice", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"},
}
}
func schema_k8sio_api_resource_v1alpha2_PodSchedulingContext(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
@@ -45037,6 +45247,125 @@ func schema_k8sio_api_resource_v1alpha2_ResourceClaimList(ref common.ReferenceCa
}
}
func schema_k8sio_api_resource_v1alpha2_ResourceClaimParameters(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "ResourceClaimParameters defines resource requests for a ResourceClaim in an in-tree format understood by Kubernetes.",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"kind": {
SchemaProps: spec.SchemaProps{
Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds",
Type: []string{"string"},
Format: "",
},
},
"apiVersion": {
SchemaProps: spec.SchemaProps{
Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources",
Type: []string{"string"},
Format: "",
},
},
"metadata": {
SchemaProps: spec.SchemaProps{
Description: "Standard object metadata",
Default: map[string]interface{}{},
Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"),
},
},
"generatedFrom": {
SchemaProps: spec.SchemaProps{
Description: "If this object was created from some other resource, then this links back to that resource. This field is used to find the in-tree representation of the claim parameters when the parameter reference of the claim refers to some unknown type.",
Ref: ref("k8s.io/api/resource/v1alpha2.ResourceClaimParametersReference"),
},
},
"shareable": {
SchemaProps: spec.SchemaProps{
Description: "Shareable indicates whether the allocated claim is meant to be shareable by multiple consumers at the same time.",
Type: []string{"boolean"},
Format: "",
},
},
"driverRequests": {
VendorExtensible: spec.VendorExtensible{
Extensions: spec.Extensions{
"x-kubernetes-list-type": "atomic",
},
},
SchemaProps: spec.SchemaProps{
Description: "DriverRequests describes all resources that are needed for the allocated claim. A single claim may use resources coming from different drivers. For each driver, this array has at most one entry which then may have one or more per-driver requests.\n\nMay be empty, in which case the claim can always be allocated.",
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("k8s.io/api/resource/v1alpha2.DriverRequests"),
},
},
},
},
},
},
},
},
Dependencies: []string{
"k8s.io/api/resource/v1alpha2.DriverRequests", "k8s.io/api/resource/v1alpha2.ResourceClaimParametersReference", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"},
}
}
func schema_k8sio_api_resource_v1alpha2_ResourceClaimParametersList(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "ResourceClaimParametersList is a collection of ResourceClaimParameters.",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"kind": {
SchemaProps: spec.SchemaProps{
Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds",
Type: []string{"string"},
Format: "",
},
},
"apiVersion": {
SchemaProps: spec.SchemaProps{
Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources",
Type: []string{"string"},
Format: "",
},
},
"metadata": {
SchemaProps: spec.SchemaProps{
Description: "Standard list metadata",
Default: map[string]interface{}{},
Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"),
},
},
"items": {
SchemaProps: spec.SchemaProps{
Description: "Items is the list of node resource capacity objects.",
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("k8s.io/api/resource/v1alpha2.ResourceClaimParameters"),
},
},
},
},
},
},
Required: []string{"items"},
},
},
Dependencies: []string{
"k8s.io/api/resource/v1alpha2.ResourceClaimParameters", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"},
}
}
func schema_k8sio_api_resource_v1alpha2_ResourceClaimParametersReference(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
@@ -45383,6 +45712,13 @@ func schema_k8sio_api_resource_v1alpha2_ResourceClass(ref common.ReferenceCallba
Ref: ref("k8s.io/api/core/v1.NodeSelector"),
},
},
"structuredParameters": {
SchemaProps: spec.SchemaProps{
Description: "If and only if allocation of claims using this class is handled via structured parameters, then StructuredParameters must be set to true.",
Type: []string{"boolean"},
Format: "",
},
},
},
Required: []string{"driverName"},
},
@@ -45443,6 +45779,137 @@ func schema_k8sio_api_resource_v1alpha2_ResourceClassList(ref common.ReferenceCa
}
}
func schema_k8sio_api_resource_v1alpha2_ResourceClassParameters(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "ResourceClassParameters defines resource requests for a ResourceClass in an in-tree format understood by Kubernetes.",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"kind": {
SchemaProps: spec.SchemaProps{
Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds",
Type: []string{"string"},
Format: "",
},
},
"apiVersion": {
SchemaProps: spec.SchemaProps{
Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources",
Type: []string{"string"},
Format: "",
},
},
"metadata": {
SchemaProps: spec.SchemaProps{
Description: "Standard object metadata",
Default: map[string]interface{}{},
Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"),
},
},
"generatedFrom": {
SchemaProps: spec.SchemaProps{
Description: "If this object was created from some other resource, then this links back to that resource. This field is used to find the in-tree representation of the class parameters when the parameter reference of the class refers to some unknown type.",
Ref: ref("k8s.io/api/resource/v1alpha2.ResourceClassParametersReference"),
},
},
"vendorParameters": {
VendorExtensible: spec.VendorExtensible{
Extensions: spec.Extensions{
"x-kubernetes-list-type": "atomic",
},
},
SchemaProps: spec.SchemaProps{
Description: "VendorParameters are arbitrary setup parameters for all claims using this class. They are ignored while allocating the claim. There must not be more than one entry per driver.",
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("k8s.io/api/resource/v1alpha2.VendorParameters"),
},
},
},
},
},
"filters": {
VendorExtensible: spec.VendorExtensible{
Extensions: spec.Extensions{
"x-kubernetes-list-type": "atomic",
},
},
SchemaProps: spec.SchemaProps{
Description: "Filters describes additional contraints that must be met when using the class.",
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("k8s.io/api/resource/v1alpha2.ResourceFilter"),
},
},
},
},
},
},
},
},
Dependencies: []string{
"k8s.io/api/resource/v1alpha2.ResourceClassParametersReference", "k8s.io/api/resource/v1alpha2.ResourceFilter", "k8s.io/api/resource/v1alpha2.VendorParameters", "k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta"},
}
}
func schema_k8sio_api_resource_v1alpha2_ResourceClassParametersList(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "ResourceClassParametersList is a collection of ResourceClassParameters.",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"kind": {
SchemaProps: spec.SchemaProps{
Description: "Kind is a string value representing the REST resource this object represents. Servers may infer this from the endpoint the client submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds",
Type: []string{"string"},
Format: "",
},
},
"apiVersion": {
SchemaProps: spec.SchemaProps{
Description: "APIVersion defines the versioned schema of this representation of an object. Servers should convert recognized schemas to the latest internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources",
Type: []string{"string"},
Format: "",
},
},
"metadata": {
SchemaProps: spec.SchemaProps{
Description: "Standard list metadata",
Default: map[string]interface{}{},
Ref: ref("k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"),
},
},
"items": {
SchemaProps: spec.SchemaProps{
Description: "Items is the list of node resource capacity objects.",
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("k8s.io/api/resource/v1alpha2.ResourceClassParameters"),
},
},
},
},
},
},
Required: []string{"items"},
},
},
Dependencies: []string{
"k8s.io/api/resource/v1alpha2.ResourceClassParameters", "k8s.io/apimachinery/pkg/apis/meta/v1.ListMeta"},
}
}
func schema_k8sio_api_resource_v1alpha2_ResourceClassParametersReference(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
@@ -45487,6 +45954,37 @@ func schema_k8sio_api_resource_v1alpha2_ResourceClassParametersReference(ref com
}
}
func schema_k8sio_api_resource_v1alpha2_ResourceFilter(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "ResourceFilter is a filter for resources from one particular driver.",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"driverName": {
SchemaProps: spec.SchemaProps{
Description: "DriverName is the name used by the DRA driver kubelet plugin.",
Type: []string{"string"},
Format: "",
},
},
},
},
},
}
}
func schema_k8sio_api_resource_v1alpha2_ResourceFilterModel(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "ResourceFilterModel must have one and only one field set.",
Type: []string{"object"},
},
},
}
}
func schema_k8sio_api_resource_v1alpha2_ResourceHandle(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
@@ -45508,9 +46006,132 @@ func schema_k8sio_api_resource_v1alpha2_ResourceHandle(ref common.ReferenceCallb
Format: "",
},
},
"structuredData": {
SchemaProps: spec.SchemaProps{
Description: "If StructuredData is set, then it needs to be used instead of Data.",
Ref: ref("k8s.io/api/resource/v1alpha2.StructuredResourceHandle"),
},
},
},
},
},
Dependencies: []string{
"k8s.io/api/resource/v1alpha2.StructuredResourceHandle"},
}
}
func schema_k8sio_api_resource_v1alpha2_ResourceRequest(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "ResourceRequest is a request for resources from one particular driver.",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"vendorParameters": {
SchemaProps: spec.SchemaProps{
Description: "VendorParameters are arbitrary setup parameters for the requested resource. They are ignored while allocating a claim.",
Ref: ref("k8s.io/apimachinery/pkg/runtime.RawExtension"),
},
},
},
},
},
Dependencies: []string{
"k8s.io/apimachinery/pkg/runtime.RawExtension"},
}
}
func schema_k8sio_api_resource_v1alpha2_ResourceRequestModel(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "ResourceRequestModel must have one and only one field set.",
Type: []string{"object"},
},
},
}
}
func schema_k8sio_api_resource_v1alpha2_StructuredResourceHandle(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "StructuredResourceHandle is the in-tree representation of the allocation result.",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"vendorClassParameters": {
SchemaProps: spec.SchemaProps{
Description: "VendorClassParameters are the per-claim configuration parameters from the resource class at the time that the claim was allocated.",
Ref: ref("k8s.io/apimachinery/pkg/runtime.RawExtension"),
},
},
"vendorClaimParameters": {
SchemaProps: spec.SchemaProps{
Description: "VendorClaimParameters are the per-claim configuration parameters from the resource claim parameters at the time that the claim was allocated.",
Ref: ref("k8s.io/apimachinery/pkg/runtime.RawExtension"),
},
},
"nodeName": {
SchemaProps: spec.SchemaProps{
Description: "NodeName is the name of the node providing the necessary resources.",
Default: "",
Type: []string{"string"},
Format: "",
},
},
"results": {
VendorExtensible: spec.VendorExtensible{
Extensions: spec.Extensions{
"x-kubernetes-list-type": "atomic",
},
},
SchemaProps: spec.SchemaProps{
Description: "Results lists all allocated driver resources.",
Type: []string{"array"},
Items: &spec.SchemaOrArray{
Schema: &spec.Schema{
SchemaProps: spec.SchemaProps{
Default: map[string]interface{}{},
Ref: ref("k8s.io/api/resource/v1alpha2.DriverAllocationResult"),
},
},
},
},
},
},
Required: []string{"nodeName", "results"},
},
},
Dependencies: []string{
"k8s.io/api/resource/v1alpha2.DriverAllocationResult", "k8s.io/apimachinery/pkg/runtime.RawExtension"},
}
}
func schema_k8sio_api_resource_v1alpha2_VendorParameters(ref common.ReferenceCallback) common.OpenAPIDefinition {
return common.OpenAPIDefinition{
Schema: spec.Schema{
SchemaProps: spec.SchemaProps{
Description: "VendorParameters are opaque parameters for one particular driver.",
Type: []string{"object"},
Properties: map[string]spec.Schema{
"driverName": {
SchemaProps: spec.SchemaProps{
Description: "DriverName is the name used by the DRA driver kubelet plugin.",
Type: []string{"string"},
Format: "",
},
},
"parameters": {
SchemaProps: spec.SchemaProps{
Description: "Parameters can be arbitrary setup parameters. They are ignored while allocating a claim.",
Ref: ref("k8s.io/apimachinery/pkg/runtime.RawExtension"),
},
},
},
},
},
Dependencies: []string{
"k8s.io/apimachinery/pkg/runtime.RawExtension"},
}
}

View File

@@ -656,6 +656,31 @@ func AddHandlers(h printers.PrintHandler) {
_ = h.TableHandler(podSchedulingCtxColumnDefinitions, printPodSchedulingContext)
_ = h.TableHandler(podSchedulingCtxColumnDefinitions, printPodSchedulingContextList)
resourceClaimParametersColumnDefinitions := []metav1.TableColumnDefinition{
{Name: "Name", Type: "string", Format: "name", Description: metav1.ObjectMeta{}.SwaggerDoc()["name"]},
{Name: "GeneratedFrom", Type: "string", Description: resourcev1alpha2.ResourceClaimParameters{}.SwaggerDoc()["generatedFrom"]},
{Name: "Age", Type: "string", Description: metav1.ObjectMeta{}.SwaggerDoc()["creationTimestamp"]},
}
_ = h.TableHandler(resourceClaimParametersColumnDefinitions, printResourceClaimParameters)
_ = h.TableHandler(resourceClaimParametersColumnDefinitions, printResourceClaimParametersList)
resourceClassParametersColumnDefinitions := []metav1.TableColumnDefinition{
{Name: "Name", Type: "string", Format: "name", Description: metav1.ObjectMeta{}.SwaggerDoc()["name"]},
{Name: "GeneratedFrom", Type: "string", Description: resourcev1alpha2.ResourceClassParameters{}.SwaggerDoc()["generatedFrom"]},
{Name: "Age", Type: "string", Description: metav1.ObjectMeta{}.SwaggerDoc()["creationTimestamp"]},
}
_ = h.TableHandler(resourceClassParametersColumnDefinitions, printResourceClassParameters)
_ = h.TableHandler(resourceClassParametersColumnDefinitions, printResourceClassParametersList)
nodeResourceCapacityColumnDefinitions := []metav1.TableColumnDefinition{
{Name: "Name", Type: "string", Format: "name", Description: metav1.ObjectMeta{}.SwaggerDoc()["name"]},
{Name: "Node", Type: "string", Description: resourcev1alpha2.NodeResourceSlice{}.SwaggerDoc()["nodeName"]},
{Name: "Driver", Type: "string", Description: resourcev1alpha2.NodeResourceSlice{}.SwaggerDoc()["driverName"]},
{Name: "Age", Type: "string", Description: metav1.ObjectMeta{}.SwaggerDoc()["creationTimestamp"]},
}
_ = h.TableHandler(nodeResourceCapacityColumnDefinitions, printNodeResourceSlice)
_ = h.TableHandler(nodeResourceCapacityColumnDefinitions, printNodeResourceSliceList)
serviceCIDRColumnDefinitions := []metav1.TableColumnDefinition{
{Name: "Name", Type: "string", Format: "name", Description: metav1.ObjectMeta{}.SwaggerDoc()["name"]},
{Name: "CIDRs", Type: "string", Description: networkingv1alpha1.ServiceCIDRSpec{}.SwaggerDoc()["cidrs"]},
@@ -3046,6 +3071,77 @@ func printPodSchedulingContextList(list *resource.PodSchedulingContextList, opti
return rows, nil
}
func printResourceClaimParameters(obj *resource.ResourceClaimParameters, options printers.GenerateOptions) ([]metav1.TableRow, error) {
row := metav1.TableRow{
Object: runtime.RawExtension{Object: obj},
}
generatedFrom := ""
if obj.GeneratedFrom != nil {
generatedFrom = fmt.Sprintf("%s.%s %s", obj.GeneratedFrom.Kind, obj.GeneratedFrom.APIGroup, obj.GeneratedFrom.Name)
}
row.Cells = append(row.Cells, obj.Name, generatedFrom, translateTimestampSince(obj.CreationTimestamp))
return []metav1.TableRow{row}, nil
}
func printResourceClaimParametersList(list *resource.ResourceClaimParametersList, options printers.GenerateOptions) ([]metav1.TableRow, error) {
rows := make([]metav1.TableRow, 0, len(list.Items))
for i := range list.Items {
r, err := printResourceClaimParameters(&list.Items[i], options)
if err != nil {
return nil, err
}
rows = append(rows, r...)
}
return rows, nil
}
func printResourceClassParameters(obj *resource.ResourceClassParameters, options printers.GenerateOptions) ([]metav1.TableRow, error) {
row := metav1.TableRow{
Object: runtime.RawExtension{Object: obj},
}
generatedFrom := ""
if obj.GeneratedFrom != nil {
generatedFrom = fmt.Sprintf("%s.%s %s", obj.GeneratedFrom.Kind, obj.GeneratedFrom.APIGroup, obj.GeneratedFrom.Name)
}
row.Cells = append(row.Cells, obj.Name, generatedFrom, translateTimestampSince(obj.CreationTimestamp))
return []metav1.TableRow{row}, nil
}
func printResourceClassParametersList(list *resource.ResourceClassParametersList, options printers.GenerateOptions) ([]metav1.TableRow, error) {
rows := make([]metav1.TableRow, 0, len(list.Items))
for i := range list.Items {
r, err := printResourceClassParameters(&list.Items[i], options)
if err != nil {
return nil, err
}
rows = append(rows, r...)
}
return rows, nil
}
func printNodeResourceSlice(obj *resource.NodeResourceSlice, options printers.GenerateOptions) ([]metav1.TableRow, error) {
row := metav1.TableRow{
Object: runtime.RawExtension{Object: obj},
}
row.Cells = append(row.Cells, obj.Name, obj.NodeName, obj.DriverName, translateTimestampSince(obj.CreationTimestamp))
return []metav1.TableRow{row}, nil
}
func printNodeResourceSliceList(list *resource.NodeResourceSliceList, options printers.GenerateOptions) ([]metav1.TableRow, error) {
rows := make([]metav1.TableRow, 0, len(list.Items))
for i := range list.Items {
r, err := printNodeResourceSlice(&list.Items[i], options)
if err != nil {
return nil, err
}
rows = append(rows, r...)
}
return rows, nil
}
func printBoolPtr(value *bool) string {
if value != nil {
return printBool(*value)

View File

@@ -0,0 +1,62 @@
/*
Copyright 2022 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.
*/
package storage
import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apiserver/pkg/registry/generic"
genericregistry "k8s.io/apiserver/pkg/registry/generic/registry"
"k8s.io/kubernetes/pkg/apis/resource"
"k8s.io/kubernetes/pkg/printers"
printersinternal "k8s.io/kubernetes/pkg/printers/internalversion"
printerstorage "k8s.io/kubernetes/pkg/printers/storage"
"k8s.io/kubernetes/pkg/registry/resource/noderesourceslice"
)
// REST implements a RESTStorage for NodeResourceSlice.
type REST struct {
*genericregistry.Store
}
// NewREST returns a RESTStorage object that will work against NodeResourceSlice.
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
store := &genericregistry.Store{
NewFunc: func() runtime.Object { return &resource.NodeResourceSlice{} },
NewListFunc: func() runtime.Object { return &resource.NodeResourceSliceList{} },
PredicateFunc: noderesourceslice.Match,
DefaultQualifiedResource: resource.Resource("noderesourceslices"),
SingularQualifiedResource: resource.Resource("noderesourceslice"),
CreateStrategy: noderesourceslice.Strategy,
UpdateStrategy: noderesourceslice.Strategy,
DeleteStrategy: noderesourceslice.Strategy,
ReturnDeletedObject: true,
TableConvertor: printerstorage.TableConvertor{TableGenerator: printers.NewTableGenerator().With(printersinternal.AddHandlers)},
}
options := &generic.StoreOptions{
RESTOptions: optsGetter,
AttrFunc: noderesourceslice.GetAttrs,
TriggerFunc: noderesourceslice.TriggerFunc,
Indexers: noderesourceslice.Indexers(),
}
if err := store.CompleteWithOptions(options); err != nil {
return nil, err
}
return &REST{store}, nil
}

View File

@@ -0,0 +1,146 @@
/*
Copyright 2022 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.
*/
package storage
import (
"testing"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apiserver/pkg/registry/generic"
genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing"
etcd3testing "k8s.io/apiserver/pkg/storage/etcd3/testing"
"k8s.io/kubernetes/pkg/apis/resource"
_ "k8s.io/kubernetes/pkg/apis/resource/install"
"k8s.io/kubernetes/pkg/registry/registrytest"
)
func newStorage(t *testing.T) (*REST, *etcd3testing.EtcdTestServer) {
etcdStorage, server := registrytest.NewEtcdStorage(t, resource.GroupName)
restOptions := generic.RESTOptions{
StorageConfig: etcdStorage,
Decorator: generic.UndecoratedStorage,
DeleteCollectionWorkers: 1,
ResourcePrefix: "noderesourceslices",
}
resourceClassStorage, err := NewREST(restOptions)
if err != nil {
t.Fatalf("unexpected error from REST storage: %v", err)
}
return resourceClassStorage, server
}
func validNewNodeResourceSlice(name string) *resource.NodeResourceSlice {
return &resource.NodeResourceSlice{
ObjectMeta: metav1.ObjectMeta{
Name: name,
},
NodeName: name,
DriverName: "cdi.example.com",
}
}
func TestCreate(t *testing.T) {
storage, server := newStorage(t)
defer server.Terminate(t)
defer storage.Store.DestroyFunc()
test := genericregistrytest.New(t, storage.Store).ClusterScope()
resourceClass := validNewNodeResourceSlice("foo")
resourceClass.ObjectMeta = metav1.ObjectMeta{GenerateName: "foo"}
test.TestCreate(
// valid
resourceClass,
// invalid
&resource.NodeResourceSlice{
ObjectMeta: metav1.ObjectMeta{Name: "*BadName!"},
},
)
}
func TestUpdate(t *testing.T) {
storage, server := newStorage(t)
defer server.Terminate(t)
defer storage.Store.DestroyFunc()
test := genericregistrytest.New(t, storage.Store).ClusterScope()
test.TestUpdate(
// valid
validNewNodeResourceSlice("foo"),
// updateFunc
func(obj runtime.Object) runtime.Object {
object := obj.(*resource.NodeResourceSlice)
object.Labels = map[string]string{"foo": "bar"}
return object
},
// invalid update
func(obj runtime.Object) runtime.Object {
object := obj.(*resource.NodeResourceSlice)
object.DriverName = ""
return object
},
)
}
func TestDelete(t *testing.T) {
storage, server := newStorage(t)
defer server.Terminate(t)
defer storage.Store.DestroyFunc()
test := genericregistrytest.New(t, storage.Store).ClusterScope().ReturnDeletedObject()
test.TestDelete(validNewNodeResourceSlice("foo"))
}
func TestGet(t *testing.T) {
storage, server := newStorage(t)
defer server.Terminate(t)
defer storage.Store.DestroyFunc()
test := genericregistrytest.New(t, storage.Store).ClusterScope()
test.TestGet(validNewNodeResourceSlice("foo"))
}
func TestList(t *testing.T) {
storage, server := newStorage(t)
defer server.Terminate(t)
defer storage.Store.DestroyFunc()
test := genericregistrytest.New(t, storage.Store).ClusterScope()
test.TestList(validNewNodeResourceSlice("foo"))
}
func TestWatch(t *testing.T) {
storage, server := newStorage(t)
defer server.Terminate(t)
defer storage.Store.DestroyFunc()
test := genericregistrytest.New(t, storage.Store).ClusterScope()
test.TestWatch(
validNewNodeResourceSlice("foo"),
// matching labels
[]labels.Set{},
// not matching labels
[]labels.Set{
{"foo": "bar"},
},
// matching fields
[]fields.Set{
{"metadata.name": "foo"},
},
// not matching fields
[]fields.Set{
{"metadata.name": "bar"},
},
)
}

View File

@@ -0,0 +1,139 @@
/*
Copyright 2022 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.
*/
package noderesourceslice
import (
"context"
"fmt"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field"
"k8s.io/apiserver/pkg/registry/generic"
"k8s.io/apiserver/pkg/storage"
"k8s.io/apiserver/pkg/storage/names"
"k8s.io/client-go/tools/cache"
"k8s.io/kubernetes/pkg/api/legacyscheme"
"k8s.io/kubernetes/pkg/apis/resource"
"k8s.io/kubernetes/pkg/apis/resource/validation"
)
// nodeResourceSliceStrategy implements behavior for NodeResourceSlice objects
type nodeResourceSliceStrategy struct {
runtime.ObjectTyper
names.NameGenerator
}
var Strategy = nodeResourceSliceStrategy{legacyscheme.Scheme, names.SimpleNameGenerator}
func (nodeResourceSliceStrategy) NamespaceScoped() bool {
return false
}
func (nodeResourceSliceStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
}
func (nodeResourceSliceStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
slice := obj.(*resource.NodeResourceSlice)
return validation.ValidateNodeResourceSlice(slice)
}
func (nodeResourceSliceStrategy) WarningsOnCreate(ctx context.Context, obj runtime.Object) []string {
return nil
}
func (nodeResourceSliceStrategy) Canonicalize(obj runtime.Object) {
}
func (nodeResourceSliceStrategy) AllowCreateOnUpdate() bool {
return false
}
func (nodeResourceSliceStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
}
func (nodeResourceSliceStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
return validation.ValidateNodeResourceSliceUpdate(obj.(*resource.NodeResourceSlice), old.(*resource.NodeResourceSlice))
}
func (nodeResourceSliceStrategy) WarningsOnUpdate(ctx context.Context, obj, old runtime.Object) []string {
return nil
}
func (nodeResourceSliceStrategy) AllowUnconditionalUpdate() bool {
return true
}
var TriggerFunc = map[string]storage.IndexerFunc{
// Only one index is supported:
// https://github.com/kubernetes/kubernetes/blob/3aa8c59fec0bf339e67ca80ea7905c817baeca85/staging/src/k8s.io/apiserver/pkg/storage/cacher/cacher.go#L346-L350
"nodeName": nodeNameTriggerFunc,
}
func nodeNameTriggerFunc(obj runtime.Object) string {
return obj.(*resource.NodeResourceSlice).NodeName
}
// Indexers returns the indexers for NodeResourceSlice.
func Indexers() *cache.Indexers {
return &cache.Indexers{
storage.FieldIndex("nodeName"): nodeNameIndexFunc,
}
}
func nodeNameIndexFunc(obj interface{}) ([]string, error) {
slice, ok := obj.(*resource.NodeResourceSlice)
if !ok {
return nil, fmt.Errorf("not a NodeResourceSlice")
}
return []string{slice.NodeName}, nil
}
// GetAttrs returns labels and fields of a given object for filtering purposes.
func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, error) {
slice, ok := obj.(*resource.NodeResourceSlice)
if !ok {
return nil, nil, fmt.Errorf("not a NodeResourceSlice")
}
return labels.Set(slice.ObjectMeta.Labels), toSelectableFields(slice), nil
}
// Match returns a generic matcher for a given label and field selector.
func Match(label labels.Selector, field fields.Selector) storage.SelectionPredicate {
return storage.SelectionPredicate{
Label: label,
Field: field,
GetAttrs: GetAttrs,
IndexFields: []string{"nodeName"},
}
}
// toSelectableFields returns a field set that represents the object
// TODO: fields are not labels, and the validation rules for them do not apply.
func toSelectableFields(slice *resource.NodeResourceSlice) fields.Set {
// The purpose of allocation with a given number of elements is to reduce
// amount of allocations needed to create the fields.Set. If you add any
// field here or the number of object-meta related fields changes, this should
// be adjusted.
fields := make(fields.Set, 3)
fields["nodeName"] = slice.NodeName
fields["driverName"] = slice.DriverName
// Adds one field.
return generic.AddObjectMetaFieldsSet(fields, &slice.ObjectMeta, false)
}

View File

@@ -0,0 +1,82 @@
/*
Copyright 2022 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.
*/
package noderesourceslice
import (
"testing"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/kubernetes/pkg/apis/resource"
)
var slice = &resource.NodeResourceSlice{
ObjectMeta: metav1.ObjectMeta{
Name: "valid-class",
},
NodeName: "valid-node-name",
DriverName: "testdriver.example.com",
}
func TestClassStrategy(t *testing.T) {
if Strategy.NamespaceScoped() {
t.Errorf("NodeResourceSlice must not be namespace scoped")
}
if Strategy.AllowCreateOnUpdate() {
t.Errorf("NodeResourceSlice should not allow create on update")
}
}
func TestClassStrategyCreate(t *testing.T) {
ctx := genericapirequest.NewDefaultContext()
slice := slice.DeepCopy()
Strategy.PrepareForCreate(ctx, slice)
errs := Strategy.Validate(ctx, slice)
if len(errs) != 0 {
t.Errorf("unexpected error validating for create %v", errs)
}
}
func TestClassStrategyUpdate(t *testing.T) {
t.Run("no-changes-okay", func(t *testing.T) {
ctx := genericapirequest.NewDefaultContext()
slice := slice.DeepCopy()
newClass := slice.DeepCopy()
newClass.ResourceVersion = "4"
Strategy.PrepareForUpdate(ctx, newClass, slice)
errs := Strategy.ValidateUpdate(ctx, newClass, slice)
if len(errs) != 0 {
t.Errorf("unexpected validation errors: %v", errs)
}
})
t.Run("name-change-not-allowed", func(t *testing.T) {
ctx := genericapirequest.NewDefaultContext()
slice := slice.DeepCopy()
newClass := slice.DeepCopy()
newClass.Name = "valid-class-2"
newClass.ResourceVersion = "4"
Strategy.PrepareForUpdate(ctx, newClass, slice)
errs := Strategy.ValidateUpdate(ctx, newClass, slice)
if len(errs) == 0 {
t.Errorf("expected a validation error")
}
})
}

View File

@@ -0,0 +1,57 @@
/*
Copyright 2022 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.
*/
package storage
import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apiserver/pkg/registry/generic"
genericregistry "k8s.io/apiserver/pkg/registry/generic/registry"
"k8s.io/kubernetes/pkg/apis/resource"
"k8s.io/kubernetes/pkg/printers"
printersinternal "k8s.io/kubernetes/pkg/printers/internalversion"
printerstorage "k8s.io/kubernetes/pkg/printers/storage"
"k8s.io/kubernetes/pkg/registry/resource/resourceclaimparameters"
)
// REST implements a RESTStorage for ResourceClaimParameters.
type REST struct {
*genericregistry.Store
}
// NewREST returns a RESTStorage object that will work against ResourceClaimParameters.
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
store := &genericregistry.Store{
NewFunc: func() runtime.Object { return &resource.ResourceClaimParameters{} },
NewListFunc: func() runtime.Object { return &resource.ResourceClaimParametersList{} },
PredicateFunc: resourceclaimparameters.Match,
DefaultQualifiedResource: resource.Resource("resourceclaimparameters"),
SingularQualifiedResource: resource.Resource("resourceclaimparameters"),
CreateStrategy: resourceclaimparameters.Strategy,
UpdateStrategy: resourceclaimparameters.Strategy,
DeleteStrategy: resourceclaimparameters.Strategy,
ReturnDeletedObject: true,
TableConvertor: printerstorage.TableConvertor{TableGenerator: printers.NewTableGenerator().With(printersinternal.AddHandlers)},
}
options := &generic.StoreOptions{RESTOptions: optsGetter, AttrFunc: resourceclaimparameters.GetAttrs}
if err := store.CompleteWithOptions(options); err != nil {
return nil, err
}
return &REST{store}, nil
}

View File

@@ -0,0 +1,145 @@
/*
Copyright 2022 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.
*/
package storage
import (
"testing"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apiserver/pkg/registry/generic"
genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing"
etcd3testing "k8s.io/apiserver/pkg/storage/etcd3/testing"
"k8s.io/kubernetes/pkg/apis/resource"
_ "k8s.io/kubernetes/pkg/apis/resource/install"
"k8s.io/kubernetes/pkg/registry/registrytest"
)
func newStorage(t *testing.T) (*REST, *etcd3testing.EtcdTestServer) {
etcdStorage, server := registrytest.NewEtcdStorage(t, resource.GroupName)
restOptions := generic.RESTOptions{
StorageConfig: etcdStorage,
Decorator: generic.UndecoratedStorage,
DeleteCollectionWorkers: 1,
ResourcePrefix: "resourceclaimparameters",
}
resourceClassStorage, err := NewREST(restOptions)
if err != nil {
t.Fatalf("unexpected error from REST storage: %v", err)
}
return resourceClassStorage, server
}
func validNewResourceClaimParameters(name string) *resource.ResourceClaimParameters {
return &resource.ResourceClaimParameters{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: metav1.NamespaceDefault,
},
}
}
func TestCreate(t *testing.T) {
storage, server := newStorage(t)
defer server.Terminate(t)
defer storage.Store.DestroyFunc()
test := genericregistrytest.New(t, storage.Store)
resourceClass := validNewResourceClaimParameters("foo")
resourceClass.ObjectMeta = metav1.ObjectMeta{}
test.TestCreate(
// valid
resourceClass,
// invalid
&resource.ResourceClaimParameters{
ObjectMeta: metav1.ObjectMeta{Name: "*BadName!"},
},
)
}
func TestUpdate(t *testing.T) {
storage, server := newStorage(t)
defer server.Terminate(t)
defer storage.Store.DestroyFunc()
test := genericregistrytest.New(t, storage.Store)
test.TestUpdate(
// valid
validNewResourceClaimParameters("foo"),
// updateFunc
func(obj runtime.Object) runtime.Object {
object := obj.(*resource.ResourceClaimParameters)
object.Labels = map[string]string{"foo": "bar"}
return object
},
// invalid update
func(obj runtime.Object) runtime.Object {
object := obj.(*resource.ResourceClaimParameters)
object.Labels = map[string]string{"&$^^#%@": "1"}
return object
},
)
}
func TestDelete(t *testing.T) {
storage, server := newStorage(t)
defer server.Terminate(t)
defer storage.Store.DestroyFunc()
test := genericregistrytest.New(t, storage.Store).ReturnDeletedObject()
test.TestDelete(validNewResourceClaimParameters("foo"))
}
func TestGet(t *testing.T) {
storage, server := newStorage(t)
defer server.Terminate(t)
defer storage.Store.DestroyFunc()
test := genericregistrytest.New(t, storage.Store)
test.TestGet(validNewResourceClaimParameters("foo"))
}
func TestList(t *testing.T) {
storage, server := newStorage(t)
defer server.Terminate(t)
defer storage.Store.DestroyFunc()
test := genericregistrytest.New(t, storage.Store)
test.TestList(validNewResourceClaimParameters("foo"))
}
func TestWatch(t *testing.T) {
storage, server := newStorage(t)
defer server.Terminate(t)
defer storage.Store.DestroyFunc()
test := genericregistrytest.New(t, storage.Store)
test.TestWatch(
validNewResourceClaimParameters("foo"),
// matching labels
[]labels.Set{},
// not matching labels
[]labels.Set{
{"foo": "bar"},
},
// matching fields
[]fields.Set{
{"metadata.name": "foo"},
},
// not matching fields
[]fields.Set{
{"metadata.name": "bar"},
},
)
}

View File

@@ -0,0 +1,103 @@
/*
Copyright 2022 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.
*/
package resourceclaimparameters
import (
"context"
"errors"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field"
"k8s.io/apiserver/pkg/registry/generic"
"k8s.io/apiserver/pkg/storage"
"k8s.io/apiserver/pkg/storage/names"
"k8s.io/kubernetes/pkg/api/legacyscheme"
"k8s.io/kubernetes/pkg/apis/resource"
"k8s.io/kubernetes/pkg/apis/resource/validation"
)
// resourceClaimParametersStrategy implements behavior for ResourceClaimParameters objects
type resourceClaimParametersStrategy struct {
runtime.ObjectTyper
names.NameGenerator
}
var Strategy = resourceClaimParametersStrategy{legacyscheme.Scheme, names.SimpleNameGenerator}
func (resourceClaimParametersStrategy) NamespaceScoped() bool {
return true
}
func (resourceClaimParametersStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
}
func (resourceClaimParametersStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
resourceClaimParameters := obj.(*resource.ResourceClaimParameters)
return validation.ValidateResourceClaimParameters(resourceClaimParameters)
}
func (resourceClaimParametersStrategy) WarningsOnCreate(ctx context.Context, obj runtime.Object) []string {
return nil
}
func (resourceClaimParametersStrategy) Canonicalize(obj runtime.Object) {
}
func (resourceClaimParametersStrategy) AllowCreateOnUpdate() bool {
return false
}
func (resourceClaimParametersStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
}
func (resourceClaimParametersStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
return validation.ValidateResourceClaimParametersUpdate(obj.(*resource.ResourceClaimParameters), old.(*resource.ResourceClaimParameters))
}
func (resourceClaimParametersStrategy) WarningsOnUpdate(ctx context.Context, obj, old runtime.Object) []string {
return nil
}
func (resourceClaimParametersStrategy) AllowUnconditionalUpdate() bool {
return true
}
// Match returns a generic matcher for a given label and field selector.
func Match(label labels.Selector, field fields.Selector) storage.SelectionPredicate {
return storage.SelectionPredicate{
Label: label,
Field: field,
GetAttrs: GetAttrs,
}
}
// GetAttrs returns labels and fields of a given object for filtering purposes.
func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, error) {
parameters, ok := obj.(*resource.ResourceClaimParameters)
if !ok {
return nil, nil, errors.New("not a resourceclaim")
}
return labels.Set(parameters.Labels), toSelectableFields(parameters), nil
}
// toSelectableFields returns a field set that represents the object
func toSelectableFields(claim *resource.ResourceClaimParameters) fields.Set {
fields := generic.ObjectMetaFieldsSet(&claim.ObjectMeta, true)
return fields
}

View File

@@ -0,0 +1,81 @@
/*
Copyright 2022 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.
*/
package resourceclaimparameters
import (
"testing"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/kubernetes/pkg/apis/resource"
)
var resourceClaimParameters = &resource.ResourceClaimParameters{
ObjectMeta: metav1.ObjectMeta{
Name: "valid",
Namespace: "ns",
},
}
func TestClassStrategy(t *testing.T) {
if !Strategy.NamespaceScoped() {
t.Errorf("ResourceClaimParameters must be namespace scoped")
}
if Strategy.AllowCreateOnUpdate() {
t.Errorf("ResourceClaimParameters should not allow create on update")
}
}
func TestClassStrategyCreate(t *testing.T) {
ctx := genericapirequest.NewDefaultContext()
resourceClaimParameters := resourceClaimParameters.DeepCopy()
Strategy.PrepareForCreate(ctx, resourceClaimParameters)
errs := Strategy.Validate(ctx, resourceClaimParameters)
if len(errs) != 0 {
t.Errorf("unexpected error validating for create %v", errs)
}
}
func TestClassStrategyUpdate(t *testing.T) {
t.Run("no-changes-okay", func(t *testing.T) {
ctx := genericapirequest.NewDefaultContext()
resourceClaimParameters := resourceClaimParameters.DeepCopy()
newObj := resourceClaimParameters.DeepCopy()
newObj.ResourceVersion = "4"
Strategy.PrepareForUpdate(ctx, newObj, resourceClaimParameters)
errs := Strategy.ValidateUpdate(ctx, newObj, resourceClaimParameters)
if len(errs) != 0 {
t.Errorf("unexpected validation errors: %v", errs)
}
})
t.Run("name-change-not-allowed", func(t *testing.T) {
ctx := genericapirequest.NewDefaultContext()
resourceClaimParameters := resourceClaimParameters.DeepCopy()
newObj := resourceClaimParameters.DeepCopy()
newObj.Name += "-2"
newObj.ResourceVersion = "4"
Strategy.PrepareForUpdate(ctx, newObj, resourceClaimParameters)
errs := Strategy.ValidateUpdate(ctx, newObj, resourceClaimParameters)
if len(errs) == 0 {
t.Errorf("expected a validation error")
}
})
}

View File

@@ -0,0 +1,57 @@
/*
Copyright 2022 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.
*/
package storage
import (
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apiserver/pkg/registry/generic"
genericregistry "k8s.io/apiserver/pkg/registry/generic/registry"
"k8s.io/kubernetes/pkg/apis/resource"
"k8s.io/kubernetes/pkg/printers"
printersinternal "k8s.io/kubernetes/pkg/printers/internalversion"
printerstorage "k8s.io/kubernetes/pkg/printers/storage"
"k8s.io/kubernetes/pkg/registry/resource/resourceclassparameters"
)
// REST implements a RESTStorage for ResourceClassParameters.
type REST struct {
*genericregistry.Store
}
// NewREST returns a RESTStorage object that will work against ResourceClassParameters.
func NewREST(optsGetter generic.RESTOptionsGetter) (*REST, error) {
store := &genericregistry.Store{
NewFunc: func() runtime.Object { return &resource.ResourceClassParameters{} },
NewListFunc: func() runtime.Object { return &resource.ResourceClassParametersList{} },
PredicateFunc: resourceclassparameters.Match,
DefaultQualifiedResource: resource.Resource("resourceclassparameters"),
SingularQualifiedResource: resource.Resource("resourceclassparameters"),
CreateStrategy: resourceclassparameters.Strategy,
UpdateStrategy: resourceclassparameters.Strategy,
DeleteStrategy: resourceclassparameters.Strategy,
ReturnDeletedObject: true,
TableConvertor: printerstorage.TableConvertor{TableGenerator: printers.NewTableGenerator().With(printersinternal.AddHandlers)},
}
options := &generic.StoreOptions{RESTOptions: optsGetter, AttrFunc: resourceclassparameters.GetAttrs}
if err := store.CompleteWithOptions(options); err != nil {
return nil, err
}
return &REST{store}, nil
}

View File

@@ -0,0 +1,145 @@
/*
Copyright 2022 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.
*/
package storage
import (
"testing"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apiserver/pkg/registry/generic"
genericregistrytest "k8s.io/apiserver/pkg/registry/generic/testing"
etcd3testing "k8s.io/apiserver/pkg/storage/etcd3/testing"
"k8s.io/kubernetes/pkg/apis/resource"
_ "k8s.io/kubernetes/pkg/apis/resource/install"
"k8s.io/kubernetes/pkg/registry/registrytest"
)
func newStorage(t *testing.T) (*REST, *etcd3testing.EtcdTestServer) {
etcdStorage, server := registrytest.NewEtcdStorage(t, resource.GroupName)
restOptions := generic.RESTOptions{
StorageConfig: etcdStorage,
Decorator: generic.UndecoratedStorage,
DeleteCollectionWorkers: 1,
ResourcePrefix: "resourceclassparameters",
}
resourceClassStorage, err := NewREST(restOptions)
if err != nil {
t.Fatalf("unexpected error from REST storage: %v", err)
}
return resourceClassStorage, server
}
func validNewResourceClaimParameters(name string) *resource.ResourceClaimParameters {
return &resource.ResourceClaimParameters{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: metav1.NamespaceDefault,
},
}
}
func TestCreate(t *testing.T) {
storage, server := newStorage(t)
defer server.Terminate(t)
defer storage.Store.DestroyFunc()
test := genericregistrytest.New(t, storage.Store)
resourceClass := validNewResourceClaimParameters("foo")
resourceClass.ObjectMeta = metav1.ObjectMeta{}
test.TestCreate(
// valid
resourceClass,
// invalid
&resource.ResourceClaimParameters{
ObjectMeta: metav1.ObjectMeta{Name: "*BadName!"},
},
)
}
func TestUpdate(t *testing.T) {
storage, server := newStorage(t)
defer server.Terminate(t)
defer storage.Store.DestroyFunc()
test := genericregistrytest.New(t, storage.Store)
test.TestUpdate(
// valid
validNewResourceClaimParameters("foo"),
// updateFunc
func(obj runtime.Object) runtime.Object {
object := obj.(*resource.ResourceClaimParameters)
object.Labels = map[string]string{"foo": "bar"}
return object
},
// invalid update
func(obj runtime.Object) runtime.Object {
object := obj.(*resource.ResourceClaimParameters)
object.Labels = map[string]string{"&$^^#%@": "1"}
return object
},
)
}
func TestDelete(t *testing.T) {
storage, server := newStorage(t)
defer server.Terminate(t)
defer storage.Store.DestroyFunc()
test := genericregistrytest.New(t, storage.Store).ReturnDeletedObject()
test.TestDelete(validNewResourceClaimParameters("foo"))
}
func TestGet(t *testing.T) {
storage, server := newStorage(t)
defer server.Terminate(t)
defer storage.Store.DestroyFunc()
test := genericregistrytest.New(t, storage.Store)
test.TestGet(validNewResourceClaimParameters("foo"))
}
func TestList(t *testing.T) {
storage, server := newStorage(t)
defer server.Terminate(t)
defer storage.Store.DestroyFunc()
test := genericregistrytest.New(t, storage.Store)
test.TestList(validNewResourceClaimParameters("foo"))
}
func TestWatch(t *testing.T) {
storage, server := newStorage(t)
defer server.Terminate(t)
defer storage.Store.DestroyFunc()
test := genericregistrytest.New(t, storage.Store)
test.TestWatch(
validNewResourceClaimParameters("foo"),
// matching labels
[]labels.Set{},
// not matching labels
[]labels.Set{
{"foo": "bar"},
},
// matching fields
[]fields.Set{
{"metadata.name": "foo"},
},
// not matching fields
[]fields.Set{
{"metadata.name": "bar"},
},
)
}

View File

@@ -0,0 +1,103 @@
/*
Copyright 2022 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.
*/
package resourceclassparameters
import (
"context"
"errors"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/validation/field"
"k8s.io/apiserver/pkg/registry/generic"
"k8s.io/apiserver/pkg/storage"
"k8s.io/apiserver/pkg/storage/names"
"k8s.io/kubernetes/pkg/api/legacyscheme"
"k8s.io/kubernetes/pkg/apis/resource"
"k8s.io/kubernetes/pkg/apis/resource/validation"
)
// resourceClassParametersStrategy implements behavior for ResourceClassParameters objects
type resourceClassParametersStrategy struct {
runtime.ObjectTyper
names.NameGenerator
}
var Strategy = resourceClassParametersStrategy{legacyscheme.Scheme, names.SimpleNameGenerator}
func (resourceClassParametersStrategy) NamespaceScoped() bool {
return true
}
func (resourceClassParametersStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) {
}
func (resourceClassParametersStrategy) Validate(ctx context.Context, obj runtime.Object) field.ErrorList {
resourceClassParameters := obj.(*resource.ResourceClassParameters)
return validation.ValidateResourceClassParameters(resourceClassParameters)
}
func (resourceClassParametersStrategy) WarningsOnCreate(ctx context.Context, obj runtime.Object) []string {
return nil
}
func (resourceClassParametersStrategy) Canonicalize(obj runtime.Object) {
}
func (resourceClassParametersStrategy) AllowCreateOnUpdate() bool {
return false
}
func (resourceClassParametersStrategy) PrepareForUpdate(ctx context.Context, obj, old runtime.Object) {
}
func (resourceClassParametersStrategy) ValidateUpdate(ctx context.Context, obj, old runtime.Object) field.ErrorList {
return validation.ValidateResourceClassParametersUpdate(obj.(*resource.ResourceClassParameters), old.(*resource.ResourceClassParameters))
}
func (resourceClassParametersStrategy) WarningsOnUpdate(ctx context.Context, obj, old runtime.Object) []string {
return nil
}
func (resourceClassParametersStrategy) AllowUnconditionalUpdate() bool {
return true
}
// Match returns a generic matcher for a given label and field selector.
func Match(label labels.Selector, field fields.Selector) storage.SelectionPredicate {
return storage.SelectionPredicate{
Label: label,
Field: field,
GetAttrs: GetAttrs,
}
}
// GetAttrs returns labels and fields of a given object for filtering purposes.
func GetAttrs(obj runtime.Object) (labels.Set, fields.Set, error) {
parameters, ok := obj.(*resource.ResourceClassParameters)
if !ok {
return nil, nil, errors.New("not a resourceclassparameters")
}
return labels.Set(parameters.Labels), toSelectableFields(parameters), nil
}
// toSelectableFields returns a field set that represents the object
func toSelectableFields(class *resource.ResourceClassParameters) fields.Set {
fields := generic.ObjectMetaFieldsSet(&class.ObjectMeta, true)
return fields
}

View File

@@ -0,0 +1,81 @@
/*
Copyright 2022 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.
*/
package resourceclassparameters
import (
"testing"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/kubernetes/pkg/apis/resource"
)
var resourceClassParameters = &resource.ResourceClassParameters{
ObjectMeta: metav1.ObjectMeta{
Name: "valid",
Namespace: "ns",
},
}
func TestClassStrategy(t *testing.T) {
if !Strategy.NamespaceScoped() {
t.Errorf("ResourceClassParameters must be namespace scoped")
}
if Strategy.AllowCreateOnUpdate() {
t.Errorf("ResourceClassParameters should not allow create on update")
}
}
func TestClassStrategyCreate(t *testing.T) {
ctx := genericapirequest.NewDefaultContext()
resourceClassParameters := resourceClassParameters.DeepCopy()
Strategy.PrepareForCreate(ctx, resourceClassParameters)
errs := Strategy.Validate(ctx, resourceClassParameters)
if len(errs) != 0 {
t.Errorf("unexpected error validating for create %v", errs)
}
}
func TestClassStrategyUpdate(t *testing.T) {
t.Run("no-changes-okay", func(t *testing.T) {
ctx := genericapirequest.NewDefaultContext()
resourceClassParameters := resourceClassParameters.DeepCopy()
newObj := resourceClassParameters.DeepCopy()
newObj.ResourceVersion = "4"
Strategy.PrepareForUpdate(ctx, newObj, resourceClassParameters)
errs := Strategy.ValidateUpdate(ctx, newObj, resourceClassParameters)
if len(errs) != 0 {
t.Errorf("unexpected validation errors: %v", errs)
}
})
t.Run("name-change-not-allowed", func(t *testing.T) {
ctx := genericapirequest.NewDefaultContext()
resourceClassParameters := resourceClassParameters.DeepCopy()
newObj := resourceClassParameters.DeepCopy()
newObj.Name += "-2"
newObj.ResourceVersion = "4"
Strategy.PrepareForUpdate(ctx, newObj, resourceClassParameters)
errs := Strategy.ValidateUpdate(ctx, newObj, resourceClassParameters)
if len(errs) == 0 {
t.Errorf("expected a validation error")
}
})
}

View File

@@ -24,10 +24,13 @@ import (
serverstorage "k8s.io/apiserver/pkg/server/storage"
"k8s.io/kubernetes/pkg/api/legacyscheme"
"k8s.io/kubernetes/pkg/apis/resource"
noderesourceslicestore "k8s.io/kubernetes/pkg/registry/resource/noderesourceslice/storage"
podschedulingcontextsstore "k8s.io/kubernetes/pkg/registry/resource/podschedulingcontext/storage"
resourceclaimstore "k8s.io/kubernetes/pkg/registry/resource/resourceclaim/storage"
resourceclaimparametersstore "k8s.io/kubernetes/pkg/registry/resource/resourceclaimparameters/storage"
resourceclaimtemplatestore "k8s.io/kubernetes/pkg/registry/resource/resourceclaimtemplate/storage"
resourceclassstore "k8s.io/kubernetes/pkg/registry/resource/resourceclass/storage"
resourceclassparametersstore "k8s.io/kubernetes/pkg/registry/resource/resourceclassparameters/storage"
)
type RESTStorageProvider struct{}
@@ -83,6 +86,30 @@ func (p RESTStorageProvider) v1alpha2Storage(apiResourceConfigSource serverstora
storage[resource+"/status"] = podSchedulingStatusStorage
}
if resource := "resourceclaimparameters"; apiResourceConfigSource.ResourceEnabled(resourcev1alpha2.SchemeGroupVersion.WithResource(resource)) {
resourceClaimParametersStorage, err := resourceclaimparametersstore.NewREST(restOptionsGetter)
if err != nil {
return nil, err
}
storage[resource] = resourceClaimParametersStorage
}
if resource := "resourceclassparameters"; apiResourceConfigSource.ResourceEnabled(resourcev1alpha2.SchemeGroupVersion.WithResource(resource)) {
resourceClassParametersStorage, err := resourceclassparametersstore.NewREST(restOptionsGetter)
if err != nil {
return nil, err
}
storage[resource] = resourceClassParametersStorage
}
if resource := "noderesourceslices"; apiResourceConfigSource.ResourceEnabled(resourcev1alpha2.SchemeGroupVersion.WithResource(resource)) {
nodeResourceSliceStorage, err := noderesourceslicestore.NewREST(restOptionsGetter)
if err != nil {
return nil, err
}
storage[resource] = nodeResourceSliceStorage
}
return storage, nil
}

File diff suppressed because it is too large Load Diff

View File

@@ -63,6 +63,72 @@ message AllocationResult {
optional bool shareable = 3;
}
// AllocationResultModel must have one and only one field set.
message AllocationResultModel {
}
// DriverAllocationResult contains vendor parameters and the allocation result for
// one request.
message DriverAllocationResult {
// VendorRequestParameters are the per-request configuration parameters
// from the time that the claim was allocated.
//
// +optional
optional k8s.io.apimachinery.pkg.runtime.RawExtension vendorRequestParameters = 1;
optional AllocationResultModel allocationResultModel = 2;
}
// DriverRequests describes all resources that are needed from one particular driver.
message DriverRequests {
// DriverName is the name used by the DRA driver kubelet plugin.
optional string driverName = 1;
// VendorParameters are arbitrary setup parameters for all requests of the
// claim. They are ignored while allocating the claim.
//
// +optional
optional k8s.io.apimachinery.pkg.runtime.RawExtension vendorParameters = 2;
// Requests describes all resources that are needed from the driver.
// +listType=atomic
repeated ResourceRequest requests = 3;
}
// NodeResourceModel must have one and only one field set.
message NodeResourceModel {
}
// NodeResourceSlice provides information about available
// resources on individual nodes.
message NodeResourceSlice {
// Standard object metadata
// +optional
optional k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1;
// NodeName identifies the node where the capacity is available.
// A field selector can be used to list only NodeResourceSlice
// objects with a certain node name.
optional string nodeName = 2;
// DriverName identifies the DRA driver providing the capacity information.
// A field selector can be used to list only NodeResourceSlice
// objects with a certain driver name.
optional string driverName = 3;
optional NodeResourceModel nodeResourceModel = 4;
}
// NodeResourceSliceList is a collection of NodeResourceSlices.
message NodeResourceSliceList {
// Standard list metadata
// +optional
optional k8s.io.apimachinery.pkg.apis.meta.v1.ListMeta metadata = 1;
// Items is the list of node resource capacity objects.
repeated NodeResourceSlice items = 2;
}
// PodSchedulingContext objects hold information that is needed to schedule
// a Pod with ResourceClaims that use "WaitForFirstConsumer" allocation
// mode.
@@ -176,6 +242,45 @@ message ResourceClaimList {
repeated ResourceClaim items = 2;
}
// ResourceClaimParameters defines resource requests for a ResourceClaim in an
// in-tree format understood by Kubernetes.
message ResourceClaimParameters {
// Standard object metadata
optional k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1;
// If this object was created from some other resource, then this links
// back to that resource. This field is used to find the in-tree representation
// of the claim parameters when the parameter reference of the claim refers
// to some unknown type.
// +optional
optional ResourceClaimParametersReference generatedFrom = 2;
// Shareable indicates whether the allocated claim is meant to be shareable
// by multiple consumers at the same time.
// +optional
optional bool shareable = 3;
// DriverRequests describes all resources that are needed for the
// allocated claim. A single claim may use resources coming from
// different drivers. For each driver, this array has at most one
// entry which then may have one or more per-driver requests.
//
// May be empty, in which case the claim can always be allocated.
//
// +listType=atomic
repeated DriverRequests driverRequests = 4;
}
// ResourceClaimParametersList is a collection of ResourceClaimParameters.
message ResourceClaimParametersList {
// Standard list metadata
// +optional
optional k8s.io.apimachinery.pkg.apis.meta.v1.ListMeta metadata = 1;
// Items is the list of node resource capacity objects.
repeated ResourceClaimParameters items = 2;
}
// ResourceClaimParametersReference contains enough information to let you
// locate the parameters for a ResourceClaim. The object must be in the same
// namespace as the ResourceClaim.
@@ -344,6 +449,11 @@ message ResourceClass {
// Setting this field is optional. If null, all nodes are candidates.
// +optional
optional k8s.io.api.core.v1.NodeSelector suitableNodes = 4;
// If and only if allocation of claims using this class is handled
// via structured parameters, then StructuredParameters must be set to true.
// +optional
optional bool structuredParameters = 5;
}
// ResourceClassList is a collection of classes.
@@ -356,6 +466,43 @@ message ResourceClassList {
repeated ResourceClass items = 2;
}
// ResourceClassParameters defines resource requests for a ResourceClass in an
// in-tree format understood by Kubernetes.
message ResourceClassParameters {
// Standard object metadata
optional k8s.io.apimachinery.pkg.apis.meta.v1.ObjectMeta metadata = 1;
// If this object was created from some other resource, then this links
// back to that resource. This field is used to find the in-tree representation
// of the class parameters when the parameter reference of the class refers
// to some unknown type.
// +optional
optional ResourceClassParametersReference generatedFrom = 2;
// VendorParameters are arbitrary setup parameters for all claims using
// this class. They are ignored while allocating the claim. There must
// not be more than one entry per driver.
//
// +listType=atomic
// +optional
repeated VendorParameters vendorParameters = 3;
// Filters describes additional contraints that must be met when using the class.
//
// +listType=atomic
repeated ResourceFilter filters = 4;
}
// ResourceClassParametersList is a collection of ResourceClassParameters.
message ResourceClassParametersList {
// Standard list metadata
// +optional
optional k8s.io.apimachinery.pkg.apis.meta.v1.ListMeta metadata = 1;
// Items is the list of node resource capacity objects.
repeated ResourceClassParameters items = 2;
}
// ResourceClassParametersReference contains enough information to let you
// locate the parameters for a ResourceClass.
message ResourceClassParametersReference {
@@ -379,6 +526,18 @@ message ResourceClassParametersReference {
optional string namespace = 4;
}
// ResourceFilter is a filter for resources from one particular driver.
message ResourceFilter {
// DriverName is the name used by the DRA driver kubelet plugin.
optional string driverName = 1;
optional ResourceFilterModel resourceFilterModel = 2;
}
// ResourceFilterModel must have one and only one field set.
message ResourceFilterModel {
}
// ResourceHandle holds opaque resource data for processing by a specific kubelet plugin.
message ResourceHandle {
// DriverName specifies the name of the resource driver whose kubelet
@@ -398,5 +557,61 @@ message ResourceHandle {
// future, but not reduced.
// +optional
optional string data = 2;
// If StructuredData is set, then it needs to be used instead of Data.
//
// +optional
optional StructuredResourceHandle structuredData = 5;
}
// ResourceRequest is a request for resources from one particular driver.
message ResourceRequest {
// VendorParameters are arbitrary setup parameters for the requested
// resource. They are ignored while allocating a claim.
//
// +optional
optional k8s.io.apimachinery.pkg.runtime.RawExtension vendorParameters = 1;
optional ResourceRequestModel resourceRequestModel = 2;
}
// ResourceRequestModel must have one and only one field set.
message ResourceRequestModel {
}
// StructuredResourceHandle is the in-tree representation of the allocation result.
message StructuredResourceHandle {
// VendorClassParameters are the per-claim configuration parameters
// from the resource class at the time that the claim was allocated.
//
// +optional
optional k8s.io.apimachinery.pkg.runtime.RawExtension vendorClassParameters = 1;
// VendorClaimParameters are the per-claim configuration parameters
// from the resource claim parameters at the time that the claim was
// allocated.
//
// +optional
optional k8s.io.apimachinery.pkg.runtime.RawExtension vendorClaimParameters = 2;
// NodeName is the name of the node providing the necessary resources.
optional string nodeName = 4;
// Results lists all allocated driver resources.
//
// +listType=atomic
repeated DriverAllocationResult results = 5;
}
// VendorParameters are opaque parameters for one particular driver.
message VendorParameters {
// DriverName is the name used by the DRA driver kubelet plugin.
optional string driverName = 1;
// Parameters can be arbitrary setup parameters. They are ignored while
// allocating a claim.
//
// +optional
optional k8s.io.apimachinery.pkg.runtime.RawExtension parameters = 2;
}

View File

@@ -52,6 +52,12 @@ func addKnownTypes(scheme *runtime.Scheme) error {
&ResourceClaimTemplateList{},
&PodSchedulingContext{},
&PodSchedulingContextList{},
&NodeResourceSlice{},
&NodeResourceSliceList{},
&ResourceClaimParameters{},
&ResourceClaimParametersList{},
&ResourceClassParameters{},
&ResourceClassParametersList{},
)
// Add common types

View File

@@ -19,9 +19,16 @@ package v1alpha2
import (
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/types"
)
const (
// Finalizer is the finalizer that gets set for claims
// which were allocated through a builtin controller.
Finalizer = "dra.k8s.io/delete-protection"
)
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +k8s:prerelease-lifecycle-gen:introduced=1.26
@@ -192,11 +199,57 @@ type ResourceHandle struct {
// future, but not reduced.
// +optional
Data string `json:"data,omitempty" protobuf:"bytes,2,opt,name=data"`
// If StructuredData is set, then it needs to be used instead of Data.
//
// +optional
StructuredData *StructuredResourceHandle `json:"structuredData,omitempty" protobuf:"bytes,5,opt,name=structuredData"`
}
// ResourceHandleDataMaxSize represents the maximum size of resourceHandle.data.
const ResourceHandleDataMaxSize = 16 * 1024
// StructuredResourceHandle is the in-tree representation of the allocation result.
type StructuredResourceHandle struct {
// VendorClassParameters are the per-claim configuration parameters
// from the resource class at the time that the claim was allocated.
//
// +optional
VendorClassParameters runtime.RawExtension `json:"vendorClassParameters,omitempty" protobuf:"bytes,1,opt,name=vendorClassParameters"`
// VendorClaimParameters are the per-claim configuration parameters
// from the resource claim parameters at the time that the claim was
// allocated.
//
// +optional
VendorClaimParameters runtime.RawExtension `json:"vendorClaimParameters,omitempty" protobuf:"bytes,2,opt,name=vendorClaimParameters"`
// NodeName is the name of the node providing the necessary resources.
NodeName string `json:"nodeName" protobuf:"bytes,4,name=nodeName"`
// Results lists all allocated driver resources.
//
// +listType=atomic
Results []DriverAllocationResult `json:"results" protobuf:"bytes,5,name=results"`
}
// DriverAllocationResult contains vendor parameters and the allocation result for
// one request.
type DriverAllocationResult struct {
// VendorRequestParameters are the per-request configuration parameters
// from the time that the claim was allocated.
//
// +optional
VendorRequestParameters runtime.RawExtension `json:"vendorRequestParameters,omitempty" protobuf:"bytes,1,opt,name=vendorRequestParameters"`
AllocationResultModel `json:",inline" protobuf:"bytes,2,name=allocationResultModel"`
}
// AllocationResultModel must have one and only one field set.
type AllocationResultModel struct {
// TODO: implement one structured parameter model
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +k8s:prerelease-lifecycle-gen:introduced=1.26
@@ -347,6 +400,11 @@ type ResourceClass struct {
// Setting this field is optional. If null, all nodes are candidates.
// +optional
SuitableNodes *v1.NodeSelector `json:"suitableNodes,omitempty" protobuf:"bytes,4,opt,name=suitableNodes"`
// If and only if allocation of claims using this class is handled
// via structured parameters, then StructuredParameters must be set to true.
// +optional
StructuredParameters *bool `json:"structuredParameters,omitempty" protobuf:"bytes,5,opt,name=structuredParameters"`
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
@@ -462,3 +520,199 @@ type ResourceClaimTemplateList struct {
// Items is the list of resource claim templates.
Items []ResourceClaimTemplate `json:"items" protobuf:"bytes,2,rep,name=items"`
}
// +genclient
// +genclient:nonNamespaced
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +k8s:prerelease-lifecycle-gen:introduced=1.30
// NodeResourceSlice provides information about available
// resources on individual nodes.
type NodeResourceSlice struct {
metav1.TypeMeta `json:",inline"`
// Standard object metadata
// +optional
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
// NodeName identifies the node where the capacity is available.
// A field selector can be used to list only NodeResourceSlice
// objects with a certain node name.
NodeName string `json:"nodeName" protobuf:"bytes,2,name=nodeName"`
// DriverName identifies the DRA driver providing the capacity information.
// A field selector can be used to list only NodeResourceSlice
// objects with a certain driver name.
DriverName string `json:"driverName" protobuf:"bytes,3,name=driverName"`
NodeResourceModel `json:",inline" protobuf:"bytes,4,name=nodeResourceModel"`
}
// NodeResourceModel must have one and only one field set.
type NodeResourceModel struct {
// TODO: implement one structured parameter model
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +k8s:prerelease-lifecycle-gen:introduced=1.30
// NodeResourceSliceList is a collection of NodeResourceSlices.
type NodeResourceSliceList struct {
metav1.TypeMeta `json:",inline"`
// Standard list metadata
// +optional
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
// Items is the list of node resource capacity objects.
Items []NodeResourceSlice `json:"items" protobuf:"bytes,2,rep,name=items"`
}
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +k8s:prerelease-lifecycle-gen:introduced=1.30
// ResourceClaimParameters defines resource requests for a ResourceClaim in an
// in-tree format understood by Kubernetes.
type ResourceClaimParameters struct {
metav1.TypeMeta `json:",inline"`
// Standard object metadata
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
// If this object was created from some other resource, then this links
// back to that resource. This field is used to find the in-tree representation
// of the claim parameters when the parameter reference of the claim refers
// to some unknown type.
// +optional
GeneratedFrom *ResourceClaimParametersReference `json:"generatedFrom,omitempty" protobuf:"bytes,2,opt,name=generatedFrom"`
// Shareable indicates whether the allocated claim is meant to be shareable
// by multiple consumers at the same time.
// +optional
Shareable bool `json:"shareable,omitempty" protobuf:"bytes,3,opt,name=shareable"`
// DriverRequests describes all resources that are needed for the
// allocated claim. A single claim may use resources coming from
// different drivers. For each driver, this array has at most one
// entry which then may have one or more per-driver requests.
//
// May be empty, in which case the claim can always be allocated.
//
// +listType=atomic
DriverRequests []DriverRequests `json:"driverRequests,omitempty" protobuf:"bytes,4,opt,name=driverRequests"`
}
// DriverRequests describes all resources that are needed from one particular driver.
type DriverRequests struct {
// DriverName is the name used by the DRA driver kubelet plugin.
DriverName string `json:"driverName,omitempty" protobuf:"bytes,1,opt,name=driverName"`
// VendorParameters are arbitrary setup parameters for all requests of the
// claim. They are ignored while allocating the claim.
//
// +optional
VendorParameters runtime.RawExtension `json:"vendorParameters,omitempty" protobuf:"bytes,2,opt,name=vendorParameters"`
// Requests describes all resources that are needed from the driver.
// +listType=atomic
Requests []ResourceRequest `json:"requests,omitempty" protobuf:"bytes,3,opt,name=requests"`
}
// ResourceRequest is a request for resources from one particular driver.
type ResourceRequest struct {
// VendorParameters are arbitrary setup parameters for the requested
// resource. They are ignored while allocating a claim.
//
// +optional
VendorParameters runtime.RawExtension `json:"vendorParameters,omitempty" protobuf:"bytes,1,opt,name=vendorParameters"`
ResourceRequestModel `json:",inline" protobuf:"bytes,2,name=resourceRequestModel"`
}
// ResourceRequestModel must have one and only one field set.
type ResourceRequestModel struct {
// TODO: implement one structured parameter model
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +k8s:prerelease-lifecycle-gen:introduced=1.30
// ResourceClaimParametersList is a collection of ResourceClaimParameters.
type ResourceClaimParametersList struct {
metav1.TypeMeta `json:",inline"`
// Standard list metadata
// +optional
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
// Items is the list of node resource capacity objects.
Items []ResourceClaimParameters `json:"items" protobuf:"bytes,2,rep,name=items"`
}
// +genclient
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +k8s:prerelease-lifecycle-gen:introduced=1.30
// ResourceClassParameters defines resource requests for a ResourceClass in an
// in-tree format understood by Kubernetes.
type ResourceClassParameters struct {
metav1.TypeMeta `json:",inline"`
// Standard object metadata
metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
// If this object was created from some other resource, then this links
// back to that resource. This field is used to find the in-tree representation
// of the class parameters when the parameter reference of the class refers
// to some unknown type.
// +optional
GeneratedFrom *ResourceClassParametersReference `json:"generatedFrom,omitempty" protobuf:"bytes,2,opt,name=generatedFrom"`
// VendorParameters are arbitrary setup parameters for all claims using
// this class. They are ignored while allocating the claim. There must
// not be more than one entry per driver.
//
// +listType=atomic
// +optional
VendorParameters []VendorParameters `json:"vendorParameters,omitempty" protobuf:"bytes,3,opt,name=vendorParameters"`
// Filters describes additional contraints that must be met when using the class.
//
// +listType=atomic
Filters []ResourceFilter `json:"filters,omitempty" protobuf:"bytes,4,opt,name=filters"`
}
// ResourceFilter is a filter for resources from one particular driver.
type ResourceFilter struct {
// DriverName is the name used by the DRA driver kubelet plugin.
DriverName string `json:"driverName,omitempty" protobuf:"bytes,1,opt,name=driverName"`
ResourceFilterModel `json:",inline" protobuf:"bytes,2,name=resourceFilterModel"`
}
// ResourceFilterModel must have one and only one field set.
type ResourceFilterModel struct {
// TODO: implement one structured parameter model
}
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
// +k8s:prerelease-lifecycle-gen:introduced=1.30
// ResourceClassParametersList is a collection of ResourceClassParameters.
type ResourceClassParametersList struct {
metav1.TypeMeta `json:",inline"`
// Standard list metadata
// +optional
metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
// Items is the list of node resource capacity objects.
Items []ResourceClassParameters `json:"items" protobuf:"bytes,2,rep,name=items"`
}
// VendorParameters are opaque parameters for one particular driver.
type VendorParameters struct {
// DriverName is the name used by the DRA driver kubelet plugin.
DriverName string `json:"driverName,omitempty" protobuf:"bytes,1,opt,name=driverName"`
// Parameters can be arbitrary setup parameters. They are ignored while
// allocating a claim.
//
// +optional
Parameters runtime.RawExtension `json:"parameters,omitempty" protobuf:"bytes,2,opt,name=parameters"`
}

View File

@@ -38,6 +38,63 @@ func (AllocationResult) SwaggerDoc() map[string]string {
return map_AllocationResult
}
var map_AllocationResultModel = map[string]string{
"": "AllocationResultModel must have one and only one field set.",
}
func (AllocationResultModel) SwaggerDoc() map[string]string {
return map_AllocationResultModel
}
var map_DriverAllocationResult = map[string]string{
"": "DriverAllocationResult contains vendor parameters and the allocation result for one request.",
"vendorRequestParameters": "VendorRequestParameters are the per-request configuration parameters from the time that the claim was allocated.",
}
func (DriverAllocationResult) SwaggerDoc() map[string]string {
return map_DriverAllocationResult
}
var map_DriverRequests = map[string]string{
"": "DriverRequests describes all resources that are needed from one particular driver.",
"driverName": "DriverName is the name used by the DRA driver kubelet plugin.",
"vendorParameters": "VendorParameters are arbitrary setup parameters for all requests of the claim. They are ignored while allocating the claim.",
"requests": "Requests describes all resources that are needed from the driver.",
}
func (DriverRequests) SwaggerDoc() map[string]string {
return map_DriverRequests
}
var map_NodeResourceModel = map[string]string{
"": "NodeResourceModel must have one and only one field set.",
}
func (NodeResourceModel) SwaggerDoc() map[string]string {
return map_NodeResourceModel
}
var map_NodeResourceSlice = map[string]string{
"": "NodeResourceSlice provides information about available resources on individual nodes.",
"metadata": "Standard object metadata",
"nodeName": "NodeName identifies the node where the capacity is available. A field selector can be used to list only NodeResourceSlice objects with a certain node name.",
"driverName": "DriverName identifies the DRA driver providing the capacity information. A field selector can be used to list only NodeResourceSlice objects with a certain driver name.",
}
func (NodeResourceSlice) SwaggerDoc() map[string]string {
return map_NodeResourceSlice
}
var map_NodeResourceSliceList = map[string]string{
"": "NodeResourceSliceList is a collection of NodeResourceSlices.",
"metadata": "Standard list metadata",
"items": "Items is the list of node resource capacity objects.",
}
func (NodeResourceSliceList) SwaggerDoc() map[string]string {
return map_NodeResourceSliceList
}
var map_PodSchedulingContext = map[string]string{
"": "PodSchedulingContext objects hold information that is needed to schedule a Pod with ResourceClaims that use \"WaitForFirstConsumer\" allocation mode.\n\nThis is an alpha type and requires enabling the DynamicResourceAllocation feature gate.",
"metadata": "Standard object metadata",
@@ -111,6 +168,28 @@ func (ResourceClaimList) SwaggerDoc() map[string]string {
return map_ResourceClaimList
}
var map_ResourceClaimParameters = map[string]string{
"": "ResourceClaimParameters defines resource requests for a ResourceClaim in an in-tree format understood by Kubernetes.",
"metadata": "Standard object metadata",
"generatedFrom": "If this object was created from some other resource, then this links back to that resource. This field is used to find the in-tree representation of the claim parameters when the parameter reference of the claim refers to some unknown type.",
"shareable": "Shareable indicates whether the allocated claim is meant to be shareable by multiple consumers at the same time.",
"driverRequests": "DriverRequests describes all resources that are needed for the allocated claim. A single claim may use resources coming from different drivers. For each driver, this array has at most one entry which then may have one or more per-driver requests.\n\nMay be empty, in which case the claim can always be allocated.",
}
func (ResourceClaimParameters) SwaggerDoc() map[string]string {
return map_ResourceClaimParameters
}
var map_ResourceClaimParametersList = map[string]string{
"": "ResourceClaimParametersList is a collection of ResourceClaimParameters.",
"metadata": "Standard list metadata",
"items": "Items is the list of node resource capacity objects.",
}
func (ResourceClaimParametersList) SwaggerDoc() map[string]string {
return map_ResourceClaimParametersList
}
var map_ResourceClaimParametersReference = map[string]string{
"": "ResourceClaimParametersReference contains enough information to let you locate the parameters for a ResourceClaim. The object must be in the same namespace as the ResourceClaim.",
"apiGroup": "APIGroup is the group for the resource being referenced. It is empty for the core API. This matches the group in the APIVersion that is used when creating the resources.",
@@ -186,11 +265,12 @@ func (ResourceClaimTemplateSpec) SwaggerDoc() map[string]string {
}
var map_ResourceClass = map[string]string{
"": "ResourceClass is used by administrators to influence how resources are allocated.\n\nThis is an alpha type and requires enabling the DynamicResourceAllocation feature gate.",
"metadata": "Standard object metadata",
"driverName": "DriverName defines the name of the dynamic resource driver that is used for allocation of a ResourceClaim that uses this class.\n\nResource drivers have a unique name in forward domain order (acme.example.com).",
"parametersRef": "ParametersRef references an arbitrary separate object that may hold parameters that will be used by the driver when allocating a resource that uses this class. A dynamic resource driver can distinguish between parameters stored here and and those stored in ResourceClaimSpec.",
"suitableNodes": "Only nodes matching the selector will be considered by the scheduler when trying to find a Node that fits a Pod when that Pod uses a ResourceClaim that has not been allocated yet.\n\nSetting this field is optional. If null, all nodes are candidates.",
"": "ResourceClass is used by administrators to influence how resources are allocated.\n\nThis is an alpha type and requires enabling the DynamicResourceAllocation feature gate.",
"metadata": "Standard object metadata",
"driverName": "DriverName defines the name of the dynamic resource driver that is used for allocation of a ResourceClaim that uses this class.\n\nResource drivers have a unique name in forward domain order (acme.example.com).",
"parametersRef": "ParametersRef references an arbitrary separate object that may hold parameters that will be used by the driver when allocating a resource that uses this class. A dynamic resource driver can distinguish between parameters stored here and and those stored in ResourceClaimSpec.",
"suitableNodes": "Only nodes matching the selector will be considered by the scheduler when trying to find a Node that fits a Pod when that Pod uses a ResourceClaim that has not been allocated yet.\n\nSetting this field is optional. If null, all nodes are candidates.",
"structuredParameters": "If and only if allocation of claims using this class is handled via structured parameters, then StructuredParameters must be set to true.",
}
func (ResourceClass) SwaggerDoc() map[string]string {
@@ -207,6 +287,28 @@ func (ResourceClassList) SwaggerDoc() map[string]string {
return map_ResourceClassList
}
var map_ResourceClassParameters = map[string]string{
"": "ResourceClassParameters defines resource requests for a ResourceClass in an in-tree format understood by Kubernetes.",
"metadata": "Standard object metadata",
"generatedFrom": "If this object was created from some other resource, then this links back to that resource. This field is used to find the in-tree representation of the class parameters when the parameter reference of the class refers to some unknown type.",
"vendorParameters": "VendorParameters are arbitrary setup parameters for all claims using this class. They are ignored while allocating the claim. There must not be more than one entry per driver.",
"filters": "Filters describes additional contraints that must be met when using the class.",
}
func (ResourceClassParameters) SwaggerDoc() map[string]string {
return map_ResourceClassParameters
}
var map_ResourceClassParametersList = map[string]string{
"": "ResourceClassParametersList is a collection of ResourceClassParameters.",
"metadata": "Standard list metadata",
"items": "Items is the list of node resource capacity objects.",
}
func (ResourceClassParametersList) SwaggerDoc() map[string]string {
return map_ResourceClassParametersList
}
var map_ResourceClassParametersReference = map[string]string{
"": "ResourceClassParametersReference contains enough information to let you locate the parameters for a ResourceClass.",
"apiGroup": "APIGroup is the group for the resource being referenced. It is empty for the core API. This matches the group in the APIVersion that is used when creating the resources.",
@@ -219,14 +321,71 @@ func (ResourceClassParametersReference) SwaggerDoc() map[string]string {
return map_ResourceClassParametersReference
}
var map_ResourceFilter = map[string]string{
"": "ResourceFilter is a filter for resources from one particular driver.",
"driverName": "DriverName is the name used by the DRA driver kubelet plugin.",
}
func (ResourceFilter) SwaggerDoc() map[string]string {
return map_ResourceFilter
}
var map_ResourceFilterModel = map[string]string{
"": "ResourceFilterModel must have one and only one field set.",
}
func (ResourceFilterModel) SwaggerDoc() map[string]string {
return map_ResourceFilterModel
}
var map_ResourceHandle = map[string]string{
"": "ResourceHandle holds opaque resource data for processing by a specific kubelet plugin.",
"driverName": "DriverName specifies the name of the resource driver whose kubelet plugin should be invoked to process this ResourceHandle's data once it lands on a node. This may differ from the DriverName set in ResourceClaimStatus this ResourceHandle is embedded in.",
"data": "Data contains the opaque data associated with this ResourceHandle. It is set by the controller component of the resource driver whose name matches the DriverName set in the ResourceClaimStatus this ResourceHandle is embedded in. It is set at allocation time and is intended for processing by the kubelet plugin whose name matches the DriverName set in this ResourceHandle.\n\nThe maximum size of this field is 16KiB. This may get increased in the future, but not reduced.",
"": "ResourceHandle holds opaque resource data for processing by a specific kubelet plugin.",
"driverName": "DriverName specifies the name of the resource driver whose kubelet plugin should be invoked to process this ResourceHandle's data once it lands on a node. This may differ from the DriverName set in ResourceClaimStatus this ResourceHandle is embedded in.",
"data": "Data contains the opaque data associated with this ResourceHandle. It is set by the controller component of the resource driver whose name matches the DriverName set in the ResourceClaimStatus this ResourceHandle is embedded in. It is set at allocation time and is intended for processing by the kubelet plugin whose name matches the DriverName set in this ResourceHandle.\n\nThe maximum size of this field is 16KiB. This may get increased in the future, but not reduced.",
"structuredData": "If StructuredData is set, then it needs to be used instead of Data.",
}
func (ResourceHandle) SwaggerDoc() map[string]string {
return map_ResourceHandle
}
var map_ResourceRequest = map[string]string{
"": "ResourceRequest is a request for resources from one particular driver.",
"vendorParameters": "VendorParameters are arbitrary setup parameters for the requested resource. They are ignored while allocating a claim.",
}
func (ResourceRequest) SwaggerDoc() map[string]string {
return map_ResourceRequest
}
var map_ResourceRequestModel = map[string]string{
"": "ResourceRequestModel must have one and only one field set.",
}
func (ResourceRequestModel) SwaggerDoc() map[string]string {
return map_ResourceRequestModel
}
var map_StructuredResourceHandle = map[string]string{
"": "StructuredResourceHandle is the in-tree representation of the allocation result.",
"vendorClassParameters": "VendorClassParameters are the per-claim configuration parameters from the resource class at the time that the claim was allocated.",
"vendorClaimParameters": "VendorClaimParameters are the per-claim configuration parameters from the resource claim parameters at the time that the claim was allocated.",
"nodeName": "NodeName is the name of the node providing the necessary resources.",
"results": "Results lists all allocated driver resources.",
}
func (StructuredResourceHandle) SwaggerDoc() map[string]string {
return map_StructuredResourceHandle
}
var map_VendorParameters = map[string]string{
"": "VendorParameters are opaque parameters for one particular driver.",
"driverName": "DriverName is the name used by the DRA driver kubelet plugin.",
"parameters": "Parameters can be arbitrary setup parameters. They are ignored while allocating a claim.",
}
func (VendorParameters) SwaggerDoc() map[string]string {
return map_VendorParameters
}
// AUTO-GENERATED FUNCTIONS END HERE

View File

@@ -32,7 +32,9 @@ func (in *AllocationResult) DeepCopyInto(out *AllocationResult) {
if in.ResourceHandles != nil {
in, out := &in.ResourceHandles, &out.ResourceHandles
*out = make([]ResourceHandle, len(*in))
copy(*out, *in)
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
if in.AvailableOnNodes != nil {
in, out := &in.AvailableOnNodes, &out.AvailableOnNodes
@@ -52,6 +54,140 @@ func (in *AllocationResult) DeepCopy() *AllocationResult {
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *AllocationResultModel) DeepCopyInto(out *AllocationResultModel) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new AllocationResultModel.
func (in *AllocationResultModel) DeepCopy() *AllocationResultModel {
if in == nil {
return nil
}
out := new(AllocationResultModel)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *DriverAllocationResult) DeepCopyInto(out *DriverAllocationResult) {
*out = *in
in.VendorRequestParameters.DeepCopyInto(&out.VendorRequestParameters)
out.AllocationResultModel = in.AllocationResultModel
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DriverAllocationResult.
func (in *DriverAllocationResult) DeepCopy() *DriverAllocationResult {
if in == nil {
return nil
}
out := new(DriverAllocationResult)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *DriverRequests) DeepCopyInto(out *DriverRequests) {
*out = *in
in.VendorParameters.DeepCopyInto(&out.VendorParameters)
if in.Requests != nil {
in, out := &in.Requests, &out.Requests
*out = make([]ResourceRequest, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new DriverRequests.
func (in *DriverRequests) DeepCopy() *DriverRequests {
if in == nil {
return nil
}
out := new(DriverRequests)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *NodeResourceModel) DeepCopyInto(out *NodeResourceModel) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeResourceModel.
func (in *NodeResourceModel) DeepCopy() *NodeResourceModel {
if in == nil {
return nil
}
out := new(NodeResourceModel)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *NodeResourceSlice) DeepCopyInto(out *NodeResourceSlice) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
out.NodeResourceModel = in.NodeResourceModel
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeResourceSlice.
func (in *NodeResourceSlice) DeepCopy() *NodeResourceSlice {
if in == nil {
return nil
}
out := new(NodeResourceSlice)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *NodeResourceSlice) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *NodeResourceSliceList) DeepCopyInto(out *NodeResourceSliceList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]NodeResourceSlice, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeResourceSliceList.
func (in *NodeResourceSliceList) DeepCopy() *NodeResourceSliceList {
if in == nil {
return nil
}
out := new(NodeResourceSliceList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *NodeResourceSliceList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *PodSchedulingContext) DeepCopyInto(out *PodSchedulingContext) {
*out = *in
@@ -234,6 +370,77 @@ func (in *ResourceClaimList) DeepCopyObject() runtime.Object {
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ResourceClaimParameters) DeepCopyInto(out *ResourceClaimParameters) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
if in.GeneratedFrom != nil {
in, out := &in.GeneratedFrom, &out.GeneratedFrom
*out = new(ResourceClaimParametersReference)
**out = **in
}
if in.DriverRequests != nil {
in, out := &in.DriverRequests, &out.DriverRequests
*out = make([]DriverRequests, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceClaimParameters.
func (in *ResourceClaimParameters) DeepCopy() *ResourceClaimParameters {
if in == nil {
return nil
}
out := new(ResourceClaimParameters)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *ResourceClaimParameters) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ResourceClaimParametersList) DeepCopyInto(out *ResourceClaimParametersList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]ResourceClaimParameters, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceClaimParametersList.
func (in *ResourceClaimParametersList) DeepCopy() *ResourceClaimParametersList {
if in == nil {
return nil
}
out := new(ResourceClaimParametersList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *ResourceClaimParametersList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ResourceClaimParametersReference) DeepCopyInto(out *ResourceClaimParametersReference) {
*out = *in
@@ -411,6 +618,11 @@ func (in *ResourceClass) DeepCopyInto(out *ResourceClass) {
*out = new(v1.NodeSelector)
(*in).DeepCopyInto(*out)
}
if in.StructuredParameters != nil {
in, out := &in.StructuredParameters, &out.StructuredParameters
*out = new(bool)
**out = **in
}
return
}
@@ -465,6 +677,82 @@ func (in *ResourceClassList) DeepCopyObject() runtime.Object {
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ResourceClassParameters) DeepCopyInto(out *ResourceClassParameters) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ObjectMeta.DeepCopyInto(&out.ObjectMeta)
if in.GeneratedFrom != nil {
in, out := &in.GeneratedFrom, &out.GeneratedFrom
*out = new(ResourceClassParametersReference)
**out = **in
}
if in.VendorParameters != nil {
in, out := &in.VendorParameters, &out.VendorParameters
*out = make([]VendorParameters, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
if in.Filters != nil {
in, out := &in.Filters, &out.Filters
*out = make([]ResourceFilter, len(*in))
copy(*out, *in)
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceClassParameters.
func (in *ResourceClassParameters) DeepCopy() *ResourceClassParameters {
if in == nil {
return nil
}
out := new(ResourceClassParameters)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *ResourceClassParameters) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ResourceClassParametersList) DeepCopyInto(out *ResourceClassParametersList) {
*out = *in
out.TypeMeta = in.TypeMeta
in.ListMeta.DeepCopyInto(&out.ListMeta)
if in.Items != nil {
in, out := &in.Items, &out.Items
*out = make([]ResourceClassParameters, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceClassParametersList.
func (in *ResourceClassParametersList) DeepCopy() *ResourceClassParametersList {
if in == nil {
return nil
}
out := new(ResourceClassParametersList)
in.DeepCopyInto(out)
return out
}
// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object.
func (in *ResourceClassParametersList) DeepCopyObject() runtime.Object {
if c := in.DeepCopy(); c != nil {
return c
}
return nil
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ResourceClassParametersReference) DeepCopyInto(out *ResourceClassParametersReference) {
*out = *in
@@ -481,9 +769,47 @@ func (in *ResourceClassParametersReference) DeepCopy() *ResourceClassParametersR
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ResourceFilter) DeepCopyInto(out *ResourceFilter) {
*out = *in
out.ResourceFilterModel = in.ResourceFilterModel
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceFilter.
func (in *ResourceFilter) DeepCopy() *ResourceFilter {
if in == nil {
return nil
}
out := new(ResourceFilter)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ResourceFilterModel) DeepCopyInto(out *ResourceFilterModel) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceFilterModel.
func (in *ResourceFilterModel) DeepCopy() *ResourceFilterModel {
if in == nil {
return nil
}
out := new(ResourceFilterModel)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ResourceHandle) DeepCopyInto(out *ResourceHandle) {
*out = *in
if in.StructuredData != nil {
in, out := &in.StructuredData, &out.StructuredData
*out = new(StructuredResourceHandle)
(*in).DeepCopyInto(*out)
}
return
}
@@ -496,3 +822,79 @@ func (in *ResourceHandle) DeepCopy() *ResourceHandle {
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ResourceRequest) DeepCopyInto(out *ResourceRequest) {
*out = *in
in.VendorParameters.DeepCopyInto(&out.VendorParameters)
out.ResourceRequestModel = in.ResourceRequestModel
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceRequest.
func (in *ResourceRequest) DeepCopy() *ResourceRequest {
if in == nil {
return nil
}
out := new(ResourceRequest)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *ResourceRequestModel) DeepCopyInto(out *ResourceRequestModel) {
*out = *in
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceRequestModel.
func (in *ResourceRequestModel) DeepCopy() *ResourceRequestModel {
if in == nil {
return nil
}
out := new(ResourceRequestModel)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *StructuredResourceHandle) DeepCopyInto(out *StructuredResourceHandle) {
*out = *in
in.VendorClassParameters.DeepCopyInto(&out.VendorClassParameters)
in.VendorClaimParameters.DeepCopyInto(&out.VendorClaimParameters)
if in.Results != nil {
in, out := &in.Results, &out.Results
*out = make([]DriverAllocationResult, len(*in))
for i := range *in {
(*in)[i].DeepCopyInto(&(*out)[i])
}
}
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new StructuredResourceHandle.
func (in *StructuredResourceHandle) DeepCopy() *StructuredResourceHandle {
if in == nil {
return nil
}
out := new(StructuredResourceHandle)
in.DeepCopyInto(out)
return out
}
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
func (in *VendorParameters) DeepCopyInto(out *VendorParameters) {
*out = *in
in.Parameters.DeepCopyInto(&out.Parameters)
return
}
// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VendorParameters.
func (in *VendorParameters) DeepCopy() *VendorParameters {
if in == nil {
return nil
}
out := new(VendorParameters)
in.DeepCopyInto(out)
return out
}

View File

@@ -0,0 +1,48 @@
{
"kind": "NodeResourceSlice",
"apiVersion": "resource.k8s.io/v1alpha2",
"metadata": {
"name": "nameValue",
"generateName": "generateNameValue",
"namespace": "namespaceValue",
"selfLink": "selfLinkValue",
"uid": "uidValue",
"resourceVersion": "resourceVersionValue",
"generation": 7,
"creationTimestamp": "2008-01-01T01:01:01Z",
"deletionTimestamp": "2009-01-01T01:01:01Z",
"deletionGracePeriodSeconds": 10,
"labels": {
"labelsKey": "labelsValue"
},
"annotations": {
"annotationsKey": "annotationsValue"
},
"ownerReferences": [
{
"apiVersion": "apiVersionValue",
"kind": "kindValue",
"name": "nameValue",
"uid": "uidValue",
"controller": true,
"blockOwnerDeletion": true
}
],
"finalizers": [
"finalizersValue"
],
"managedFields": [
{
"manager": "managerValue",
"operation": "operationValue",
"apiVersion": "apiVersionValue",
"time": "2004-01-01T01:01:01Z",
"fieldsType": "fieldsTypeValue",
"fieldsV1": {},
"subresource": "subresourceValue"
}
]
},
"nodeName": "nodeNameValue",
"driverName": "driverNameValue"
}

View File

@@ -0,0 +1,36 @@
apiVersion: resource.k8s.io/v1alpha2
driverName: driverNameValue
kind: NodeResourceSlice
metadata:
annotations:
annotationsKey: annotationsValue
creationTimestamp: "2008-01-01T01:01:01Z"
deletionGracePeriodSeconds: 10
deletionTimestamp: "2009-01-01T01:01:01Z"
finalizers:
- finalizersValue
generateName: generateNameValue
generation: 7
labels:
labelsKey: labelsValue
managedFields:
- apiVersion: apiVersionValue
fieldsType: fieldsTypeValue
fieldsV1: {}
manager: managerValue
operation: operationValue
subresource: subresourceValue
time: "2004-01-01T01:01:01Z"
name: nameValue
namespace: namespaceValue
ownerReferences:
- apiVersion: apiVersionValue
blockOwnerDeletion: true
controller: true
kind: kindValue
name: nameValue
uid: uidValue
resourceVersion: resourceVersionValue
selfLink: selfLinkValue
uid: uidValue
nodeName: nodeNameValue

View File

@@ -58,7 +58,44 @@
"resourceHandles": [
{
"driverName": "driverNameValue",
"data": "dataValue"
"data": "dataValue",
"structuredData": {
"vendorClassParameters": {
"apiVersion": "example.com/v1",
"kind": "CustomType",
"spec": {
"replicas": 1
},
"status": {
"available": 1
}
},
"vendorClaimParameters": {
"apiVersion": "example.com/v1",
"kind": "CustomType",
"spec": {
"replicas": 1
},
"status": {
"available": 1
}
},
"nodeName": "nodeNameValue",
"results": [
{
"vendorRequestParameters": {
"apiVersion": "example.com/v1",
"kind": "CustomType",
"spec": {
"replicas": 1
},
"status": {
"available": 1
}
}
}
]
}
}
],
"availableOnNodes": {

View File

@@ -56,6 +56,30 @@ status:
resourceHandles:
- data: dataValue
driverName: driverNameValue
structuredData:
nodeName: nodeNameValue
results:
- vendorRequestParameters:
apiVersion: example.com/v1
kind: CustomType
spec:
replicas: 1
status:
available: 1
vendorClaimParameters:
apiVersion: example.com/v1
kind: CustomType
spec:
replicas: 1
status:
available: 1
vendorClassParameters:
apiVersion: example.com/v1
kind: CustomType
spec:
replicas: 1
status:
available: 1
shareable: true
deallocationRequested: true
driverName: driverNameValue

View File

@@ -0,0 +1,81 @@
{
"kind": "ResourceClaimParameters",
"apiVersion": "resource.k8s.io/v1alpha2",
"metadata": {
"name": "nameValue",
"generateName": "generateNameValue",
"namespace": "namespaceValue",
"selfLink": "selfLinkValue",
"uid": "uidValue",
"resourceVersion": "resourceVersionValue",
"generation": 7,
"creationTimestamp": "2008-01-01T01:01:01Z",
"deletionTimestamp": "2009-01-01T01:01:01Z",
"deletionGracePeriodSeconds": 10,
"labels": {
"labelsKey": "labelsValue"
},
"annotations": {
"annotationsKey": "annotationsValue"
},
"ownerReferences": [
{
"apiVersion": "apiVersionValue",
"kind": "kindValue",
"name": "nameValue",
"uid": "uidValue",
"controller": true,
"blockOwnerDeletion": true
}
],
"finalizers": [
"finalizersValue"
],
"managedFields": [
{
"manager": "managerValue",
"operation": "operationValue",
"apiVersion": "apiVersionValue",
"time": "2004-01-01T01:01:01Z",
"fieldsType": "fieldsTypeValue",
"fieldsV1": {},
"subresource": "subresourceValue"
}
]
},
"generatedFrom": {
"apiGroup": "apiGroupValue",
"kind": "kindValue",
"name": "nameValue"
},
"shareable": true,
"driverRequests": [
{
"driverName": "driverNameValue",
"vendorParameters": {
"apiVersion": "example.com/v1",
"kind": "CustomType",
"spec": {
"replicas": 1
},
"status": {
"available": 1
}
},
"requests": [
{
"vendorParameters": {
"apiVersion": "example.com/v1",
"kind": "CustomType",
"spec": {
"replicas": 1
},
"status": {
"available": 1
}
}
}
]
}
]
}

View File

@@ -0,0 +1,56 @@
apiVersion: resource.k8s.io/v1alpha2
driverRequests:
- driverName: driverNameValue
requests:
- vendorParameters:
apiVersion: example.com/v1
kind: CustomType
spec:
replicas: 1
status:
available: 1
vendorParameters:
apiVersion: example.com/v1
kind: CustomType
spec:
replicas: 1
status:
available: 1
generatedFrom:
apiGroup: apiGroupValue
kind: kindValue
name: nameValue
kind: ResourceClaimParameters
metadata:
annotations:
annotationsKey: annotationsValue
creationTimestamp: "2008-01-01T01:01:01Z"
deletionGracePeriodSeconds: 10
deletionTimestamp: "2009-01-01T01:01:01Z"
finalizers:
- finalizersValue
generateName: generateNameValue
generation: 7
labels:
labelsKey: labelsValue
managedFields:
- apiVersion: apiVersionValue
fieldsType: fieldsTypeValue
fieldsV1: {}
manager: managerValue
operation: operationValue
subresource: subresourceValue
time: "2004-01-01T01:01:01Z"
name: nameValue
namespace: namespaceValue
ownerReferences:
- apiVersion: apiVersionValue
blockOwnerDeletion: true
controller: true
kind: kindValue
name: nameValue
uid: uidValue
resourceVersion: resourceVersionValue
selfLink: selfLinkValue
uid: uidValue
shareable: true

View File

@@ -73,5 +73,6 @@
]
}
]
}
},
"structuredParameters": true
}

View File

@@ -38,6 +38,7 @@ parametersRef:
kind: kindValue
name: nameValue
namespace: namespaceValue
structuredParameters: true
suitableNodes:
nodeSelectorTerms:
- matchExpressions:

View File

@@ -0,0 +1,72 @@
{
"kind": "ResourceClassParameters",
"apiVersion": "resource.k8s.io/v1alpha2",
"metadata": {
"name": "nameValue",
"generateName": "generateNameValue",
"namespace": "namespaceValue",
"selfLink": "selfLinkValue",
"uid": "uidValue",
"resourceVersion": "resourceVersionValue",
"generation": 7,
"creationTimestamp": "2008-01-01T01:01:01Z",
"deletionTimestamp": "2009-01-01T01:01:01Z",
"deletionGracePeriodSeconds": 10,
"labels": {
"labelsKey": "labelsValue"
},
"annotations": {
"annotationsKey": "annotationsValue"
},
"ownerReferences": [
{
"apiVersion": "apiVersionValue",
"kind": "kindValue",
"name": "nameValue",
"uid": "uidValue",
"controller": true,
"blockOwnerDeletion": true
}
],
"finalizers": [
"finalizersValue"
],
"managedFields": [
{
"manager": "managerValue",
"operation": "operationValue",
"apiVersion": "apiVersionValue",
"time": "2004-01-01T01:01:01Z",
"fieldsType": "fieldsTypeValue",
"fieldsV1": {},
"subresource": "subresourceValue"
}
]
},
"generatedFrom": {
"apiGroup": "apiGroupValue",
"kind": "kindValue",
"name": "nameValue",
"namespace": "namespaceValue"
},
"vendorParameters": [
{
"driverName": "driverNameValue",
"parameters": {
"apiVersion": "example.com/v1",
"kind": "CustomType",
"spec": {
"replicas": 1
},
"status": {
"available": 1
}
}
}
],
"filters": [
{
"driverName": "driverNameValue"
}
]
}

View File

@@ -0,0 +1,50 @@
apiVersion: resource.k8s.io/v1alpha2
filters:
- driverName: driverNameValue
generatedFrom:
apiGroup: apiGroupValue
kind: kindValue
name: nameValue
namespace: namespaceValue
kind: ResourceClassParameters
metadata:
annotations:
annotationsKey: annotationsValue
creationTimestamp: "2008-01-01T01:01:01Z"
deletionGracePeriodSeconds: 10
deletionTimestamp: "2009-01-01T01:01:01Z"
finalizers:
- finalizersValue
generateName: generateNameValue
generation: 7
labels:
labelsKey: labelsValue
managedFields:
- apiVersion: apiVersionValue
fieldsType: fieldsTypeValue
fieldsV1: {}
manager: managerValue
operation: operationValue
subresource: subresourceValue
time: "2004-01-01T01:01:01Z"
name: nameValue
namespace: namespaceValue
ownerReferences:
- apiVersion: apiVersionValue
blockOwnerDeletion: true
controller: true
kind: kindValue
name: nameValue
uid: uidValue
resourceVersion: resourceVersionValue
selfLink: selfLinkValue
uid: uidValue
vendorParameters:
- driverName: driverNameValue
parameters:
apiVersion: example.com/v1
kind: CustomType
spec:
replicas: 1
status:
available: 1

View File

@@ -11945,6 +11945,48 @@ var schemaYAML = typed.YAMLObject(`types:
- name: shareable
type:
scalar: boolean
- name: io.k8s.api.resource.v1alpha2.DriverAllocationResult
map:
fields:
- name: vendorRequestParameters
type:
namedType: __untyped_atomic_
- name: io.k8s.api.resource.v1alpha2.DriverRequests
map:
fields:
- name: driverName
type:
scalar: string
- name: requests
type:
list:
elementType:
namedType: io.k8s.api.resource.v1alpha2.ResourceRequest
elementRelationship: atomic
- name: vendorParameters
type:
namedType: __untyped_atomic_
- name: io.k8s.api.resource.v1alpha2.NodeResourceSlice
map:
fields:
- name: apiVersion
type:
scalar: string
- name: driverName
type:
scalar: string
default: ""
- name: kind
type:
scalar: string
- name: metadata
type:
namedType: io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta
default: {}
- name: nodeName
type:
scalar: string
default: ""
- name: io.k8s.api.resource.v1alpha2.PodSchedulingContext
map:
fields:
@@ -12028,6 +12070,31 @@ var schemaYAML = typed.YAMLObject(`types:
type:
scalar: string
default: ""
- name: io.k8s.api.resource.v1alpha2.ResourceClaimParameters
map:
fields:
- name: apiVersion
type:
scalar: string
- name: driverRequests
type:
list:
elementType:
namedType: io.k8s.api.resource.v1alpha2.DriverRequests
elementRelationship: atomic
- name: generatedFrom
type:
namedType: io.k8s.api.resource.v1alpha2.ResourceClaimParametersReference
- name: kind
type:
scalar: string
- name: metadata
type:
namedType: io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta
default: {}
- name: shareable
type:
scalar: boolean
- name: io.k8s.api.resource.v1alpha2.ResourceClaimParametersReference
map:
fields:
@@ -12135,9 +12202,40 @@ var schemaYAML = typed.YAMLObject(`types:
- name: parametersRef
type:
namedType: io.k8s.api.resource.v1alpha2.ResourceClassParametersReference
- name: structuredParameters
type:
scalar: boolean
- name: suitableNodes
type:
namedType: io.k8s.api.core.v1.NodeSelector
- name: io.k8s.api.resource.v1alpha2.ResourceClassParameters
map:
fields:
- name: apiVersion
type:
scalar: string
- name: filters
type:
list:
elementType:
namedType: io.k8s.api.resource.v1alpha2.ResourceFilter
elementRelationship: atomic
- name: generatedFrom
type:
namedType: io.k8s.api.resource.v1alpha2.ResourceClassParametersReference
- name: kind
type:
scalar: string
- name: metadata
type:
namedType: io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta
default: {}
- name: vendorParameters
type:
list:
elementType:
namedType: io.k8s.api.resource.v1alpha2.VendorParameters
elementRelationship: atomic
- name: io.k8s.api.resource.v1alpha2.ResourceClassParametersReference
map:
fields:
@@ -12155,6 +12253,12 @@ var schemaYAML = typed.YAMLObject(`types:
- name: namespace
type:
scalar: string
- name: io.k8s.api.resource.v1alpha2.ResourceFilter
map:
fields:
- name: driverName
type:
scalar: string
- name: io.k8s.api.resource.v1alpha2.ResourceHandle
map:
fields:
@@ -12164,6 +12268,43 @@ var schemaYAML = typed.YAMLObject(`types:
- name: driverName
type:
scalar: string
- name: structuredData
type:
namedType: io.k8s.api.resource.v1alpha2.StructuredResourceHandle
- name: io.k8s.api.resource.v1alpha2.ResourceRequest
map:
fields:
- name: vendorParameters
type:
namedType: __untyped_atomic_
- name: io.k8s.api.resource.v1alpha2.StructuredResourceHandle
map:
fields:
- name: nodeName
type:
scalar: string
default: ""
- name: results
type:
list:
elementType:
namedType: io.k8s.api.resource.v1alpha2.DriverAllocationResult
elementRelationship: atomic
- name: vendorClaimParameters
type:
namedType: __untyped_atomic_
- name: vendorClassParameters
type:
namedType: __untyped_atomic_
- name: io.k8s.api.resource.v1alpha2.VendorParameters
map:
fields:
- name: driverName
type:
scalar: string
- name: parameters
type:
namedType: __untyped_atomic_
- name: io.k8s.api.scheduling.v1.PriorityClass
map:
fields:

View File

@@ -0,0 +1,45 @@
/*
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 v1alpha2
import (
v1alpha2 "k8s.io/api/resource/v1alpha2"
runtime "k8s.io/apimachinery/pkg/runtime"
)
// DriverAllocationResultApplyConfiguration represents an declarative configuration of the DriverAllocationResult type for use
// with apply.
type DriverAllocationResultApplyConfiguration struct {
VendorRequestParameters *runtime.RawExtension `json:"vendorRequestParameters,omitempty"`
v1alpha2.AllocationResultModel `json:",inline"`
}
// DriverAllocationResultApplyConfiguration constructs an declarative configuration of the DriverAllocationResult type for use with
// apply.
func DriverAllocationResult() *DriverAllocationResultApplyConfiguration {
return &DriverAllocationResultApplyConfiguration{}
}
// WithVendorRequestParameters sets the VendorRequestParameters 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 VendorRequestParameters field is set to the value of the last call.
func (b *DriverAllocationResultApplyConfiguration) WithVendorRequestParameters(value runtime.RawExtension) *DriverAllocationResultApplyConfiguration {
b.VendorRequestParameters = &value
return b
}

View File

@@ -0,0 +1,66 @@
/*
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 v1alpha2
import (
runtime "k8s.io/apimachinery/pkg/runtime"
)
// DriverRequestsApplyConfiguration represents an declarative configuration of the DriverRequests type for use
// with apply.
type DriverRequestsApplyConfiguration struct {
DriverName *string `json:"driverName,omitempty"`
VendorParameters *runtime.RawExtension `json:"vendorParameters,omitempty"`
Requests []ResourceRequestApplyConfiguration `json:"requests,omitempty"`
}
// DriverRequestsApplyConfiguration constructs an declarative configuration of the DriverRequests type for use with
// apply.
func DriverRequests() *DriverRequestsApplyConfiguration {
return &DriverRequestsApplyConfiguration{}
}
// WithDriverName sets the DriverName 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 DriverName field is set to the value of the last call.
func (b *DriverRequestsApplyConfiguration) WithDriverName(value string) *DriverRequestsApplyConfiguration {
b.DriverName = &value
return b
}
// WithVendorParameters sets the VendorParameters 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 VendorParameters field is set to the value of the last call.
func (b *DriverRequestsApplyConfiguration) WithVendorParameters(value runtime.RawExtension) *DriverRequestsApplyConfiguration {
b.VendorParameters = &value
return b
}
// WithRequests adds the given value to the Requests field in the declarative configuration
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
// If called multiple times, values provided by each call will be appended to the Requests field.
func (b *DriverRequestsApplyConfiguration) WithRequests(values ...*ResourceRequestApplyConfiguration) *DriverRequestsApplyConfiguration {
for i := range values {
if values[i] == nil {
panic("nil value passed to WithRequests")
}
b.Requests = append(b.Requests, *values[i])
}
return b
}

View File

@@ -0,0 +1,257 @@
/*
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 v1alpha2
import (
v1alpha2 "k8s.io/api/resource/v1alpha2"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types"
managedfields "k8s.io/apimachinery/pkg/util/managedfields"
internal "k8s.io/client-go/applyconfigurations/internal"
v1 "k8s.io/client-go/applyconfigurations/meta/v1"
)
// NodeResourceSliceApplyConfiguration represents an declarative configuration of the NodeResourceSlice type for use
// with apply.
type NodeResourceSliceApplyConfiguration struct {
v1.TypeMetaApplyConfiguration `json:",inline"`
*v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"`
NodeName *string `json:"nodeName,omitempty"`
DriverName *string `json:"driverName,omitempty"`
v1alpha2.NodeResourceModel `json:",inline"`
}
// NodeResourceSlice constructs an declarative configuration of the NodeResourceSlice type for use with
// apply.
func NodeResourceSlice(name string) *NodeResourceSliceApplyConfiguration {
b := &NodeResourceSliceApplyConfiguration{}
b.WithName(name)
b.WithKind("NodeResourceSlice")
b.WithAPIVersion("resource.k8s.io/v1alpha2")
return b
}
// ExtractNodeResourceSlice extracts the applied configuration owned by fieldManager from
// nodeResourceSlice. If no managedFields are found in nodeResourceSlice for fieldManager, a
// NodeResourceSliceApplyConfiguration is returned with only the Name, Namespace (if applicable),
// APIVersion and Kind populated. It is possible that no managed fields were found for because other
// field managers have taken ownership of all the fields previously owned by fieldManager, or because
// the fieldManager never owned fields any fields.
// nodeResourceSlice must be a unmodified NodeResourceSlice API object that was retrieved from the Kubernetes API.
// ExtractNodeResourceSlice provides a way to perform a extract/modify-in-place/apply workflow.
// Note that an extracted apply configuration will contain fewer fields than what the fieldManager previously
// applied if another fieldManager has updated or force applied any of the previously applied fields.
// Experimental!
func ExtractNodeResourceSlice(nodeResourceSlice *v1alpha2.NodeResourceSlice, fieldManager string) (*NodeResourceSliceApplyConfiguration, error) {
return extractNodeResourceSlice(nodeResourceSlice, fieldManager, "")
}
// ExtractNodeResourceSliceStatus is the same as ExtractNodeResourceSlice except
// that it extracts the status subresource applied configuration.
// Experimental!
func ExtractNodeResourceSliceStatus(nodeResourceSlice *v1alpha2.NodeResourceSlice, fieldManager string) (*NodeResourceSliceApplyConfiguration, error) {
return extractNodeResourceSlice(nodeResourceSlice, fieldManager, "status")
}
func extractNodeResourceSlice(nodeResourceSlice *v1alpha2.NodeResourceSlice, fieldManager string, subresource string) (*NodeResourceSliceApplyConfiguration, error) {
b := &NodeResourceSliceApplyConfiguration{}
err := managedfields.ExtractInto(nodeResourceSlice, internal.Parser().Type("io.k8s.api.resource.v1alpha2.NodeResourceSlice"), fieldManager, b, subresource)
if err != nil {
return nil, err
}
b.WithName(nodeResourceSlice.Name)
b.WithKind("NodeResourceSlice")
b.WithAPIVersion("resource.k8s.io/v1alpha2")
return b, nil
}
// WithKind sets the Kind 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 Kind field is set to the value of the last call.
func (b *NodeResourceSliceApplyConfiguration) WithKind(value string) *NodeResourceSliceApplyConfiguration {
b.Kind = &value
return b
}
// WithAPIVersion sets the APIVersion 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 APIVersion field is set to the value of the last call.
func (b *NodeResourceSliceApplyConfiguration) WithAPIVersion(value string) *NodeResourceSliceApplyConfiguration {
b.APIVersion = &value
return b
}
// WithName sets the Name 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 Name field is set to the value of the last call.
func (b *NodeResourceSliceApplyConfiguration) WithName(value string) *NodeResourceSliceApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
b.Name = &value
return b
}
// WithGenerateName sets the GenerateName 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 GenerateName field is set to the value of the last call.
func (b *NodeResourceSliceApplyConfiguration) WithGenerateName(value string) *NodeResourceSliceApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
b.GenerateName = &value
return b
}
// WithNamespace sets the Namespace 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 Namespace field is set to the value of the last call.
func (b *NodeResourceSliceApplyConfiguration) WithNamespace(value string) *NodeResourceSliceApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
b.Namespace = &value
return b
}
// WithUID sets the UID 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 UID field is set to the value of the last call.
func (b *NodeResourceSliceApplyConfiguration) WithUID(value types.UID) *NodeResourceSliceApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
b.UID = &value
return b
}
// WithResourceVersion sets the ResourceVersion 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 ResourceVersion field is set to the value of the last call.
func (b *NodeResourceSliceApplyConfiguration) WithResourceVersion(value string) *NodeResourceSliceApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
b.ResourceVersion = &value
return b
}
// WithGeneration sets the Generation 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 Generation field is set to the value of the last call.
func (b *NodeResourceSliceApplyConfiguration) WithGeneration(value int64) *NodeResourceSliceApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
b.Generation = &value
return b
}
// WithCreationTimestamp sets the CreationTimestamp 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 CreationTimestamp field is set to the value of the last call.
func (b *NodeResourceSliceApplyConfiguration) WithCreationTimestamp(value metav1.Time) *NodeResourceSliceApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
b.CreationTimestamp = &value
return b
}
// WithDeletionTimestamp sets the DeletionTimestamp 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 DeletionTimestamp field is set to the value of the last call.
func (b *NodeResourceSliceApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *NodeResourceSliceApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
b.DeletionTimestamp = &value
return b
}
// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds 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 DeletionGracePeriodSeconds field is set to the value of the last call.
func (b *NodeResourceSliceApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *NodeResourceSliceApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
b.DeletionGracePeriodSeconds = &value
return b
}
// WithLabels puts the entries into the Labels field in the declarative configuration
// 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 Labels field,
// overwriting an existing map entries in Labels field with the same key.
func (b *NodeResourceSliceApplyConfiguration) WithLabels(entries map[string]string) *NodeResourceSliceApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
if b.Labels == nil && len(entries) > 0 {
b.Labels = make(map[string]string, len(entries))
}
for k, v := range entries {
b.Labels[k] = v
}
return b
}
// WithAnnotations puts the entries into the Annotations field in the declarative configuration
// 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 Annotations field,
// overwriting an existing map entries in Annotations field with the same key.
func (b *NodeResourceSliceApplyConfiguration) WithAnnotations(entries map[string]string) *NodeResourceSliceApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
if b.Annotations == nil && len(entries) > 0 {
b.Annotations = make(map[string]string, len(entries))
}
for k, v := range entries {
b.Annotations[k] = v
}
return b
}
// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
// If called multiple times, values provided by each call will be appended to the OwnerReferences field.
func (b *NodeResourceSliceApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *NodeResourceSliceApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
for i := range values {
if values[i] == nil {
panic("nil value passed to WithOwnerReferences")
}
b.OwnerReferences = append(b.OwnerReferences, *values[i])
}
return b
}
// WithFinalizers adds the given value to the Finalizers field in the declarative configuration
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
// If called multiple times, values provided by each call will be appended to the Finalizers field.
func (b *NodeResourceSliceApplyConfiguration) WithFinalizers(values ...string) *NodeResourceSliceApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
for i := range values {
b.Finalizers = append(b.Finalizers, values[i])
}
return b
}
func (b *NodeResourceSliceApplyConfiguration) ensureObjectMetaApplyConfigurationExists() {
if b.ObjectMetaApplyConfiguration == nil {
b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{}
}
}
// WithNodeName sets the NodeName 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 NodeName field is set to the value of the last call.
func (b *NodeResourceSliceApplyConfiguration) WithNodeName(value string) *NodeResourceSliceApplyConfiguration {
b.NodeName = &value
return b
}
// WithDriverName sets the DriverName 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 DriverName field is set to the value of the last call.
func (b *NodeResourceSliceApplyConfiguration) WithDriverName(value string) *NodeResourceSliceApplyConfiguration {
b.DriverName = &value
return b
}

View File

@@ -0,0 +1,272 @@
/*
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 v1alpha2
import (
resourcev1alpha2 "k8s.io/api/resource/v1alpha2"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types"
managedfields "k8s.io/apimachinery/pkg/util/managedfields"
internal "k8s.io/client-go/applyconfigurations/internal"
v1 "k8s.io/client-go/applyconfigurations/meta/v1"
)
// ResourceClaimParametersApplyConfiguration represents an declarative configuration of the ResourceClaimParameters type for use
// with apply.
type ResourceClaimParametersApplyConfiguration struct {
v1.TypeMetaApplyConfiguration `json:",inline"`
*v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"`
GeneratedFrom *ResourceClaimParametersReferenceApplyConfiguration `json:"generatedFrom,omitempty"`
Shareable *bool `json:"shareable,omitempty"`
DriverRequests []DriverRequestsApplyConfiguration `json:"driverRequests,omitempty"`
}
// ResourceClaimParameters constructs an declarative configuration of the ResourceClaimParameters type for use with
// apply.
func ResourceClaimParameters(name, namespace string) *ResourceClaimParametersApplyConfiguration {
b := &ResourceClaimParametersApplyConfiguration{}
b.WithName(name)
b.WithNamespace(namespace)
b.WithKind("ResourceClaimParameters")
b.WithAPIVersion("resource.k8s.io/v1alpha2")
return b
}
// ExtractResourceClaimParameters extracts the applied configuration owned by fieldManager from
// resourceClaimParameters. If no managedFields are found in resourceClaimParameters for fieldManager, a
// ResourceClaimParametersApplyConfiguration is returned with only the Name, Namespace (if applicable),
// APIVersion and Kind populated. It is possible that no managed fields were found for because other
// field managers have taken ownership of all the fields previously owned by fieldManager, or because
// the fieldManager never owned fields any fields.
// resourceClaimParameters must be a unmodified ResourceClaimParameters API object that was retrieved from the Kubernetes API.
// ExtractResourceClaimParameters provides a way to perform a extract/modify-in-place/apply workflow.
// Note that an extracted apply configuration will contain fewer fields than what the fieldManager previously
// applied if another fieldManager has updated or force applied any of the previously applied fields.
// Experimental!
func ExtractResourceClaimParameters(resourceClaimParameters *resourcev1alpha2.ResourceClaimParameters, fieldManager string) (*ResourceClaimParametersApplyConfiguration, error) {
return extractResourceClaimParameters(resourceClaimParameters, fieldManager, "")
}
// ExtractResourceClaimParametersStatus is the same as ExtractResourceClaimParameters except
// that it extracts the status subresource applied configuration.
// Experimental!
func ExtractResourceClaimParametersStatus(resourceClaimParameters *resourcev1alpha2.ResourceClaimParameters, fieldManager string) (*ResourceClaimParametersApplyConfiguration, error) {
return extractResourceClaimParameters(resourceClaimParameters, fieldManager, "status")
}
func extractResourceClaimParameters(resourceClaimParameters *resourcev1alpha2.ResourceClaimParameters, fieldManager string, subresource string) (*ResourceClaimParametersApplyConfiguration, error) {
b := &ResourceClaimParametersApplyConfiguration{}
err := managedfields.ExtractInto(resourceClaimParameters, internal.Parser().Type("io.k8s.api.resource.v1alpha2.ResourceClaimParameters"), fieldManager, b, subresource)
if err != nil {
return nil, err
}
b.WithName(resourceClaimParameters.Name)
b.WithNamespace(resourceClaimParameters.Namespace)
b.WithKind("ResourceClaimParameters")
b.WithAPIVersion("resource.k8s.io/v1alpha2")
return b, nil
}
// WithKind sets the Kind 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 Kind field is set to the value of the last call.
func (b *ResourceClaimParametersApplyConfiguration) WithKind(value string) *ResourceClaimParametersApplyConfiguration {
b.Kind = &value
return b
}
// WithAPIVersion sets the APIVersion 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 APIVersion field is set to the value of the last call.
func (b *ResourceClaimParametersApplyConfiguration) WithAPIVersion(value string) *ResourceClaimParametersApplyConfiguration {
b.APIVersion = &value
return b
}
// WithName sets the Name 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 Name field is set to the value of the last call.
func (b *ResourceClaimParametersApplyConfiguration) WithName(value string) *ResourceClaimParametersApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
b.Name = &value
return b
}
// WithGenerateName sets the GenerateName 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 GenerateName field is set to the value of the last call.
func (b *ResourceClaimParametersApplyConfiguration) WithGenerateName(value string) *ResourceClaimParametersApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
b.GenerateName = &value
return b
}
// WithNamespace sets the Namespace 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 Namespace field is set to the value of the last call.
func (b *ResourceClaimParametersApplyConfiguration) WithNamespace(value string) *ResourceClaimParametersApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
b.Namespace = &value
return b
}
// WithUID sets the UID 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 UID field is set to the value of the last call.
func (b *ResourceClaimParametersApplyConfiguration) WithUID(value types.UID) *ResourceClaimParametersApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
b.UID = &value
return b
}
// WithResourceVersion sets the ResourceVersion 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 ResourceVersion field is set to the value of the last call.
func (b *ResourceClaimParametersApplyConfiguration) WithResourceVersion(value string) *ResourceClaimParametersApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
b.ResourceVersion = &value
return b
}
// WithGeneration sets the Generation 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 Generation field is set to the value of the last call.
func (b *ResourceClaimParametersApplyConfiguration) WithGeneration(value int64) *ResourceClaimParametersApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
b.Generation = &value
return b
}
// WithCreationTimestamp sets the CreationTimestamp 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 CreationTimestamp field is set to the value of the last call.
func (b *ResourceClaimParametersApplyConfiguration) WithCreationTimestamp(value metav1.Time) *ResourceClaimParametersApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
b.CreationTimestamp = &value
return b
}
// WithDeletionTimestamp sets the DeletionTimestamp 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 DeletionTimestamp field is set to the value of the last call.
func (b *ResourceClaimParametersApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *ResourceClaimParametersApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
b.DeletionTimestamp = &value
return b
}
// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds 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 DeletionGracePeriodSeconds field is set to the value of the last call.
func (b *ResourceClaimParametersApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *ResourceClaimParametersApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
b.DeletionGracePeriodSeconds = &value
return b
}
// WithLabels puts the entries into the Labels field in the declarative configuration
// 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 Labels field,
// overwriting an existing map entries in Labels field with the same key.
func (b *ResourceClaimParametersApplyConfiguration) WithLabels(entries map[string]string) *ResourceClaimParametersApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
if b.Labels == nil && len(entries) > 0 {
b.Labels = make(map[string]string, len(entries))
}
for k, v := range entries {
b.Labels[k] = v
}
return b
}
// WithAnnotations puts the entries into the Annotations field in the declarative configuration
// 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 Annotations field,
// overwriting an existing map entries in Annotations field with the same key.
func (b *ResourceClaimParametersApplyConfiguration) WithAnnotations(entries map[string]string) *ResourceClaimParametersApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
if b.Annotations == nil && len(entries) > 0 {
b.Annotations = make(map[string]string, len(entries))
}
for k, v := range entries {
b.Annotations[k] = v
}
return b
}
// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
// If called multiple times, values provided by each call will be appended to the OwnerReferences field.
func (b *ResourceClaimParametersApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *ResourceClaimParametersApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
for i := range values {
if values[i] == nil {
panic("nil value passed to WithOwnerReferences")
}
b.OwnerReferences = append(b.OwnerReferences, *values[i])
}
return b
}
// WithFinalizers adds the given value to the Finalizers field in the declarative configuration
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
// If called multiple times, values provided by each call will be appended to the Finalizers field.
func (b *ResourceClaimParametersApplyConfiguration) WithFinalizers(values ...string) *ResourceClaimParametersApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
for i := range values {
b.Finalizers = append(b.Finalizers, values[i])
}
return b
}
func (b *ResourceClaimParametersApplyConfiguration) ensureObjectMetaApplyConfigurationExists() {
if b.ObjectMetaApplyConfiguration == nil {
b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{}
}
}
// WithGeneratedFrom sets the GeneratedFrom 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 GeneratedFrom field is set to the value of the last call.
func (b *ResourceClaimParametersApplyConfiguration) WithGeneratedFrom(value *ResourceClaimParametersReferenceApplyConfiguration) *ResourceClaimParametersApplyConfiguration {
b.GeneratedFrom = value
return b
}
// WithShareable sets the Shareable 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 Shareable field is set to the value of the last call.
func (b *ResourceClaimParametersApplyConfiguration) WithShareable(value bool) *ResourceClaimParametersApplyConfiguration {
b.Shareable = &value
return b
}
// WithDriverRequests adds the given value to the DriverRequests field in the declarative configuration
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
// If called multiple times, values provided by each call will be appended to the DriverRequests field.
func (b *ResourceClaimParametersApplyConfiguration) WithDriverRequests(values ...*DriverRequestsApplyConfiguration) *ResourceClaimParametersApplyConfiguration {
for i := range values {
if values[i] == nil {
panic("nil value passed to WithDriverRequests")
}
b.DriverRequests = append(b.DriverRequests, *values[i])
}
return b
}

View File

@@ -36,6 +36,7 @@ type ResourceClassApplyConfiguration struct {
DriverName *string `json:"driverName,omitempty"`
ParametersRef *ResourceClassParametersReferenceApplyConfiguration `json:"parametersRef,omitempty"`
SuitableNodes *corev1.NodeSelectorApplyConfiguration `json:"suitableNodes,omitempty"`
StructuredParameters *bool `json:"structuredParameters,omitempty"`
}
// ResourceClass constructs an declarative configuration of the ResourceClass type for use with
@@ -264,3 +265,11 @@ func (b *ResourceClassApplyConfiguration) WithSuitableNodes(value *corev1.NodeSe
b.SuitableNodes = value
return b
}
// WithStructuredParameters sets the StructuredParameters 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 StructuredParameters field is set to the value of the last call.
func (b *ResourceClassApplyConfiguration) WithStructuredParameters(value bool) *ResourceClassApplyConfiguration {
b.StructuredParameters = &value
return b
}

View File

@@ -0,0 +1,277 @@
/*
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 v1alpha2
import (
resourcev1alpha2 "k8s.io/api/resource/v1alpha2"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types"
managedfields "k8s.io/apimachinery/pkg/util/managedfields"
internal "k8s.io/client-go/applyconfigurations/internal"
v1 "k8s.io/client-go/applyconfigurations/meta/v1"
)
// ResourceClassParametersApplyConfiguration represents an declarative configuration of the ResourceClassParameters type for use
// with apply.
type ResourceClassParametersApplyConfiguration struct {
v1.TypeMetaApplyConfiguration `json:",inline"`
*v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"`
GeneratedFrom *ResourceClassParametersReferenceApplyConfiguration `json:"generatedFrom,omitempty"`
VendorParameters []VendorParametersApplyConfiguration `json:"vendorParameters,omitempty"`
Filters []ResourceFilterApplyConfiguration `json:"filters,omitempty"`
}
// ResourceClassParameters constructs an declarative configuration of the ResourceClassParameters type for use with
// apply.
func ResourceClassParameters(name, namespace string) *ResourceClassParametersApplyConfiguration {
b := &ResourceClassParametersApplyConfiguration{}
b.WithName(name)
b.WithNamespace(namespace)
b.WithKind("ResourceClassParameters")
b.WithAPIVersion("resource.k8s.io/v1alpha2")
return b
}
// ExtractResourceClassParameters extracts the applied configuration owned by fieldManager from
// resourceClassParameters. If no managedFields are found in resourceClassParameters for fieldManager, a
// ResourceClassParametersApplyConfiguration is returned with only the Name, Namespace (if applicable),
// APIVersion and Kind populated. It is possible that no managed fields were found for because other
// field managers have taken ownership of all the fields previously owned by fieldManager, or because
// the fieldManager never owned fields any fields.
// resourceClassParameters must be a unmodified ResourceClassParameters API object that was retrieved from the Kubernetes API.
// ExtractResourceClassParameters provides a way to perform a extract/modify-in-place/apply workflow.
// Note that an extracted apply configuration will contain fewer fields than what the fieldManager previously
// applied if another fieldManager has updated or force applied any of the previously applied fields.
// Experimental!
func ExtractResourceClassParameters(resourceClassParameters *resourcev1alpha2.ResourceClassParameters, fieldManager string) (*ResourceClassParametersApplyConfiguration, error) {
return extractResourceClassParameters(resourceClassParameters, fieldManager, "")
}
// ExtractResourceClassParametersStatus is the same as ExtractResourceClassParameters except
// that it extracts the status subresource applied configuration.
// Experimental!
func ExtractResourceClassParametersStatus(resourceClassParameters *resourcev1alpha2.ResourceClassParameters, fieldManager string) (*ResourceClassParametersApplyConfiguration, error) {
return extractResourceClassParameters(resourceClassParameters, fieldManager, "status")
}
func extractResourceClassParameters(resourceClassParameters *resourcev1alpha2.ResourceClassParameters, fieldManager string, subresource string) (*ResourceClassParametersApplyConfiguration, error) {
b := &ResourceClassParametersApplyConfiguration{}
err := managedfields.ExtractInto(resourceClassParameters, internal.Parser().Type("io.k8s.api.resource.v1alpha2.ResourceClassParameters"), fieldManager, b, subresource)
if err != nil {
return nil, err
}
b.WithName(resourceClassParameters.Name)
b.WithNamespace(resourceClassParameters.Namespace)
b.WithKind("ResourceClassParameters")
b.WithAPIVersion("resource.k8s.io/v1alpha2")
return b, nil
}
// WithKind sets the Kind 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 Kind field is set to the value of the last call.
func (b *ResourceClassParametersApplyConfiguration) WithKind(value string) *ResourceClassParametersApplyConfiguration {
b.Kind = &value
return b
}
// WithAPIVersion sets the APIVersion 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 APIVersion field is set to the value of the last call.
func (b *ResourceClassParametersApplyConfiguration) WithAPIVersion(value string) *ResourceClassParametersApplyConfiguration {
b.APIVersion = &value
return b
}
// WithName sets the Name 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 Name field is set to the value of the last call.
func (b *ResourceClassParametersApplyConfiguration) WithName(value string) *ResourceClassParametersApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
b.Name = &value
return b
}
// WithGenerateName sets the GenerateName 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 GenerateName field is set to the value of the last call.
func (b *ResourceClassParametersApplyConfiguration) WithGenerateName(value string) *ResourceClassParametersApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
b.GenerateName = &value
return b
}
// WithNamespace sets the Namespace 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 Namespace field is set to the value of the last call.
func (b *ResourceClassParametersApplyConfiguration) WithNamespace(value string) *ResourceClassParametersApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
b.Namespace = &value
return b
}
// WithUID sets the UID 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 UID field is set to the value of the last call.
func (b *ResourceClassParametersApplyConfiguration) WithUID(value types.UID) *ResourceClassParametersApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
b.UID = &value
return b
}
// WithResourceVersion sets the ResourceVersion 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 ResourceVersion field is set to the value of the last call.
func (b *ResourceClassParametersApplyConfiguration) WithResourceVersion(value string) *ResourceClassParametersApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
b.ResourceVersion = &value
return b
}
// WithGeneration sets the Generation 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 Generation field is set to the value of the last call.
func (b *ResourceClassParametersApplyConfiguration) WithGeneration(value int64) *ResourceClassParametersApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
b.Generation = &value
return b
}
// WithCreationTimestamp sets the CreationTimestamp 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 CreationTimestamp field is set to the value of the last call.
func (b *ResourceClassParametersApplyConfiguration) WithCreationTimestamp(value metav1.Time) *ResourceClassParametersApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
b.CreationTimestamp = &value
return b
}
// WithDeletionTimestamp sets the DeletionTimestamp 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 DeletionTimestamp field is set to the value of the last call.
func (b *ResourceClassParametersApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *ResourceClassParametersApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
b.DeletionTimestamp = &value
return b
}
// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds 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 DeletionGracePeriodSeconds field is set to the value of the last call.
func (b *ResourceClassParametersApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *ResourceClassParametersApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
b.DeletionGracePeriodSeconds = &value
return b
}
// WithLabels puts the entries into the Labels field in the declarative configuration
// 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 Labels field,
// overwriting an existing map entries in Labels field with the same key.
func (b *ResourceClassParametersApplyConfiguration) WithLabels(entries map[string]string) *ResourceClassParametersApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
if b.Labels == nil && len(entries) > 0 {
b.Labels = make(map[string]string, len(entries))
}
for k, v := range entries {
b.Labels[k] = v
}
return b
}
// WithAnnotations puts the entries into the Annotations field in the declarative configuration
// 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 Annotations field,
// overwriting an existing map entries in Annotations field with the same key.
func (b *ResourceClassParametersApplyConfiguration) WithAnnotations(entries map[string]string) *ResourceClassParametersApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
if b.Annotations == nil && len(entries) > 0 {
b.Annotations = make(map[string]string, len(entries))
}
for k, v := range entries {
b.Annotations[k] = v
}
return b
}
// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
// If called multiple times, values provided by each call will be appended to the OwnerReferences field.
func (b *ResourceClassParametersApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *ResourceClassParametersApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
for i := range values {
if values[i] == nil {
panic("nil value passed to WithOwnerReferences")
}
b.OwnerReferences = append(b.OwnerReferences, *values[i])
}
return b
}
// WithFinalizers adds the given value to the Finalizers field in the declarative configuration
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
// If called multiple times, values provided by each call will be appended to the Finalizers field.
func (b *ResourceClassParametersApplyConfiguration) WithFinalizers(values ...string) *ResourceClassParametersApplyConfiguration {
b.ensureObjectMetaApplyConfigurationExists()
for i := range values {
b.Finalizers = append(b.Finalizers, values[i])
}
return b
}
func (b *ResourceClassParametersApplyConfiguration) ensureObjectMetaApplyConfigurationExists() {
if b.ObjectMetaApplyConfiguration == nil {
b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{}
}
}
// WithGeneratedFrom sets the GeneratedFrom 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 GeneratedFrom field is set to the value of the last call.
func (b *ResourceClassParametersApplyConfiguration) WithGeneratedFrom(value *ResourceClassParametersReferenceApplyConfiguration) *ResourceClassParametersApplyConfiguration {
b.GeneratedFrom = value
return b
}
// WithVendorParameters adds the given value to the VendorParameters field in the declarative configuration
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
// If called multiple times, values provided by each call will be appended to the VendorParameters field.
func (b *ResourceClassParametersApplyConfiguration) WithVendorParameters(values ...*VendorParametersApplyConfiguration) *ResourceClassParametersApplyConfiguration {
for i := range values {
if values[i] == nil {
panic("nil value passed to WithVendorParameters")
}
b.VendorParameters = append(b.VendorParameters, *values[i])
}
return b
}
// WithFilters adds the given value to the Filters field in the declarative configuration
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
// If called multiple times, values provided by each call will be appended to the Filters field.
func (b *ResourceClassParametersApplyConfiguration) WithFilters(values ...*ResourceFilterApplyConfiguration) *ResourceClassParametersApplyConfiguration {
for i := range values {
if values[i] == nil {
panic("nil value passed to WithFilters")
}
b.Filters = append(b.Filters, *values[i])
}
return b
}

View File

@@ -0,0 +1,44 @@
/*
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 v1alpha2
import (
v1alpha2 "k8s.io/api/resource/v1alpha2"
)
// ResourceFilterApplyConfiguration represents an declarative configuration of the ResourceFilter type for use
// with apply.
type ResourceFilterApplyConfiguration struct {
DriverName *string `json:"driverName,omitempty"`
v1alpha2.ResourceFilterModel `json:",inline"`
}
// ResourceFilterApplyConfiguration constructs an declarative configuration of the ResourceFilter type for use with
// apply.
func ResourceFilter() *ResourceFilterApplyConfiguration {
return &ResourceFilterApplyConfiguration{}
}
// WithDriverName sets the DriverName 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 DriverName field is set to the value of the last call.
func (b *ResourceFilterApplyConfiguration) WithDriverName(value string) *ResourceFilterApplyConfiguration {
b.DriverName = &value
return b
}

View File

@@ -21,8 +21,9 @@ package v1alpha2
// ResourceHandleApplyConfiguration represents an declarative configuration of the ResourceHandle type for use
// with apply.
type ResourceHandleApplyConfiguration struct {
DriverName *string `json:"driverName,omitempty"`
Data *string `json:"data,omitempty"`
DriverName *string `json:"driverName,omitempty"`
Data *string `json:"data,omitempty"`
StructuredData *StructuredResourceHandleApplyConfiguration `json:"structuredData,omitempty"`
}
// ResourceHandleApplyConfiguration constructs an declarative configuration of the ResourceHandle type for use with
@@ -46,3 +47,11 @@ func (b *ResourceHandleApplyConfiguration) WithData(value string) *ResourceHandl
b.Data = &value
return b
}
// WithStructuredData sets the StructuredData 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 StructuredData field is set to the value of the last call.
func (b *ResourceHandleApplyConfiguration) WithStructuredData(value *StructuredResourceHandleApplyConfiguration) *ResourceHandleApplyConfiguration {
b.StructuredData = value
return b
}

View File

@@ -0,0 +1,45 @@
/*
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 v1alpha2
import (
v1alpha2 "k8s.io/api/resource/v1alpha2"
runtime "k8s.io/apimachinery/pkg/runtime"
)
// ResourceRequestApplyConfiguration represents an declarative configuration of the ResourceRequest type for use
// with apply.
type ResourceRequestApplyConfiguration struct {
VendorParameters *runtime.RawExtension `json:"vendorParameters,omitempty"`
v1alpha2.ResourceRequestModel `json:",inline"`
}
// ResourceRequestApplyConfiguration constructs an declarative configuration of the ResourceRequest type for use with
// apply.
func ResourceRequest() *ResourceRequestApplyConfiguration {
return &ResourceRequestApplyConfiguration{}
}
// WithVendorParameters sets the VendorParameters 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 VendorParameters field is set to the value of the last call.
func (b *ResourceRequestApplyConfiguration) WithVendorParameters(value runtime.RawExtension) *ResourceRequestApplyConfiguration {
b.VendorParameters = &value
return b
}

View File

@@ -0,0 +1,75 @@
/*
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 v1alpha2
import (
runtime "k8s.io/apimachinery/pkg/runtime"
)
// StructuredResourceHandleApplyConfiguration represents an declarative configuration of the StructuredResourceHandle type for use
// with apply.
type StructuredResourceHandleApplyConfiguration struct {
VendorClassParameters *runtime.RawExtension `json:"vendorClassParameters,omitempty"`
VendorClaimParameters *runtime.RawExtension `json:"vendorClaimParameters,omitempty"`
NodeName *string `json:"nodeName,omitempty"`
Results []DriverAllocationResultApplyConfiguration `json:"results,omitempty"`
}
// StructuredResourceHandleApplyConfiguration constructs an declarative configuration of the StructuredResourceHandle type for use with
// apply.
func StructuredResourceHandle() *StructuredResourceHandleApplyConfiguration {
return &StructuredResourceHandleApplyConfiguration{}
}
// WithVendorClassParameters sets the VendorClassParameters 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 VendorClassParameters field is set to the value of the last call.
func (b *StructuredResourceHandleApplyConfiguration) WithVendorClassParameters(value runtime.RawExtension) *StructuredResourceHandleApplyConfiguration {
b.VendorClassParameters = &value
return b
}
// WithVendorClaimParameters sets the VendorClaimParameters 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 VendorClaimParameters field is set to the value of the last call.
func (b *StructuredResourceHandleApplyConfiguration) WithVendorClaimParameters(value runtime.RawExtension) *StructuredResourceHandleApplyConfiguration {
b.VendorClaimParameters = &value
return b
}
// WithNodeName sets the NodeName 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 NodeName field is set to the value of the last call.
func (b *StructuredResourceHandleApplyConfiguration) WithNodeName(value string) *StructuredResourceHandleApplyConfiguration {
b.NodeName = &value
return b
}
// WithResults adds the given value to the Results field in the declarative configuration
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
// If called multiple times, values provided by each call will be appended to the Results field.
func (b *StructuredResourceHandleApplyConfiguration) WithResults(values ...*DriverAllocationResultApplyConfiguration) *StructuredResourceHandleApplyConfiguration {
for i := range values {
if values[i] == nil {
panic("nil value passed to WithResults")
}
b.Results = append(b.Results, *values[i])
}
return b
}

View File

@@ -0,0 +1,52 @@
/*
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 v1alpha2
import (
runtime "k8s.io/apimachinery/pkg/runtime"
)
// VendorParametersApplyConfiguration represents an declarative configuration of the VendorParameters type for use
// with apply.
type VendorParametersApplyConfiguration struct {
DriverName *string `json:"driverName,omitempty"`
Parameters *runtime.RawExtension `json:"parameters,omitempty"`
}
// VendorParametersApplyConfiguration constructs an declarative configuration of the VendorParameters type for use with
// apply.
func VendorParameters() *VendorParametersApplyConfiguration {
return &VendorParametersApplyConfiguration{}
}
// WithDriverName sets the DriverName 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 DriverName field is set to the value of the last call.
func (b *VendorParametersApplyConfiguration) WithDriverName(value string) *VendorParametersApplyConfiguration {
b.DriverName = &value
return b
}
// WithParameters sets the Parameters 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 Parameters field is set to the value of the last call.
func (b *VendorParametersApplyConfiguration) WithParameters(value runtime.RawExtension) *VendorParametersApplyConfiguration {
b.Parameters = &value
return b
}

View File

@@ -1523,6 +1523,12 @@ func ForKind(kind schema.GroupVersionKind) interface{} {
// Group=resource.k8s.io, Version=v1alpha2
case v1alpha2.SchemeGroupVersion.WithKind("AllocationResult"):
return &resourcev1alpha2.AllocationResultApplyConfiguration{}
case v1alpha2.SchemeGroupVersion.WithKind("DriverAllocationResult"):
return &resourcev1alpha2.DriverAllocationResultApplyConfiguration{}
case v1alpha2.SchemeGroupVersion.WithKind("DriverRequests"):
return &resourcev1alpha2.DriverRequestsApplyConfiguration{}
case v1alpha2.SchemeGroupVersion.WithKind("NodeResourceSlice"):
return &resourcev1alpha2.NodeResourceSliceApplyConfiguration{}
case v1alpha2.SchemeGroupVersion.WithKind("PodSchedulingContext"):
return &resourcev1alpha2.PodSchedulingContextApplyConfiguration{}
case v1alpha2.SchemeGroupVersion.WithKind("PodSchedulingContextSpec"):
@@ -1533,6 +1539,8 @@ func ForKind(kind schema.GroupVersionKind) interface{} {
return &resourcev1alpha2.ResourceClaimApplyConfiguration{}
case v1alpha2.SchemeGroupVersion.WithKind("ResourceClaimConsumerReference"):
return &resourcev1alpha2.ResourceClaimConsumerReferenceApplyConfiguration{}
case v1alpha2.SchemeGroupVersion.WithKind("ResourceClaimParameters"):
return &resourcev1alpha2.ResourceClaimParametersApplyConfiguration{}
case v1alpha2.SchemeGroupVersion.WithKind("ResourceClaimParametersReference"):
return &resourcev1alpha2.ResourceClaimParametersReferenceApplyConfiguration{}
case v1alpha2.SchemeGroupVersion.WithKind("ResourceClaimSchedulingStatus"):
@@ -1547,10 +1555,20 @@ func ForKind(kind schema.GroupVersionKind) interface{} {
return &resourcev1alpha2.ResourceClaimTemplateSpecApplyConfiguration{}
case v1alpha2.SchemeGroupVersion.WithKind("ResourceClass"):
return &resourcev1alpha2.ResourceClassApplyConfiguration{}
case v1alpha2.SchemeGroupVersion.WithKind("ResourceClassParameters"):
return &resourcev1alpha2.ResourceClassParametersApplyConfiguration{}
case v1alpha2.SchemeGroupVersion.WithKind("ResourceClassParametersReference"):
return &resourcev1alpha2.ResourceClassParametersReferenceApplyConfiguration{}
case v1alpha2.SchemeGroupVersion.WithKind("ResourceFilter"):
return &resourcev1alpha2.ResourceFilterApplyConfiguration{}
case v1alpha2.SchemeGroupVersion.WithKind("ResourceHandle"):
return &resourcev1alpha2.ResourceHandleApplyConfiguration{}
case v1alpha2.SchemeGroupVersion.WithKind("ResourceRequest"):
return &resourcev1alpha2.ResourceRequestApplyConfiguration{}
case v1alpha2.SchemeGroupVersion.WithKind("StructuredResourceHandle"):
return &resourcev1alpha2.StructuredResourceHandleApplyConfiguration{}
case v1alpha2.SchemeGroupVersion.WithKind("VendorParameters"):
return &resourcev1alpha2.VendorParametersApplyConfiguration{}
// Group=scheduling.k8s.io, Version=v1
case schedulingv1.SchemeGroupVersion.WithKind("PriorityClass"):

View File

@@ -362,14 +362,20 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource
return &genericInformer{resource: resource.GroupResource(), informer: f.Rbac().V1beta1().RoleBindings().Informer()}, nil
// Group=resource.k8s.io, Version=v1alpha2
case v1alpha2.SchemeGroupVersion.WithResource("noderesourceslices"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Resource().V1alpha2().NodeResourceSlices().Informer()}, nil
case v1alpha2.SchemeGroupVersion.WithResource("podschedulingcontexts"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Resource().V1alpha2().PodSchedulingContexts().Informer()}, nil
case v1alpha2.SchemeGroupVersion.WithResource("resourceclaims"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Resource().V1alpha2().ResourceClaims().Informer()}, nil
case v1alpha2.SchemeGroupVersion.WithResource("resourceclaimparameters"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Resource().V1alpha2().ResourceClaimParameters().Informer()}, nil
case v1alpha2.SchemeGroupVersion.WithResource("resourceclaimtemplates"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Resource().V1alpha2().ResourceClaimTemplates().Informer()}, nil
case v1alpha2.SchemeGroupVersion.WithResource("resourceclasses"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Resource().V1alpha2().ResourceClasses().Informer()}, nil
case v1alpha2.SchemeGroupVersion.WithResource("resourceclassparameters"):
return &genericInformer{resource: resource.GroupResource(), informer: f.Resource().V1alpha2().ResourceClassParameters().Informer()}, nil
// Group=scheduling.k8s.io, Version=v1
case schedulingv1.SchemeGroupVersion.WithResource("priorityclasses"):

View File

@@ -24,14 +24,20 @@ import (
// Interface provides access to all the informers in this group version.
type Interface interface {
// NodeResourceSlices returns a NodeResourceSliceInformer.
NodeResourceSlices() NodeResourceSliceInformer
// PodSchedulingContexts returns a PodSchedulingContextInformer.
PodSchedulingContexts() PodSchedulingContextInformer
// ResourceClaims returns a ResourceClaimInformer.
ResourceClaims() ResourceClaimInformer
// ResourceClaimParameters returns a ResourceClaimParametersInformer.
ResourceClaimParameters() ResourceClaimParametersInformer
// ResourceClaimTemplates returns a ResourceClaimTemplateInformer.
ResourceClaimTemplates() ResourceClaimTemplateInformer
// ResourceClasses returns a ResourceClassInformer.
ResourceClasses() ResourceClassInformer
// ResourceClassParameters returns a ResourceClassParametersInformer.
ResourceClassParameters() ResourceClassParametersInformer
}
type version struct {
@@ -45,6 +51,11 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList
return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions}
}
// NodeResourceSlices returns a NodeResourceSliceInformer.
func (v *version) NodeResourceSlices() NodeResourceSliceInformer {
return &nodeResourceSliceInformer{factory: v.factory, tweakListOptions: v.tweakListOptions}
}
// PodSchedulingContexts returns a PodSchedulingContextInformer.
func (v *version) PodSchedulingContexts() PodSchedulingContextInformer {
return &podSchedulingContextInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
@@ -55,6 +66,11 @@ func (v *version) ResourceClaims() ResourceClaimInformer {
return &resourceClaimInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
}
// ResourceClaimParameters returns a ResourceClaimParametersInformer.
func (v *version) ResourceClaimParameters() ResourceClaimParametersInformer {
return &resourceClaimParametersInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
}
// ResourceClaimTemplates returns a ResourceClaimTemplateInformer.
func (v *version) ResourceClaimTemplates() ResourceClaimTemplateInformer {
return &resourceClaimTemplateInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
@@ -64,3 +80,8 @@ func (v *version) ResourceClaimTemplates() ResourceClaimTemplateInformer {
func (v *version) ResourceClasses() ResourceClassInformer {
return &resourceClassInformer{factory: v.factory, tweakListOptions: v.tweakListOptions}
}
// ResourceClassParameters returns a ResourceClassParametersInformer.
func (v *version) ResourceClassParameters() ResourceClassParametersInformer {
return &resourceClassParametersInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
}

View File

@@ -0,0 +1,89 @@
/*
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 informer-gen. DO NOT EDIT.
package v1alpha2
import (
"context"
time "time"
resourcev1alpha2 "k8s.io/api/resource/v1alpha2"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
watch "k8s.io/apimachinery/pkg/watch"
internalinterfaces "k8s.io/client-go/informers/internalinterfaces"
kubernetes "k8s.io/client-go/kubernetes"
v1alpha2 "k8s.io/client-go/listers/resource/v1alpha2"
cache "k8s.io/client-go/tools/cache"
)
// NodeResourceSliceInformer provides access to a shared informer and lister for
// NodeResourceSlices.
type NodeResourceSliceInformer interface {
Informer() cache.SharedIndexInformer
Lister() v1alpha2.NodeResourceSliceLister
}
type nodeResourceSliceInformer struct {
factory internalinterfaces.SharedInformerFactory
tweakListOptions internalinterfaces.TweakListOptionsFunc
}
// NewNodeResourceSliceInformer constructs a new informer for NodeResourceSlice type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewNodeResourceSliceInformer(client kubernetes.Interface, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
return NewFilteredNodeResourceSliceInformer(client, resyncPeriod, indexers, nil)
}
// NewFilteredNodeResourceSliceInformer constructs a new informer for NodeResourceSlice type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewFilteredNodeResourceSliceInformer(client kubernetes.Interface, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
return cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.ResourceV1alpha2().NodeResourceSlices().List(context.TODO(), options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.ResourceV1alpha2().NodeResourceSlices().Watch(context.TODO(), options)
},
},
&resourcev1alpha2.NodeResourceSlice{},
resyncPeriod,
indexers,
)
}
func (f *nodeResourceSliceInformer) defaultInformer(client kubernetes.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewFilteredNodeResourceSliceInformer(client, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
}
func (f *nodeResourceSliceInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&resourcev1alpha2.NodeResourceSlice{}, f.defaultInformer)
}
func (f *nodeResourceSliceInformer) Lister() v1alpha2.NodeResourceSliceLister {
return v1alpha2.NewNodeResourceSliceLister(f.Informer().GetIndexer())
}

View File

@@ -0,0 +1,90 @@
/*
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 informer-gen. DO NOT EDIT.
package v1alpha2
import (
"context"
time "time"
resourcev1alpha2 "k8s.io/api/resource/v1alpha2"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
watch "k8s.io/apimachinery/pkg/watch"
internalinterfaces "k8s.io/client-go/informers/internalinterfaces"
kubernetes "k8s.io/client-go/kubernetes"
v1alpha2 "k8s.io/client-go/listers/resource/v1alpha2"
cache "k8s.io/client-go/tools/cache"
)
// ResourceClaimParametersInformer provides access to a shared informer and lister for
// ResourceClaimParameters.
type ResourceClaimParametersInformer interface {
Informer() cache.SharedIndexInformer
Lister() v1alpha2.ResourceClaimParametersLister
}
type resourceClaimParametersInformer struct {
factory internalinterfaces.SharedInformerFactory
tweakListOptions internalinterfaces.TweakListOptionsFunc
namespace string
}
// NewResourceClaimParametersInformer constructs a new informer for ResourceClaimParameters type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewResourceClaimParametersInformer(client kubernetes.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
return NewFilteredResourceClaimParametersInformer(client, namespace, resyncPeriod, indexers, nil)
}
// NewFilteredResourceClaimParametersInformer constructs a new informer for ResourceClaimParameters type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewFilteredResourceClaimParametersInformer(client kubernetes.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
return cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.ResourceV1alpha2().ResourceClaimParameters(namespace).List(context.TODO(), options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.ResourceV1alpha2().ResourceClaimParameters(namespace).Watch(context.TODO(), options)
},
},
&resourcev1alpha2.ResourceClaimParameters{},
resyncPeriod,
indexers,
)
}
func (f *resourceClaimParametersInformer) defaultInformer(client kubernetes.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewFilteredResourceClaimParametersInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
}
func (f *resourceClaimParametersInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&resourcev1alpha2.ResourceClaimParameters{}, f.defaultInformer)
}
func (f *resourceClaimParametersInformer) Lister() v1alpha2.ResourceClaimParametersLister {
return v1alpha2.NewResourceClaimParametersLister(f.Informer().GetIndexer())
}

View File

@@ -0,0 +1,90 @@
/*
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 informer-gen. DO NOT EDIT.
package v1alpha2
import (
"context"
time "time"
resourcev1alpha2 "k8s.io/api/resource/v1alpha2"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
runtime "k8s.io/apimachinery/pkg/runtime"
watch "k8s.io/apimachinery/pkg/watch"
internalinterfaces "k8s.io/client-go/informers/internalinterfaces"
kubernetes "k8s.io/client-go/kubernetes"
v1alpha2 "k8s.io/client-go/listers/resource/v1alpha2"
cache "k8s.io/client-go/tools/cache"
)
// ResourceClassParametersInformer provides access to a shared informer and lister for
// ResourceClassParameters.
type ResourceClassParametersInformer interface {
Informer() cache.SharedIndexInformer
Lister() v1alpha2.ResourceClassParametersLister
}
type resourceClassParametersInformer struct {
factory internalinterfaces.SharedInformerFactory
tweakListOptions internalinterfaces.TweakListOptionsFunc
namespace string
}
// NewResourceClassParametersInformer constructs a new informer for ResourceClassParameters type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewResourceClassParametersInformer(client kubernetes.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
return NewFilteredResourceClassParametersInformer(client, namespace, resyncPeriod, indexers, nil)
}
// NewFilteredResourceClassParametersInformer constructs a new informer for ResourceClassParameters type.
// Always prefer using an informer factory to get a shared informer instead of getting an independent
// one. This reduces memory footprint and number of connections to the server.
func NewFilteredResourceClassParametersInformer(client kubernetes.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
return cache.NewSharedIndexInformer(
&cache.ListWatch{
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.ResourceV1alpha2().ResourceClassParameters(namespace).List(context.TODO(), options)
},
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
if tweakListOptions != nil {
tweakListOptions(&options)
}
return client.ResourceV1alpha2().ResourceClassParameters(namespace).Watch(context.TODO(), options)
},
},
&resourcev1alpha2.ResourceClassParameters{},
resyncPeriod,
indexers,
)
}
func (f *resourceClassParametersInformer) defaultInformer(client kubernetes.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
return NewFilteredResourceClassParametersInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
}
func (f *resourceClassParametersInformer) Informer() cache.SharedIndexInformer {
return f.factory.InformerFor(&resourcev1alpha2.ResourceClassParameters{}, f.defaultInformer)
}
func (f *resourceClassParametersInformer) Lister() v1alpha2.ResourceClassParametersLister {
return v1alpha2.NewResourceClassParametersLister(f.Informer().GetIndexer())
}

View File

@@ -0,0 +1,145 @@
/*
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 client-gen. DO NOT EDIT.
package fake
import (
"context"
json "encoding/json"
"fmt"
v1alpha2 "k8s.io/api/resource/v1alpha2"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
labels "k8s.io/apimachinery/pkg/labels"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
resourcev1alpha2 "k8s.io/client-go/applyconfigurations/resource/v1alpha2"
testing "k8s.io/client-go/testing"
)
// FakeNodeResourceSlices implements NodeResourceSliceInterface
type FakeNodeResourceSlices struct {
Fake *FakeResourceV1alpha2
}
var noderesourceslicesResource = v1alpha2.SchemeGroupVersion.WithResource("noderesourceslices")
var noderesourceslicesKind = v1alpha2.SchemeGroupVersion.WithKind("NodeResourceSlice")
// Get takes name of the nodeResourceSlice, and returns the corresponding nodeResourceSlice object, and an error if there is any.
func (c *FakeNodeResourceSlices) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha2.NodeResourceSlice, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootGetAction(noderesourceslicesResource, name), &v1alpha2.NodeResourceSlice{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha2.NodeResourceSlice), err
}
// List takes label and field selectors, and returns the list of NodeResourceSlices that match those selectors.
func (c *FakeNodeResourceSlices) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.NodeResourceSliceList, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootListAction(noderesourceslicesResource, noderesourceslicesKind, opts), &v1alpha2.NodeResourceSliceList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &v1alpha2.NodeResourceSliceList{ListMeta: obj.(*v1alpha2.NodeResourceSliceList).ListMeta}
for _, item := range obj.(*v1alpha2.NodeResourceSliceList).Items {
if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item)
}
}
return list, err
}
// Watch returns a watch.Interface that watches the requested nodeResourceSlices.
func (c *FakeNodeResourceSlices) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewRootWatchAction(noderesourceslicesResource, opts))
}
// Create takes the representation of a nodeResourceSlice and creates it. Returns the server's representation of the nodeResourceSlice, and an error, if there is any.
func (c *FakeNodeResourceSlices) Create(ctx context.Context, nodeResourceSlice *v1alpha2.NodeResourceSlice, opts v1.CreateOptions) (result *v1alpha2.NodeResourceSlice, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootCreateAction(noderesourceslicesResource, nodeResourceSlice), &v1alpha2.NodeResourceSlice{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha2.NodeResourceSlice), err
}
// Update takes the representation of a nodeResourceSlice and updates it. Returns the server's representation of the nodeResourceSlice, and an error, if there is any.
func (c *FakeNodeResourceSlices) Update(ctx context.Context, nodeResourceSlice *v1alpha2.NodeResourceSlice, opts v1.UpdateOptions) (result *v1alpha2.NodeResourceSlice, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootUpdateAction(noderesourceslicesResource, nodeResourceSlice), &v1alpha2.NodeResourceSlice{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha2.NodeResourceSlice), err
}
// Delete takes name of the nodeResourceSlice and deletes it. Returns an error if one occurs.
func (c *FakeNodeResourceSlices) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewRootDeleteActionWithOptions(noderesourceslicesResource, name, opts), &v1alpha2.NodeResourceSlice{})
return err
}
// DeleteCollection deletes a collection of objects.
func (c *FakeNodeResourceSlices) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
action := testing.NewRootDeleteCollectionAction(noderesourceslicesResource, listOpts)
_, err := c.Fake.Invokes(action, &v1alpha2.NodeResourceSliceList{})
return err
}
// Patch applies the patch and returns the patched nodeResourceSlice.
func (c *FakeNodeResourceSlices) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha2.NodeResourceSlice, err error) {
obj, err := c.Fake.
Invokes(testing.NewRootPatchSubresourceAction(noderesourceslicesResource, name, pt, data, subresources...), &v1alpha2.NodeResourceSlice{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha2.NodeResourceSlice), err
}
// Apply takes the given apply declarative configuration, applies it and returns the applied nodeResourceSlice.
func (c *FakeNodeResourceSlices) Apply(ctx context.Context, nodeResourceSlice *resourcev1alpha2.NodeResourceSliceApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha2.NodeResourceSlice, err error) {
if nodeResourceSlice == nil {
return nil, fmt.Errorf("nodeResourceSlice provided to Apply must not be nil")
}
data, err := json.Marshal(nodeResourceSlice)
if err != nil {
return nil, err
}
name := nodeResourceSlice.Name
if name == nil {
return nil, fmt.Errorf("nodeResourceSlice.Name must be provided to Apply")
}
obj, err := c.Fake.
Invokes(testing.NewRootPatchSubresourceAction(noderesourceslicesResource, *name, types.ApplyPatchType, data), &v1alpha2.NodeResourceSlice{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha2.NodeResourceSlice), err
}

View File

@@ -28,6 +28,10 @@ type FakeResourceV1alpha2 struct {
*testing.Fake
}
func (c *FakeResourceV1alpha2) NodeResourceSlices() v1alpha2.NodeResourceSliceInterface {
return &FakeNodeResourceSlices{c}
}
func (c *FakeResourceV1alpha2) PodSchedulingContexts(namespace string) v1alpha2.PodSchedulingContextInterface {
return &FakePodSchedulingContexts{c, namespace}
}
@@ -36,6 +40,10 @@ func (c *FakeResourceV1alpha2) ResourceClaims(namespace string) v1alpha2.Resourc
return &FakeResourceClaims{c, namespace}
}
func (c *FakeResourceV1alpha2) ResourceClaimParameters(namespace string) v1alpha2.ResourceClaimParametersInterface {
return &FakeResourceClaimParameters{c, namespace}
}
func (c *FakeResourceV1alpha2) ResourceClaimTemplates(namespace string) v1alpha2.ResourceClaimTemplateInterface {
return &FakeResourceClaimTemplates{c, namespace}
}
@@ -44,6 +52,10 @@ func (c *FakeResourceV1alpha2) ResourceClasses() v1alpha2.ResourceClassInterface
return &FakeResourceClasses{c}
}
func (c *FakeResourceV1alpha2) ResourceClassParameters(namespace string) v1alpha2.ResourceClassParametersInterface {
return &FakeResourceClassParameters{c, namespace}
}
// RESTClient returns a RESTClient that is used to communicate
// with API server by this client implementation.
func (c *FakeResourceV1alpha2) RESTClient() rest.Interface {

View File

@@ -0,0 +1,154 @@
/*
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 client-gen. DO NOT EDIT.
package fake
import (
"context"
json "encoding/json"
"fmt"
v1alpha2 "k8s.io/api/resource/v1alpha2"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
labels "k8s.io/apimachinery/pkg/labels"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
resourcev1alpha2 "k8s.io/client-go/applyconfigurations/resource/v1alpha2"
testing "k8s.io/client-go/testing"
)
// FakeResourceClaimParameters implements ResourceClaimParametersInterface
type FakeResourceClaimParameters struct {
Fake *FakeResourceV1alpha2
ns string
}
var resourceclaimparametersResource = v1alpha2.SchemeGroupVersion.WithResource("resourceclaimparameters")
var resourceclaimparametersKind = v1alpha2.SchemeGroupVersion.WithKind("ResourceClaimParameters")
// Get takes name of the resourceClaimParameters, and returns the corresponding resourceClaimParameters object, and an error if there is any.
func (c *FakeResourceClaimParameters) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha2.ResourceClaimParameters, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(resourceclaimparametersResource, c.ns, name), &v1alpha2.ResourceClaimParameters{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha2.ResourceClaimParameters), err
}
// List takes label and field selectors, and returns the list of ResourceClaimParameters that match those selectors.
func (c *FakeResourceClaimParameters) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.ResourceClaimParametersList, err error) {
obj, err := c.Fake.
Invokes(testing.NewListAction(resourceclaimparametersResource, resourceclaimparametersKind, c.ns, opts), &v1alpha2.ResourceClaimParametersList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &v1alpha2.ResourceClaimParametersList{ListMeta: obj.(*v1alpha2.ResourceClaimParametersList).ListMeta}
for _, item := range obj.(*v1alpha2.ResourceClaimParametersList).Items {
if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item)
}
}
return list, err
}
// Watch returns a watch.Interface that watches the requested resourceClaimParameters.
func (c *FakeResourceClaimParameters) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewWatchAction(resourceclaimparametersResource, c.ns, opts))
}
// Create takes the representation of a resourceClaimParameters and creates it. Returns the server's representation of the resourceClaimParameters, and an error, if there is any.
func (c *FakeResourceClaimParameters) Create(ctx context.Context, resourceClaimParameters *v1alpha2.ResourceClaimParameters, opts v1.CreateOptions) (result *v1alpha2.ResourceClaimParameters, err error) {
obj, err := c.Fake.
Invokes(testing.NewCreateAction(resourceclaimparametersResource, c.ns, resourceClaimParameters), &v1alpha2.ResourceClaimParameters{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha2.ResourceClaimParameters), err
}
// Update takes the representation of a resourceClaimParameters and updates it. Returns the server's representation of the resourceClaimParameters, and an error, if there is any.
func (c *FakeResourceClaimParameters) Update(ctx context.Context, resourceClaimParameters *v1alpha2.ResourceClaimParameters, opts v1.UpdateOptions) (result *v1alpha2.ResourceClaimParameters, err error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateAction(resourceclaimparametersResource, c.ns, resourceClaimParameters), &v1alpha2.ResourceClaimParameters{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha2.ResourceClaimParameters), err
}
// Delete takes name of the resourceClaimParameters and deletes it. Returns an error if one occurs.
func (c *FakeResourceClaimParameters) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewDeleteActionWithOptions(resourceclaimparametersResource, c.ns, name, opts), &v1alpha2.ResourceClaimParameters{})
return err
}
// DeleteCollection deletes a collection of objects.
func (c *FakeResourceClaimParameters) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
action := testing.NewDeleteCollectionAction(resourceclaimparametersResource, c.ns, listOpts)
_, err := c.Fake.Invokes(action, &v1alpha2.ResourceClaimParametersList{})
return err
}
// Patch applies the patch and returns the patched resourceClaimParameters.
func (c *FakeResourceClaimParameters) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha2.ResourceClaimParameters, err error) {
obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceAction(resourceclaimparametersResource, c.ns, name, pt, data, subresources...), &v1alpha2.ResourceClaimParameters{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha2.ResourceClaimParameters), err
}
// Apply takes the given apply declarative configuration, applies it and returns the applied resourceClaimParameters.
func (c *FakeResourceClaimParameters) Apply(ctx context.Context, resourceClaimParameters *resourcev1alpha2.ResourceClaimParametersApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha2.ResourceClaimParameters, err error) {
if resourceClaimParameters == nil {
return nil, fmt.Errorf("resourceClaimParameters provided to Apply must not be nil")
}
data, err := json.Marshal(resourceClaimParameters)
if err != nil {
return nil, err
}
name := resourceClaimParameters.Name
if name == nil {
return nil, fmt.Errorf("resourceClaimParameters.Name must be provided to Apply")
}
obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceAction(resourceclaimparametersResource, c.ns, *name, types.ApplyPatchType, data), &v1alpha2.ResourceClaimParameters{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha2.ResourceClaimParameters), err
}

View File

@@ -0,0 +1,154 @@
/*
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 client-gen. DO NOT EDIT.
package fake
import (
"context"
json "encoding/json"
"fmt"
v1alpha2 "k8s.io/api/resource/v1alpha2"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
labels "k8s.io/apimachinery/pkg/labels"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
resourcev1alpha2 "k8s.io/client-go/applyconfigurations/resource/v1alpha2"
testing "k8s.io/client-go/testing"
)
// FakeResourceClassParameters implements ResourceClassParametersInterface
type FakeResourceClassParameters struct {
Fake *FakeResourceV1alpha2
ns string
}
var resourceclassparametersResource = v1alpha2.SchemeGroupVersion.WithResource("resourceclassparameters")
var resourceclassparametersKind = v1alpha2.SchemeGroupVersion.WithKind("ResourceClassParameters")
// Get takes name of the resourceClassParameters, and returns the corresponding resourceClassParameters object, and an error if there is any.
func (c *FakeResourceClassParameters) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha2.ResourceClassParameters, err error) {
obj, err := c.Fake.
Invokes(testing.NewGetAction(resourceclassparametersResource, c.ns, name), &v1alpha2.ResourceClassParameters{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha2.ResourceClassParameters), err
}
// List takes label and field selectors, and returns the list of ResourceClassParameters that match those selectors.
func (c *FakeResourceClassParameters) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.ResourceClassParametersList, err error) {
obj, err := c.Fake.
Invokes(testing.NewListAction(resourceclassparametersResource, resourceclassparametersKind, c.ns, opts), &v1alpha2.ResourceClassParametersList{})
if obj == nil {
return nil, err
}
label, _, _ := testing.ExtractFromListOptions(opts)
if label == nil {
label = labels.Everything()
}
list := &v1alpha2.ResourceClassParametersList{ListMeta: obj.(*v1alpha2.ResourceClassParametersList).ListMeta}
for _, item := range obj.(*v1alpha2.ResourceClassParametersList).Items {
if label.Matches(labels.Set(item.Labels)) {
list.Items = append(list.Items, item)
}
}
return list, err
}
// Watch returns a watch.Interface that watches the requested resourceClassParameters.
func (c *FakeResourceClassParameters) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
return c.Fake.
InvokesWatch(testing.NewWatchAction(resourceclassparametersResource, c.ns, opts))
}
// Create takes the representation of a resourceClassParameters and creates it. Returns the server's representation of the resourceClassParameters, and an error, if there is any.
func (c *FakeResourceClassParameters) Create(ctx context.Context, resourceClassParameters *v1alpha2.ResourceClassParameters, opts v1.CreateOptions) (result *v1alpha2.ResourceClassParameters, err error) {
obj, err := c.Fake.
Invokes(testing.NewCreateAction(resourceclassparametersResource, c.ns, resourceClassParameters), &v1alpha2.ResourceClassParameters{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha2.ResourceClassParameters), err
}
// Update takes the representation of a resourceClassParameters and updates it. Returns the server's representation of the resourceClassParameters, and an error, if there is any.
func (c *FakeResourceClassParameters) Update(ctx context.Context, resourceClassParameters *v1alpha2.ResourceClassParameters, opts v1.UpdateOptions) (result *v1alpha2.ResourceClassParameters, err error) {
obj, err := c.Fake.
Invokes(testing.NewUpdateAction(resourceclassparametersResource, c.ns, resourceClassParameters), &v1alpha2.ResourceClassParameters{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha2.ResourceClassParameters), err
}
// Delete takes name of the resourceClassParameters and deletes it. Returns an error if one occurs.
func (c *FakeResourceClassParameters) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
_, err := c.Fake.
Invokes(testing.NewDeleteActionWithOptions(resourceclassparametersResource, c.ns, name, opts), &v1alpha2.ResourceClassParameters{})
return err
}
// DeleteCollection deletes a collection of objects.
func (c *FakeResourceClassParameters) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
action := testing.NewDeleteCollectionAction(resourceclassparametersResource, c.ns, listOpts)
_, err := c.Fake.Invokes(action, &v1alpha2.ResourceClassParametersList{})
return err
}
// Patch applies the patch and returns the patched resourceClassParameters.
func (c *FakeResourceClassParameters) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha2.ResourceClassParameters, err error) {
obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceAction(resourceclassparametersResource, c.ns, name, pt, data, subresources...), &v1alpha2.ResourceClassParameters{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha2.ResourceClassParameters), err
}
// Apply takes the given apply declarative configuration, applies it and returns the applied resourceClassParameters.
func (c *FakeResourceClassParameters) Apply(ctx context.Context, resourceClassParameters *resourcev1alpha2.ResourceClassParametersApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha2.ResourceClassParameters, err error) {
if resourceClassParameters == nil {
return nil, fmt.Errorf("resourceClassParameters provided to Apply must not be nil")
}
data, err := json.Marshal(resourceClassParameters)
if err != nil {
return nil, err
}
name := resourceClassParameters.Name
if name == nil {
return nil, fmt.Errorf("resourceClassParameters.Name must be provided to Apply")
}
obj, err := c.Fake.
Invokes(testing.NewPatchSubresourceAction(resourceclassparametersResource, c.ns, *name, types.ApplyPatchType, data), &v1alpha2.ResourceClassParameters{})
if obj == nil {
return nil, err
}
return obj.(*v1alpha2.ResourceClassParameters), err
}

View File

@@ -18,10 +18,16 @@ limitations under the License.
package v1alpha2
type NodeResourceSliceExpansion interface{}
type PodSchedulingContextExpansion interface{}
type ResourceClaimExpansion interface{}
type ResourceClaimParametersExpansion interface{}
type ResourceClaimTemplateExpansion interface{}
type ResourceClassExpansion interface{}
type ResourceClassParametersExpansion interface{}

View File

@@ -0,0 +1,197 @@
/*
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 client-gen. DO NOT EDIT.
package v1alpha2
import (
"context"
json "encoding/json"
"fmt"
"time"
v1alpha2 "k8s.io/api/resource/v1alpha2"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
resourcev1alpha2 "k8s.io/client-go/applyconfigurations/resource/v1alpha2"
scheme "k8s.io/client-go/kubernetes/scheme"
rest "k8s.io/client-go/rest"
)
// NodeResourceSlicesGetter has a method to return a NodeResourceSliceInterface.
// A group's client should implement this interface.
type NodeResourceSlicesGetter interface {
NodeResourceSlices() NodeResourceSliceInterface
}
// NodeResourceSliceInterface has methods to work with NodeResourceSlice resources.
type NodeResourceSliceInterface interface {
Create(ctx context.Context, nodeResourceSlice *v1alpha2.NodeResourceSlice, opts v1.CreateOptions) (*v1alpha2.NodeResourceSlice, error)
Update(ctx context.Context, nodeResourceSlice *v1alpha2.NodeResourceSlice, opts v1.UpdateOptions) (*v1alpha2.NodeResourceSlice, error)
Delete(ctx context.Context, name string, opts v1.DeleteOptions) error
DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error
Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha2.NodeResourceSlice, error)
List(ctx context.Context, opts v1.ListOptions) (*v1alpha2.NodeResourceSliceList, error)
Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error)
Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha2.NodeResourceSlice, err error)
Apply(ctx context.Context, nodeResourceSlice *resourcev1alpha2.NodeResourceSliceApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha2.NodeResourceSlice, err error)
NodeResourceSliceExpansion
}
// nodeResourceSlices implements NodeResourceSliceInterface
type nodeResourceSlices struct {
client rest.Interface
}
// newNodeResourceSlices returns a NodeResourceSlices
func newNodeResourceSlices(c *ResourceV1alpha2Client) *nodeResourceSlices {
return &nodeResourceSlices{
client: c.RESTClient(),
}
}
// Get takes name of the nodeResourceSlice, and returns the corresponding nodeResourceSlice object, and an error if there is any.
func (c *nodeResourceSlices) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha2.NodeResourceSlice, err error) {
result = &v1alpha2.NodeResourceSlice{}
err = c.client.Get().
Resource("noderesourceslices").
Name(name).
VersionedParams(&options, scheme.ParameterCodec).
Do(ctx).
Into(result)
return
}
// List takes label and field selectors, and returns the list of NodeResourceSlices that match those selectors.
func (c *nodeResourceSlices) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.NodeResourceSliceList, err error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
result = &v1alpha2.NodeResourceSliceList{}
err = c.client.Get().
Resource("noderesourceslices").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Do(ctx).
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested nodeResourceSlices.
func (c *nodeResourceSlices) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
opts.Watch = true
return c.client.Get().
Resource("noderesourceslices").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Watch(ctx)
}
// Create takes the representation of a nodeResourceSlice and creates it. Returns the server's representation of the nodeResourceSlice, and an error, if there is any.
func (c *nodeResourceSlices) Create(ctx context.Context, nodeResourceSlice *v1alpha2.NodeResourceSlice, opts v1.CreateOptions) (result *v1alpha2.NodeResourceSlice, err error) {
result = &v1alpha2.NodeResourceSlice{}
err = c.client.Post().
Resource("noderesourceslices").
VersionedParams(&opts, scheme.ParameterCodec).
Body(nodeResourceSlice).
Do(ctx).
Into(result)
return
}
// Update takes the representation of a nodeResourceSlice and updates it. Returns the server's representation of the nodeResourceSlice, and an error, if there is any.
func (c *nodeResourceSlices) Update(ctx context.Context, nodeResourceSlice *v1alpha2.NodeResourceSlice, opts v1.UpdateOptions) (result *v1alpha2.NodeResourceSlice, err error) {
result = &v1alpha2.NodeResourceSlice{}
err = c.client.Put().
Resource("noderesourceslices").
Name(nodeResourceSlice.Name).
VersionedParams(&opts, scheme.ParameterCodec).
Body(nodeResourceSlice).
Do(ctx).
Into(result)
return
}
// Delete takes name of the nodeResourceSlice and deletes it. Returns an error if one occurs.
func (c *nodeResourceSlices) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
return c.client.Delete().
Resource("noderesourceslices").
Name(name).
Body(&opts).
Do(ctx).
Error()
}
// DeleteCollection deletes a collection of objects.
func (c *nodeResourceSlices) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
var timeout time.Duration
if listOpts.TimeoutSeconds != nil {
timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second
}
return c.client.Delete().
Resource("noderesourceslices").
VersionedParams(&listOpts, scheme.ParameterCodec).
Timeout(timeout).
Body(&opts).
Do(ctx).
Error()
}
// Patch applies the patch and returns the patched nodeResourceSlice.
func (c *nodeResourceSlices) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha2.NodeResourceSlice, err error) {
result = &v1alpha2.NodeResourceSlice{}
err = c.client.Patch(pt).
Resource("noderesourceslices").
Name(name).
SubResource(subresources...).
VersionedParams(&opts, scheme.ParameterCodec).
Body(data).
Do(ctx).
Into(result)
return
}
// Apply takes the given apply declarative configuration, applies it and returns the applied nodeResourceSlice.
func (c *nodeResourceSlices) Apply(ctx context.Context, nodeResourceSlice *resourcev1alpha2.NodeResourceSliceApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha2.NodeResourceSlice, err error) {
if nodeResourceSlice == nil {
return nil, fmt.Errorf("nodeResourceSlice provided to Apply must not be nil")
}
patchOpts := opts.ToPatchOptions()
data, err := json.Marshal(nodeResourceSlice)
if err != nil {
return nil, err
}
name := nodeResourceSlice.Name
if name == nil {
return nil, fmt.Errorf("nodeResourceSlice.Name must be provided to Apply")
}
result = &v1alpha2.NodeResourceSlice{}
err = c.client.Patch(types.ApplyPatchType).
Resource("noderesourceslices").
Name(*name).
VersionedParams(&patchOpts, scheme.ParameterCodec).
Body(data).
Do(ctx).
Into(result)
return
}

View File

@@ -28,10 +28,13 @@ import (
type ResourceV1alpha2Interface interface {
RESTClient() rest.Interface
NodeResourceSlicesGetter
PodSchedulingContextsGetter
ResourceClaimsGetter
ResourceClaimParametersGetter
ResourceClaimTemplatesGetter
ResourceClassesGetter
ResourceClassParametersGetter
}
// ResourceV1alpha2Client is used to interact with features provided by the resource.k8s.io group.
@@ -39,6 +42,10 @@ type ResourceV1alpha2Client struct {
restClient rest.Interface
}
func (c *ResourceV1alpha2Client) NodeResourceSlices() NodeResourceSliceInterface {
return newNodeResourceSlices(c)
}
func (c *ResourceV1alpha2Client) PodSchedulingContexts(namespace string) PodSchedulingContextInterface {
return newPodSchedulingContexts(c, namespace)
}
@@ -47,6 +54,10 @@ func (c *ResourceV1alpha2Client) ResourceClaims(namespace string) ResourceClaimI
return newResourceClaims(c, namespace)
}
func (c *ResourceV1alpha2Client) ResourceClaimParameters(namespace string) ResourceClaimParametersInterface {
return newResourceClaimParameters(c, namespace)
}
func (c *ResourceV1alpha2Client) ResourceClaimTemplates(namespace string) ResourceClaimTemplateInterface {
return newResourceClaimTemplates(c, namespace)
}
@@ -55,6 +66,10 @@ func (c *ResourceV1alpha2Client) ResourceClasses() ResourceClassInterface {
return newResourceClasses(c)
}
func (c *ResourceV1alpha2Client) ResourceClassParameters(namespace string) ResourceClassParametersInterface {
return newResourceClassParameters(c, namespace)
}
// NewForConfig creates a new ResourceV1alpha2Client for the given config.
// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient),
// where httpClient was generated with rest.HTTPClientFor(c).

View File

@@ -0,0 +1,208 @@
/*
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 client-gen. DO NOT EDIT.
package v1alpha2
import (
"context"
json "encoding/json"
"fmt"
"time"
v1alpha2 "k8s.io/api/resource/v1alpha2"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
resourcev1alpha2 "k8s.io/client-go/applyconfigurations/resource/v1alpha2"
scheme "k8s.io/client-go/kubernetes/scheme"
rest "k8s.io/client-go/rest"
)
// ResourceClaimParametersGetter has a method to return a ResourceClaimParametersInterface.
// A group's client should implement this interface.
type ResourceClaimParametersGetter interface {
ResourceClaimParameters(namespace string) ResourceClaimParametersInterface
}
// ResourceClaimParametersInterface has methods to work with ResourceClaimParameters resources.
type ResourceClaimParametersInterface interface {
Create(ctx context.Context, resourceClaimParameters *v1alpha2.ResourceClaimParameters, opts v1.CreateOptions) (*v1alpha2.ResourceClaimParameters, error)
Update(ctx context.Context, resourceClaimParameters *v1alpha2.ResourceClaimParameters, opts v1.UpdateOptions) (*v1alpha2.ResourceClaimParameters, error)
Delete(ctx context.Context, name string, opts v1.DeleteOptions) error
DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error
Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha2.ResourceClaimParameters, error)
List(ctx context.Context, opts v1.ListOptions) (*v1alpha2.ResourceClaimParametersList, error)
Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error)
Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha2.ResourceClaimParameters, err error)
Apply(ctx context.Context, resourceClaimParameters *resourcev1alpha2.ResourceClaimParametersApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha2.ResourceClaimParameters, err error)
ResourceClaimParametersExpansion
}
// resourceClaimParameters implements ResourceClaimParametersInterface
type resourceClaimParameters struct {
client rest.Interface
ns string
}
// newResourceClaimParameters returns a ResourceClaimParameters
func newResourceClaimParameters(c *ResourceV1alpha2Client, namespace string) *resourceClaimParameters {
return &resourceClaimParameters{
client: c.RESTClient(),
ns: namespace,
}
}
// Get takes name of the resourceClaimParameters, and returns the corresponding resourceClaimParameters object, and an error if there is any.
func (c *resourceClaimParameters) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha2.ResourceClaimParameters, err error) {
result = &v1alpha2.ResourceClaimParameters{}
err = c.client.Get().
Namespace(c.ns).
Resource("resourceclaimparameters").
Name(name).
VersionedParams(&options, scheme.ParameterCodec).
Do(ctx).
Into(result)
return
}
// List takes label and field selectors, and returns the list of ResourceClaimParameters that match those selectors.
func (c *resourceClaimParameters) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.ResourceClaimParametersList, err error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
result = &v1alpha2.ResourceClaimParametersList{}
err = c.client.Get().
Namespace(c.ns).
Resource("resourceclaimparameters").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Do(ctx).
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested resourceClaimParameters.
func (c *resourceClaimParameters) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
opts.Watch = true
return c.client.Get().
Namespace(c.ns).
Resource("resourceclaimparameters").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Watch(ctx)
}
// Create takes the representation of a resourceClaimParameters and creates it. Returns the server's representation of the resourceClaimParameters, and an error, if there is any.
func (c *resourceClaimParameters) Create(ctx context.Context, resourceClaimParameters *v1alpha2.ResourceClaimParameters, opts v1.CreateOptions) (result *v1alpha2.ResourceClaimParameters, err error) {
result = &v1alpha2.ResourceClaimParameters{}
err = c.client.Post().
Namespace(c.ns).
Resource("resourceclaimparameters").
VersionedParams(&opts, scheme.ParameterCodec).
Body(resourceClaimParameters).
Do(ctx).
Into(result)
return
}
// Update takes the representation of a resourceClaimParameters and updates it. Returns the server's representation of the resourceClaimParameters, and an error, if there is any.
func (c *resourceClaimParameters) Update(ctx context.Context, resourceClaimParameters *v1alpha2.ResourceClaimParameters, opts v1.UpdateOptions) (result *v1alpha2.ResourceClaimParameters, err error) {
result = &v1alpha2.ResourceClaimParameters{}
err = c.client.Put().
Namespace(c.ns).
Resource("resourceclaimparameters").
Name(resourceClaimParameters.Name).
VersionedParams(&opts, scheme.ParameterCodec).
Body(resourceClaimParameters).
Do(ctx).
Into(result)
return
}
// Delete takes name of the resourceClaimParameters and deletes it. Returns an error if one occurs.
func (c *resourceClaimParameters) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
return c.client.Delete().
Namespace(c.ns).
Resource("resourceclaimparameters").
Name(name).
Body(&opts).
Do(ctx).
Error()
}
// DeleteCollection deletes a collection of objects.
func (c *resourceClaimParameters) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
var timeout time.Duration
if listOpts.TimeoutSeconds != nil {
timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second
}
return c.client.Delete().
Namespace(c.ns).
Resource("resourceclaimparameters").
VersionedParams(&listOpts, scheme.ParameterCodec).
Timeout(timeout).
Body(&opts).
Do(ctx).
Error()
}
// Patch applies the patch and returns the patched resourceClaimParameters.
func (c *resourceClaimParameters) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha2.ResourceClaimParameters, err error) {
result = &v1alpha2.ResourceClaimParameters{}
err = c.client.Patch(pt).
Namespace(c.ns).
Resource("resourceclaimparameters").
Name(name).
SubResource(subresources...).
VersionedParams(&opts, scheme.ParameterCodec).
Body(data).
Do(ctx).
Into(result)
return
}
// Apply takes the given apply declarative configuration, applies it and returns the applied resourceClaimParameters.
func (c *resourceClaimParameters) Apply(ctx context.Context, resourceClaimParameters *resourcev1alpha2.ResourceClaimParametersApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha2.ResourceClaimParameters, err error) {
if resourceClaimParameters == nil {
return nil, fmt.Errorf("resourceClaimParameters provided to Apply must not be nil")
}
patchOpts := opts.ToPatchOptions()
data, err := json.Marshal(resourceClaimParameters)
if err != nil {
return nil, err
}
name := resourceClaimParameters.Name
if name == nil {
return nil, fmt.Errorf("resourceClaimParameters.Name must be provided to Apply")
}
result = &v1alpha2.ResourceClaimParameters{}
err = c.client.Patch(types.ApplyPatchType).
Namespace(c.ns).
Resource("resourceclaimparameters").
Name(*name).
VersionedParams(&patchOpts, scheme.ParameterCodec).
Body(data).
Do(ctx).
Into(result)
return
}

View File

@@ -0,0 +1,208 @@
/*
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 client-gen. DO NOT EDIT.
package v1alpha2
import (
"context"
json "encoding/json"
"fmt"
"time"
v1alpha2 "k8s.io/api/resource/v1alpha2"
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
types "k8s.io/apimachinery/pkg/types"
watch "k8s.io/apimachinery/pkg/watch"
resourcev1alpha2 "k8s.io/client-go/applyconfigurations/resource/v1alpha2"
scheme "k8s.io/client-go/kubernetes/scheme"
rest "k8s.io/client-go/rest"
)
// ResourceClassParametersGetter has a method to return a ResourceClassParametersInterface.
// A group's client should implement this interface.
type ResourceClassParametersGetter interface {
ResourceClassParameters(namespace string) ResourceClassParametersInterface
}
// ResourceClassParametersInterface has methods to work with ResourceClassParameters resources.
type ResourceClassParametersInterface interface {
Create(ctx context.Context, resourceClassParameters *v1alpha2.ResourceClassParameters, opts v1.CreateOptions) (*v1alpha2.ResourceClassParameters, error)
Update(ctx context.Context, resourceClassParameters *v1alpha2.ResourceClassParameters, opts v1.UpdateOptions) (*v1alpha2.ResourceClassParameters, error)
Delete(ctx context.Context, name string, opts v1.DeleteOptions) error
DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error
Get(ctx context.Context, name string, opts v1.GetOptions) (*v1alpha2.ResourceClassParameters, error)
List(ctx context.Context, opts v1.ListOptions) (*v1alpha2.ResourceClassParametersList, error)
Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error)
Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha2.ResourceClassParameters, err error)
Apply(ctx context.Context, resourceClassParameters *resourcev1alpha2.ResourceClassParametersApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha2.ResourceClassParameters, err error)
ResourceClassParametersExpansion
}
// resourceClassParameters implements ResourceClassParametersInterface
type resourceClassParameters struct {
client rest.Interface
ns string
}
// newResourceClassParameters returns a ResourceClassParameters
func newResourceClassParameters(c *ResourceV1alpha2Client, namespace string) *resourceClassParameters {
return &resourceClassParameters{
client: c.RESTClient(),
ns: namespace,
}
}
// Get takes name of the resourceClassParameters, and returns the corresponding resourceClassParameters object, and an error if there is any.
func (c *resourceClassParameters) Get(ctx context.Context, name string, options v1.GetOptions) (result *v1alpha2.ResourceClassParameters, err error) {
result = &v1alpha2.ResourceClassParameters{}
err = c.client.Get().
Namespace(c.ns).
Resource("resourceclassparameters").
Name(name).
VersionedParams(&options, scheme.ParameterCodec).
Do(ctx).
Into(result)
return
}
// List takes label and field selectors, and returns the list of ResourceClassParameters that match those selectors.
func (c *resourceClassParameters) List(ctx context.Context, opts v1.ListOptions) (result *v1alpha2.ResourceClassParametersList, err error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
result = &v1alpha2.ResourceClassParametersList{}
err = c.client.Get().
Namespace(c.ns).
Resource("resourceclassparameters").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Do(ctx).
Into(result)
return
}
// Watch returns a watch.Interface that watches the requested resourceClassParameters.
func (c *resourceClassParameters) Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error) {
var timeout time.Duration
if opts.TimeoutSeconds != nil {
timeout = time.Duration(*opts.TimeoutSeconds) * time.Second
}
opts.Watch = true
return c.client.Get().
Namespace(c.ns).
Resource("resourceclassparameters").
VersionedParams(&opts, scheme.ParameterCodec).
Timeout(timeout).
Watch(ctx)
}
// Create takes the representation of a resourceClassParameters and creates it. Returns the server's representation of the resourceClassParameters, and an error, if there is any.
func (c *resourceClassParameters) Create(ctx context.Context, resourceClassParameters *v1alpha2.ResourceClassParameters, opts v1.CreateOptions) (result *v1alpha2.ResourceClassParameters, err error) {
result = &v1alpha2.ResourceClassParameters{}
err = c.client.Post().
Namespace(c.ns).
Resource("resourceclassparameters").
VersionedParams(&opts, scheme.ParameterCodec).
Body(resourceClassParameters).
Do(ctx).
Into(result)
return
}
// Update takes the representation of a resourceClassParameters and updates it. Returns the server's representation of the resourceClassParameters, and an error, if there is any.
func (c *resourceClassParameters) Update(ctx context.Context, resourceClassParameters *v1alpha2.ResourceClassParameters, opts v1.UpdateOptions) (result *v1alpha2.ResourceClassParameters, err error) {
result = &v1alpha2.ResourceClassParameters{}
err = c.client.Put().
Namespace(c.ns).
Resource("resourceclassparameters").
Name(resourceClassParameters.Name).
VersionedParams(&opts, scheme.ParameterCodec).
Body(resourceClassParameters).
Do(ctx).
Into(result)
return
}
// Delete takes name of the resourceClassParameters and deletes it. Returns an error if one occurs.
func (c *resourceClassParameters) Delete(ctx context.Context, name string, opts v1.DeleteOptions) error {
return c.client.Delete().
Namespace(c.ns).
Resource("resourceclassparameters").
Name(name).
Body(&opts).
Do(ctx).
Error()
}
// DeleteCollection deletes a collection of objects.
func (c *resourceClassParameters) DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error {
var timeout time.Duration
if listOpts.TimeoutSeconds != nil {
timeout = time.Duration(*listOpts.TimeoutSeconds) * time.Second
}
return c.client.Delete().
Namespace(c.ns).
Resource("resourceclassparameters").
VersionedParams(&listOpts, scheme.ParameterCodec).
Timeout(timeout).
Body(&opts).
Do(ctx).
Error()
}
// Patch applies the patch and returns the patched resourceClassParameters.
func (c *resourceClassParameters) Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *v1alpha2.ResourceClassParameters, err error) {
result = &v1alpha2.ResourceClassParameters{}
err = c.client.Patch(pt).
Namespace(c.ns).
Resource("resourceclassparameters").
Name(name).
SubResource(subresources...).
VersionedParams(&opts, scheme.ParameterCodec).
Body(data).
Do(ctx).
Into(result)
return
}
// Apply takes the given apply declarative configuration, applies it and returns the applied resourceClassParameters.
func (c *resourceClassParameters) Apply(ctx context.Context, resourceClassParameters *resourcev1alpha2.ResourceClassParametersApplyConfiguration, opts v1.ApplyOptions) (result *v1alpha2.ResourceClassParameters, err error) {
if resourceClassParameters == nil {
return nil, fmt.Errorf("resourceClassParameters provided to Apply must not be nil")
}
patchOpts := opts.ToPatchOptions()
data, err := json.Marshal(resourceClassParameters)
if err != nil {
return nil, err
}
name := resourceClassParameters.Name
if name == nil {
return nil, fmt.Errorf("resourceClassParameters.Name must be provided to Apply")
}
result = &v1alpha2.ResourceClassParameters{}
err = c.client.Patch(types.ApplyPatchType).
Namespace(c.ns).
Resource("resourceclassparameters").
Name(*name).
VersionedParams(&patchOpts, scheme.ParameterCodec).
Body(data).
Do(ctx).
Into(result)
return
}

View File

@@ -18,6 +18,10 @@ limitations under the License.
package v1alpha2
// NodeResourceSliceListerExpansion allows custom methods to be added to
// NodeResourceSliceLister.
type NodeResourceSliceListerExpansion interface{}
// PodSchedulingContextListerExpansion allows custom methods to be added to
// PodSchedulingContextLister.
type PodSchedulingContextListerExpansion interface{}
@@ -34,6 +38,14 @@ type ResourceClaimListerExpansion interface{}
// ResourceClaimNamespaceLister.
type ResourceClaimNamespaceListerExpansion interface{}
// ResourceClaimParametersListerExpansion allows custom methods to be added to
// ResourceClaimParametersLister.
type ResourceClaimParametersListerExpansion interface{}
// ResourceClaimParametersNamespaceListerExpansion allows custom methods to be added to
// ResourceClaimParametersNamespaceLister.
type ResourceClaimParametersNamespaceListerExpansion interface{}
// ResourceClaimTemplateListerExpansion allows custom methods to be added to
// ResourceClaimTemplateLister.
type ResourceClaimTemplateListerExpansion interface{}
@@ -45,3 +57,11 @@ type ResourceClaimTemplateNamespaceListerExpansion interface{}
// ResourceClassListerExpansion allows custom methods to be added to
// ResourceClassLister.
type ResourceClassListerExpansion interface{}
// ResourceClassParametersListerExpansion allows custom methods to be added to
// ResourceClassParametersLister.
type ResourceClassParametersListerExpansion interface{}
// ResourceClassParametersNamespaceListerExpansion allows custom methods to be added to
// ResourceClassParametersNamespaceLister.
type ResourceClassParametersNamespaceListerExpansion interface{}

View File

@@ -0,0 +1,68 @@
/*
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 lister-gen. DO NOT EDIT.
package v1alpha2
import (
v1alpha2 "k8s.io/api/resource/v1alpha2"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/tools/cache"
)
// NodeResourceSliceLister helps list NodeResourceSlices.
// All objects returned here must be treated as read-only.
type NodeResourceSliceLister interface {
// List lists all NodeResourceSlices in the indexer.
// Objects returned here must be treated as read-only.
List(selector labels.Selector) (ret []*v1alpha2.NodeResourceSlice, err error)
// Get retrieves the NodeResourceSlice from the index for a given name.
// Objects returned here must be treated as read-only.
Get(name string) (*v1alpha2.NodeResourceSlice, error)
NodeResourceSliceListerExpansion
}
// nodeResourceSliceLister implements the NodeResourceSliceLister interface.
type nodeResourceSliceLister struct {
indexer cache.Indexer
}
// NewNodeResourceSliceLister returns a new NodeResourceSliceLister.
func NewNodeResourceSliceLister(indexer cache.Indexer) NodeResourceSliceLister {
return &nodeResourceSliceLister{indexer: indexer}
}
// List lists all NodeResourceSlices in the indexer.
func (s *nodeResourceSliceLister) List(selector labels.Selector) (ret []*v1alpha2.NodeResourceSlice, err error) {
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
ret = append(ret, m.(*v1alpha2.NodeResourceSlice))
})
return ret, err
}
// Get retrieves the NodeResourceSlice from the index for a given name.
func (s *nodeResourceSliceLister) Get(name string) (*v1alpha2.NodeResourceSlice, error) {
obj, exists, err := s.indexer.GetByKey(name)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(v1alpha2.Resource("noderesourceslice"), name)
}
return obj.(*v1alpha2.NodeResourceSlice), nil
}

View File

@@ -0,0 +1,99 @@
/*
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 lister-gen. DO NOT EDIT.
package v1alpha2
import (
v1alpha2 "k8s.io/api/resource/v1alpha2"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/tools/cache"
)
// ResourceClaimParametersLister helps list ResourceClaimParameters.
// All objects returned here must be treated as read-only.
type ResourceClaimParametersLister interface {
// List lists all ResourceClaimParameters in the indexer.
// Objects returned here must be treated as read-only.
List(selector labels.Selector) (ret []*v1alpha2.ResourceClaimParameters, err error)
// ResourceClaimParameters returns an object that can list and get ResourceClaimParameters.
ResourceClaimParameters(namespace string) ResourceClaimParametersNamespaceLister
ResourceClaimParametersListerExpansion
}
// resourceClaimParametersLister implements the ResourceClaimParametersLister interface.
type resourceClaimParametersLister struct {
indexer cache.Indexer
}
// NewResourceClaimParametersLister returns a new ResourceClaimParametersLister.
func NewResourceClaimParametersLister(indexer cache.Indexer) ResourceClaimParametersLister {
return &resourceClaimParametersLister{indexer: indexer}
}
// List lists all ResourceClaimParameters in the indexer.
func (s *resourceClaimParametersLister) List(selector labels.Selector) (ret []*v1alpha2.ResourceClaimParameters, err error) {
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
ret = append(ret, m.(*v1alpha2.ResourceClaimParameters))
})
return ret, err
}
// ResourceClaimParameters returns an object that can list and get ResourceClaimParameters.
func (s *resourceClaimParametersLister) ResourceClaimParameters(namespace string) ResourceClaimParametersNamespaceLister {
return resourceClaimParametersNamespaceLister{indexer: s.indexer, namespace: namespace}
}
// ResourceClaimParametersNamespaceLister helps list and get ResourceClaimParameters.
// All objects returned here must be treated as read-only.
type ResourceClaimParametersNamespaceLister interface {
// List lists all ResourceClaimParameters in the indexer for a given namespace.
// Objects returned here must be treated as read-only.
List(selector labels.Selector) (ret []*v1alpha2.ResourceClaimParameters, err error)
// Get retrieves the ResourceClaimParameters from the indexer for a given namespace and name.
// Objects returned here must be treated as read-only.
Get(name string) (*v1alpha2.ResourceClaimParameters, error)
ResourceClaimParametersNamespaceListerExpansion
}
// resourceClaimParametersNamespaceLister implements the ResourceClaimParametersNamespaceLister
// interface.
type resourceClaimParametersNamespaceLister struct {
indexer cache.Indexer
namespace string
}
// List lists all ResourceClaimParameters in the indexer for a given namespace.
func (s resourceClaimParametersNamespaceLister) List(selector labels.Selector) (ret []*v1alpha2.ResourceClaimParameters, err error) {
err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
ret = append(ret, m.(*v1alpha2.ResourceClaimParameters))
})
return ret, err
}
// Get retrieves the ResourceClaimParameters from the indexer for a given namespace and name.
func (s resourceClaimParametersNamespaceLister) Get(name string) (*v1alpha2.ResourceClaimParameters, error) {
obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(v1alpha2.Resource("resourceclaimparameters"), name)
}
return obj.(*v1alpha2.ResourceClaimParameters), nil
}

View File

@@ -0,0 +1,99 @@
/*
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 lister-gen. DO NOT EDIT.
package v1alpha2
import (
v1alpha2 "k8s.io/api/resource/v1alpha2"
"k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/client-go/tools/cache"
)
// ResourceClassParametersLister helps list ResourceClassParameters.
// All objects returned here must be treated as read-only.
type ResourceClassParametersLister interface {
// List lists all ResourceClassParameters in the indexer.
// Objects returned here must be treated as read-only.
List(selector labels.Selector) (ret []*v1alpha2.ResourceClassParameters, err error)
// ResourceClassParameters returns an object that can list and get ResourceClassParameters.
ResourceClassParameters(namespace string) ResourceClassParametersNamespaceLister
ResourceClassParametersListerExpansion
}
// resourceClassParametersLister implements the ResourceClassParametersLister interface.
type resourceClassParametersLister struct {
indexer cache.Indexer
}
// NewResourceClassParametersLister returns a new ResourceClassParametersLister.
func NewResourceClassParametersLister(indexer cache.Indexer) ResourceClassParametersLister {
return &resourceClassParametersLister{indexer: indexer}
}
// List lists all ResourceClassParameters in the indexer.
func (s *resourceClassParametersLister) List(selector labels.Selector) (ret []*v1alpha2.ResourceClassParameters, err error) {
err = cache.ListAll(s.indexer, selector, func(m interface{}) {
ret = append(ret, m.(*v1alpha2.ResourceClassParameters))
})
return ret, err
}
// ResourceClassParameters returns an object that can list and get ResourceClassParameters.
func (s *resourceClassParametersLister) ResourceClassParameters(namespace string) ResourceClassParametersNamespaceLister {
return resourceClassParametersNamespaceLister{indexer: s.indexer, namespace: namespace}
}
// ResourceClassParametersNamespaceLister helps list and get ResourceClassParameters.
// All objects returned here must be treated as read-only.
type ResourceClassParametersNamespaceLister interface {
// List lists all ResourceClassParameters in the indexer for a given namespace.
// Objects returned here must be treated as read-only.
List(selector labels.Selector) (ret []*v1alpha2.ResourceClassParameters, err error)
// Get retrieves the ResourceClassParameters from the indexer for a given namespace and name.
// Objects returned here must be treated as read-only.
Get(name string) (*v1alpha2.ResourceClassParameters, error)
ResourceClassParametersNamespaceListerExpansion
}
// resourceClassParametersNamespaceLister implements the ResourceClassParametersNamespaceLister
// interface.
type resourceClassParametersNamespaceLister struct {
indexer cache.Indexer
namespace string
}
// List lists all ResourceClassParameters in the indexer for a given namespace.
func (s resourceClassParametersNamespaceLister) List(selector labels.Selector) (ret []*v1alpha2.ResourceClassParameters, err error) {
err = cache.ListAllByNamespace(s.indexer, s.namespace, selector, func(m interface{}) {
ret = append(ret, m.(*v1alpha2.ResourceClassParameters))
})
return ret, err
}
// Get retrieves the ResourceClassParameters from the indexer for a given namespace and name.
func (s resourceClassParametersNamespaceLister) Get(name string) (*v1alpha2.ResourceClassParameters, error) {
obj, exists, err := s.indexer.GetByKey(s.namespace + "/" + name)
if err != nil {
return nil, err
}
if !exists {
return nil, errors.NewNotFound(v1alpha2.Resource("resourceclassparameters"), name)
}
return obj.(*v1alpha2.ResourceClassParameters), nil
}

View File

@@ -446,6 +446,18 @@ func GetEtcdStorageDataForNamespace(namespace string) map[schema.GroupVersionRes
Stub: `{"metadata": {"name": "pod1name"}, "spec": {"selectedNode": "node1name", "potentialNodes": ["node1name", "node2name"]}}`,
ExpectedEtcdPath: "/registry/podschedulingcontexts/" + namespace + "/pod1name",
},
gvr("resource.k8s.io", "v1alpha2", "resourceclassparameters"): {
Stub: `{"metadata": {"name": "class1parameters"}}`,
ExpectedEtcdPath: "/registry/resourceclassparameters/" + namespace + "/class1parameters",
},
gvr("resource.k8s.io", "v1alpha2", "resourceclaimparameters"): {
Stub: `{"metadata": {"name": "claim1parameters"}}`,
ExpectedEtcdPath: "/registry/resourceclaimparameters/" + namespace + "/claim1parameters",
},
gvr("resource.k8s.io", "v1alpha2", "noderesourceslices"): {
Stub: `{"metadata": {"name": "node1slice"}, "nodeName": "worker1", "driverName": "dra.example.com"}`, // TODO: add one structured parameter model
ExpectedEtcdPath: "/registry/noderesourceslices/node1slice",
},
// --
// k8s.io/apiserver/pkg/apis/apiserverinternal/v1alpha1