Compare commits

...

16 Commits

Author SHA1 Message Date
Kubernetes Publisher
38928043aa Update dependencies to v0.34.3 tag 2025-12-10 02:48:12 +00:00
Kubernetes Publisher
ab04e77fe9 Merge pull request #135592 from serathius/automated-cherry-pick-of-#135580-upstream-release-1.34
Automated cherry pick of #135580 - Embed proper interface in TransformingStore

Kubernetes-commit: 2f17c6c3972753a829cbd018fc2570553fecb385
2025-12-04 17:44:55 -08:00
Jordan Liggitt
25da70165e Use transformer in consistency checker
Kubernetes-commit: 9043cb4f1c3f893675872a957076d371fe4bbb53
2025-11-26 15:19:00 -05:00
Valerian Roche
0c76ee5d62 Add unit tests for Data Consistency Detector
Kubernetes-commit: 86c4e09a78828504aba09218ff54c222685459d4
2025-07-28 13:53:34 -04:00
Valerian Roche
cc3d9d0039 Embed proper interface in TransformingStore to ensure DeltaFIFO and RealFIFO are implementing it
Signed-off-by: Valerian Roche <valerian.roche@datadoghq.com>

Kubernetes-commit: be4a4f5c207ae62b129a59368cc149f4fadc4e34
2025-07-28 13:53:34 -04:00
Kubernetes Publisher
1bb1ad283d Merge pull request #134589 from liggitt/automated-cherry-pick-of-#134588-upstream-release-1.34
Automated cherry pick of #134588: go 1.25.2/1.24.8 related fixes

Kubernetes-commit: 00b6a4c7afdbd95d9ef5b5f3cada04ac15b0c135
2025-10-14 08:41:34 -07:00
Jordan Liggitt
2505205c42 Remove invalid SAN certificate construction
Kubernetes-commit: f40e4ce55298e0d0ea0149987e774b44a276075c
2025-10-09 16:27:05 -04:00
Kubernetes Publisher
7ffba0fd20 Merge pull request #134004 from DerekFrank/automated-cherry-pick-of-#133573-upstream-release-1.34
Automated cherry pick of #133573: fix: Update unit test to catch actual nil Labels case and fix functionality to handle nil Labels

Kubernetes-commit: a147a2c8da02ff628e560c32202de5951f296662
2025-09-26 05:16:16 -07:00
DerekFrank
145cb8f04b gofmt and review feedback
Kubernetes-commit: 4a40ddf1e6b6ec907a2875f0427e129de4bd789f
2025-08-18 09:52:15 -07:00
DerekFrank
ddcdc12cd6 fix: Update unit test to catch actual nil Labels case and fix functionality to handle nil Labels
Kubernetes-commit: 4ae3b64b73617c9f9f162874e87f500e265f05e1
2025-08-15 14:28:18 -07:00
Kubernetes Publisher
97396af4f4 Merge remote-tracking branch 'origin/master' into release-1.34
Kubernetes-commit: c5d688bb1020431135dabe225e562052c0b296e3
2025-08-16 10:27:36 +00:00
Benjamin Elder
5f737f36c5 clarify that staging repos are automatically published
Kubernetes-commit: e49f6116f9eec5d48f2c8913e598fef496644d01
2025-08-15 14:33:07 -07:00
Benjamin Elder
0b8655b458 add pointer to CONTRIBUTING.md for more details on contributing, clarify read-only
Kubernetes-commit: ada2ed8487708056ff11bd2413da1073558e6d7c
2025-08-15 10:13:18 -07:00
Benjamin Elder
c00384c00d link to what a staging repository is
Kubernetes-commit: 011d50019758a7405c6ff37f0fdbd44dacb607b5
2025-08-15 10:10:26 -07:00
sAchin-680
b53b1f8624 docs: clarify that this is a staging repository and not for direct contributions
Signed-off-by: sAchin-680 <mrmister680@gmail.com>

Kubernetes-commit: 7c43e6d2fdbf88f8d92559dac3cabb23da2a2957
2025-04-17 17:51:45 +05:30
Sunyanan Choochotkaew
42e61823a9 KEP-5075: generated codes from make update
Signed-off-by: Sunyanan Choochotkaew <sunyanan.choochotkaew1@ibm.com>

Kubernetes-commit: 59bba927178174041c5e72f60432e70c5db210bf
2025-08-08 19:39:44 +00:00
49 changed files with 1406 additions and 239 deletions

View File

@@ -1,3 +1,8 @@
> ⚠️ **This is an automatically published [staged repository](https://git.k8s.io/kubernetes/staging#external-repository-staging-area) for Kubernetes**.
> Contributions, including issues and pull requests, should be made to the main Kubernetes repository: [https://github.com/kubernetes/kubernetes](https://github.com/kubernetes/kubernetes).
> This repository is read-only for importing, and not used for direct contributions.
> See [CONTRIBUTING.md](./CONTRIBUTING.md) for more details.
# client-go
Go clients for talking to a [kubernetes](http://kubernetes.io/) cluster.

View File

@@ -12828,6 +12828,9 @@ var schemaYAML = typed.YAMLObject(`types:
type:
scalar: string
default: ""
- name: shareID
type:
scalar: string
- name: io.k8s.api.resource.v1.AllocationResult
map:
fields:
@@ -12848,6 +12851,41 @@ var schemaYAML = typed.YAMLObject(`types:
type:
scalar: string
default: ""
- name: io.k8s.api.resource.v1.CapacityRequestPolicy
map:
fields:
- name: default
type:
namedType: io.k8s.apimachinery.pkg.api.resource.Quantity
- name: validRange
type:
namedType: io.k8s.api.resource.v1.CapacityRequestPolicyRange
- name: validValues
type:
list:
elementType:
namedType: io.k8s.apimachinery.pkg.api.resource.Quantity
elementRelationship: atomic
- name: io.k8s.api.resource.v1.CapacityRequestPolicyRange
map:
fields:
- name: max
type:
namedType: io.k8s.apimachinery.pkg.api.resource.Quantity
- name: min
type:
namedType: io.k8s.apimachinery.pkg.api.resource.Quantity
- name: step
type:
namedType: io.k8s.apimachinery.pkg.api.resource.Quantity
- name: io.k8s.api.resource.v1.CapacityRequirements
map:
fields:
- name: requests
type:
map:
elementType:
namedType: io.k8s.apimachinery.pkg.api.resource.Quantity
- name: io.k8s.api.resource.v1.Counter
map:
fields:
@@ -12872,6 +12910,9 @@ var schemaYAML = typed.YAMLObject(`types:
- name: allNodes
type:
scalar: boolean
- name: allowMultipleAllocations
type:
scalar: boolean
- name: attributes
type:
map:
@@ -12968,6 +13009,9 @@ var schemaYAML = typed.YAMLObject(`types:
- name: io.k8s.api.resource.v1.DeviceCapacity
map:
fields:
- name: requestPolicy
type:
namedType: io.k8s.api.resource.v1.CapacityRequestPolicy
- name: value
type:
namedType: io.k8s.apimachinery.pkg.api.resource.Quantity
@@ -13048,6 +13092,9 @@ var schemaYAML = typed.YAMLObject(`types:
- name: io.k8s.api.resource.v1.DeviceConstraint
map:
fields:
- name: distinctAttribute
type:
scalar: string
- name: matchAttribute
type:
scalar: string
@@ -13103,6 +13150,11 @@ var schemaYAML = typed.YAMLObject(`types:
elementType:
scalar: string
elementRelationship: atomic
- name: consumedCapacity
type:
map:
elementType:
namedType: io.k8s.apimachinery.pkg.api.resource.Quantity
- name: device
type:
scalar: string
@@ -13119,6 +13171,9 @@ var schemaYAML = typed.YAMLObject(`types:
type:
scalar: string
default: ""
- name: shareID
type:
scalar: string
- name: tolerations
type:
list:
@@ -13137,6 +13192,9 @@ var schemaYAML = typed.YAMLObject(`types:
- name: allocationMode
type:
scalar: string
- name: capacity
type:
namedType: io.k8s.api.resource.v1.CapacityRequirements
- name: count
type:
scalar: numeric
@@ -13205,6 +13263,9 @@ var schemaYAML = typed.YAMLObject(`types:
- name: allocationMode
type:
scalar: string
- name: capacity
type:
namedType: io.k8s.api.resource.v1.CapacityRequirements
- name: count
type:
scalar: numeric
@@ -13311,6 +13372,7 @@ var schemaYAML = typed.YAMLObject(`types:
- driver
- device
- pool
- shareID
- name: reservedFor
type:
list:
@@ -13521,6 +13583,9 @@ var schemaYAML = typed.YAMLObject(`types:
type:
scalar: string
default: ""
- name: shareID
type:
scalar: string
- name: io.k8s.api.resource.v1beta1.AllocationResult
map:
fields:
@@ -13540,6 +13605,9 @@ var schemaYAML = typed.YAMLObject(`types:
- name: allNodes
type:
scalar: boolean
- name: allowMultipleAllocations
type:
scalar: boolean
- name: attributes
type:
map:
@@ -13590,6 +13658,41 @@ var schemaYAML = typed.YAMLObject(`types:
type:
scalar: string
default: ""
- name: io.k8s.api.resource.v1beta1.CapacityRequestPolicy
map:
fields:
- name: default
type:
namedType: io.k8s.apimachinery.pkg.api.resource.Quantity
- name: validRange
type:
namedType: io.k8s.api.resource.v1beta1.CapacityRequestPolicyRange
- name: validValues
type:
list:
elementType:
namedType: io.k8s.apimachinery.pkg.api.resource.Quantity
elementRelationship: atomic
- name: io.k8s.api.resource.v1beta1.CapacityRequestPolicyRange
map:
fields:
- name: max
type:
namedType: io.k8s.apimachinery.pkg.api.resource.Quantity
- name: min
type:
namedType: io.k8s.apimachinery.pkg.api.resource.Quantity
- name: step
type:
namedType: io.k8s.apimachinery.pkg.api.resource.Quantity
- name: io.k8s.api.resource.v1beta1.CapacityRequirements
map:
fields:
- name: requests
type:
map:
elementType:
namedType: io.k8s.apimachinery.pkg.api.resource.Quantity
- name: io.k8s.api.resource.v1beta1.Counter
map:
fields:
@@ -13667,6 +13770,9 @@ var schemaYAML = typed.YAMLObject(`types:
- name: io.k8s.api.resource.v1beta1.DeviceCapacity
map:
fields:
- name: requestPolicy
type:
namedType: io.k8s.api.resource.v1beta1.CapacityRequestPolicy
- name: value
type:
namedType: io.k8s.apimachinery.pkg.api.resource.Quantity
@@ -13747,6 +13853,9 @@ var schemaYAML = typed.YAMLObject(`types:
- name: io.k8s.api.resource.v1beta1.DeviceConstraint
map:
fields:
- name: distinctAttribute
type:
scalar: string
- name: matchAttribute
type:
scalar: string
@@ -13777,6 +13886,9 @@ var schemaYAML = typed.YAMLObject(`types:
- name: allocationMode
type:
scalar: string
- name: capacity
type:
namedType: io.k8s.api.resource.v1beta1.CapacityRequirements
- name: count
type:
scalar: numeric
@@ -13824,6 +13936,11 @@ var schemaYAML = typed.YAMLObject(`types:
elementType:
scalar: string
elementRelationship: atomic
- name: consumedCapacity
type:
map:
elementType:
namedType: io.k8s.apimachinery.pkg.api.resource.Quantity
- name: device
type:
scalar: string
@@ -13840,6 +13957,9 @@ var schemaYAML = typed.YAMLObject(`types:
type:
scalar: string
default: ""
- name: shareID
type:
scalar: string
- name: tolerations
type:
list:
@@ -13858,6 +13978,9 @@ var schemaYAML = typed.YAMLObject(`types:
- name: allocationMode
type:
scalar: string
- name: capacity
type:
namedType: io.k8s.api.resource.v1beta1.CapacityRequirements
- name: count
type:
scalar: numeric
@@ -14004,6 +14127,7 @@ var schemaYAML = typed.YAMLObject(`types:
- driver
- device
- pool
- shareID
- name: reservedFor
type:
list:
@@ -14136,6 +14260,9 @@ var schemaYAML = typed.YAMLObject(`types:
type:
scalar: string
default: ""
- name: shareID
type:
scalar: string
- name: io.k8s.api.resource.v1beta2.AllocationResult
map:
fields:
@@ -14156,6 +14283,41 @@ var schemaYAML = typed.YAMLObject(`types:
type:
scalar: string
default: ""
- name: io.k8s.api.resource.v1beta2.CapacityRequestPolicy
map:
fields:
- name: default
type:
namedType: io.k8s.apimachinery.pkg.api.resource.Quantity
- name: validRange
type:
namedType: io.k8s.api.resource.v1beta2.CapacityRequestPolicyRange
- name: validValues
type:
list:
elementType:
namedType: io.k8s.apimachinery.pkg.api.resource.Quantity
elementRelationship: atomic
- name: io.k8s.api.resource.v1beta2.CapacityRequestPolicyRange
map:
fields:
- name: max
type:
namedType: io.k8s.apimachinery.pkg.api.resource.Quantity
- name: min
type:
namedType: io.k8s.apimachinery.pkg.api.resource.Quantity
- name: step
type:
namedType: io.k8s.apimachinery.pkg.api.resource.Quantity
- name: io.k8s.api.resource.v1beta2.CapacityRequirements
map:
fields:
- name: requests
type:
map:
elementType:
namedType: io.k8s.apimachinery.pkg.api.resource.Quantity
- name: io.k8s.api.resource.v1beta2.Counter
map:
fields:
@@ -14180,6 +14342,9 @@ var schemaYAML = typed.YAMLObject(`types:
- name: allNodes
type:
scalar: boolean
- name: allowMultipleAllocations
type:
scalar: boolean
- name: attributes
type:
map:
@@ -14276,6 +14441,9 @@ var schemaYAML = typed.YAMLObject(`types:
- name: io.k8s.api.resource.v1beta2.DeviceCapacity
map:
fields:
- name: requestPolicy
type:
namedType: io.k8s.api.resource.v1beta2.CapacityRequestPolicy
- name: value
type:
namedType: io.k8s.apimachinery.pkg.api.resource.Quantity
@@ -14356,6 +14524,9 @@ var schemaYAML = typed.YAMLObject(`types:
- name: io.k8s.api.resource.v1beta2.DeviceConstraint
map:
fields:
- name: distinctAttribute
type:
scalar: string
- name: matchAttribute
type:
scalar: string
@@ -14411,6 +14582,11 @@ var schemaYAML = typed.YAMLObject(`types:
elementType:
scalar: string
elementRelationship: atomic
- name: consumedCapacity
type:
map:
elementType:
namedType: io.k8s.apimachinery.pkg.api.resource.Quantity
- name: device
type:
scalar: string
@@ -14427,6 +14603,9 @@ var schemaYAML = typed.YAMLObject(`types:
type:
scalar: string
default: ""
- name: shareID
type:
scalar: string
- name: tolerations
type:
list:
@@ -14445,6 +14624,9 @@ var schemaYAML = typed.YAMLObject(`types:
- name: allocationMode
type:
scalar: string
- name: capacity
type:
namedType: io.k8s.api.resource.v1beta2.CapacityRequirements
- name: count
type:
scalar: numeric
@@ -14513,6 +14695,9 @@ var schemaYAML = typed.YAMLObject(`types:
- name: allocationMode
type:
scalar: string
- name: capacity
type:
namedType: io.k8s.api.resource.v1beta2.CapacityRequirements
- name: count
type:
scalar: numeric
@@ -14619,6 +14804,7 @@ var schemaYAML = typed.YAMLObject(`types:
- driver
- device
- pool
- shareID
- name: reservedFor
type:
list:

View File

@@ -29,6 +29,7 @@ type AllocatedDeviceStatusApplyConfiguration struct {
Driver *string `json:"driver,omitempty"`
Pool *string `json:"pool,omitempty"`
Device *string `json:"device,omitempty"`
ShareID *string `json:"shareID,omitempty"`
Conditions []metav1.ConditionApplyConfiguration `json:"conditions,omitempty"`
Data *runtime.RawExtension `json:"data,omitempty"`
NetworkData *NetworkDeviceDataApplyConfiguration `json:"networkData,omitempty"`
@@ -64,6 +65,14 @@ func (b *AllocatedDeviceStatusApplyConfiguration) WithDevice(value string) *Allo
return b
}
// WithShareID sets the ShareID 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 ShareID field is set to the value of the last call.
func (b *AllocatedDeviceStatusApplyConfiguration) WithShareID(value string) *AllocatedDeviceStatusApplyConfiguration {
b.ShareID = &value
return b
}
// WithConditions adds the given value to the Conditions 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 Conditions field.

View File

@@ -0,0 +1,63 @@
/*
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 v1
import (
resource "k8s.io/apimachinery/pkg/api/resource"
)
// CapacityRequestPolicyApplyConfiguration represents a declarative configuration of the CapacityRequestPolicy type for use
// with apply.
type CapacityRequestPolicyApplyConfiguration struct {
Default *resource.Quantity `json:"default,omitempty"`
ValidValues []resource.Quantity `json:"validValues,omitempty"`
ValidRange *CapacityRequestPolicyRangeApplyConfiguration `json:"validRange,omitempty"`
}
// CapacityRequestPolicyApplyConfiguration constructs a declarative configuration of the CapacityRequestPolicy type for use with
// apply.
func CapacityRequestPolicy() *CapacityRequestPolicyApplyConfiguration {
return &CapacityRequestPolicyApplyConfiguration{}
}
// WithDefault sets the Default 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 Default field is set to the value of the last call.
func (b *CapacityRequestPolicyApplyConfiguration) WithDefault(value resource.Quantity) *CapacityRequestPolicyApplyConfiguration {
b.Default = &value
return b
}
// WithValidValues adds the given value to the ValidValues 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 ValidValues field.
func (b *CapacityRequestPolicyApplyConfiguration) WithValidValues(values ...resource.Quantity) *CapacityRequestPolicyApplyConfiguration {
for i := range values {
b.ValidValues = append(b.ValidValues, values[i])
}
return b
}
// WithValidRange sets the ValidRange 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 ValidRange field is set to the value of the last call.
func (b *CapacityRequestPolicyApplyConfiguration) WithValidRange(value *CapacityRequestPolicyRangeApplyConfiguration) *CapacityRequestPolicyApplyConfiguration {
b.ValidRange = value
return b
}

View File

@@ -0,0 +1,61 @@
/*
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 v1
import (
resource "k8s.io/apimachinery/pkg/api/resource"
)
// CapacityRequestPolicyRangeApplyConfiguration represents a declarative configuration of the CapacityRequestPolicyRange type for use
// with apply.
type CapacityRequestPolicyRangeApplyConfiguration struct {
Min *resource.Quantity `json:"min,omitempty"`
Max *resource.Quantity `json:"max,omitempty"`
Step *resource.Quantity `json:"step,omitempty"`
}
// CapacityRequestPolicyRangeApplyConfiguration constructs a declarative configuration of the CapacityRequestPolicyRange type for use with
// apply.
func CapacityRequestPolicyRange() *CapacityRequestPolicyRangeApplyConfiguration {
return &CapacityRequestPolicyRangeApplyConfiguration{}
}
// WithMin sets the Min 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 Min field is set to the value of the last call.
func (b *CapacityRequestPolicyRangeApplyConfiguration) WithMin(value resource.Quantity) *CapacityRequestPolicyRangeApplyConfiguration {
b.Min = &value
return b
}
// WithMax sets the Max 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 Max field is set to the value of the last call.
func (b *CapacityRequestPolicyRangeApplyConfiguration) WithMax(value resource.Quantity) *CapacityRequestPolicyRangeApplyConfiguration {
b.Max = &value
return b
}
// WithStep sets the Step 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 Step field is set to the value of the last call.
func (b *CapacityRequestPolicyRangeApplyConfiguration) WithStep(value resource.Quantity) *CapacityRequestPolicyRangeApplyConfiguration {
b.Step = &value
return b
}

View File

@@ -0,0 +1,50 @@
/*
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 v1
import (
resourcev1 "k8s.io/api/resource/v1"
resource "k8s.io/apimachinery/pkg/api/resource"
)
// CapacityRequirementsApplyConfiguration represents a declarative configuration of the CapacityRequirements type for use
// with apply.
type CapacityRequirementsApplyConfiguration struct {
Requests map[resourcev1.QualifiedName]resource.Quantity `json:"requests,omitempty"`
}
// CapacityRequirementsApplyConfiguration constructs a declarative configuration of the CapacityRequirements type for use with
// apply.
func CapacityRequirements() *CapacityRequirementsApplyConfiguration {
return &CapacityRequirementsApplyConfiguration{}
}
// WithRequests puts the entries into 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, the entries provided by each call will be put on the Requests field,
// overwriting an existing map entries in Requests field with the same key.
func (b *CapacityRequirementsApplyConfiguration) WithRequests(entries map[resourcev1.QualifiedName]resource.Quantity) *CapacityRequirementsApplyConfiguration {
if b.Requests == nil && len(entries) > 0 {
b.Requests = make(map[resourcev1.QualifiedName]resource.Quantity, len(entries))
}
for k, v := range entries {
b.Requests[k] = v
}
return b
}

View File

@@ -37,6 +37,7 @@ type DeviceApplyConfiguration struct {
BindsToNode *bool `json:"bindsToNode,omitempty"`
BindingConditions []string `json:"bindingConditions,omitempty"`
BindingFailureConditions []string `json:"bindingFailureConditions,omitempty"`
AllowMultipleAllocations *bool `json:"allowMultipleAllocations,omitempty"`
}
// DeviceApplyConfiguration constructs a declarative configuration of the Device type for use with
@@ -158,3 +159,11 @@ func (b *DeviceApplyConfiguration) WithBindingFailureConditions(values ...string
}
return b
}
// WithAllowMultipleAllocations sets the AllowMultipleAllocations 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 AllowMultipleAllocations field is set to the value of the last call.
func (b *DeviceApplyConfiguration) WithAllowMultipleAllocations(value bool) *DeviceApplyConfiguration {
b.AllowMultipleAllocations = &value
return b
}

View File

@@ -25,7 +25,8 @@ import (
// DeviceCapacityApplyConfiguration represents a declarative configuration of the DeviceCapacity type for use
// with apply.
type DeviceCapacityApplyConfiguration struct {
Value *resource.Quantity `json:"value,omitempty"`
Value *resource.Quantity `json:"value,omitempty"`
RequestPolicy *CapacityRequestPolicyApplyConfiguration `json:"requestPolicy,omitempty"`
}
// DeviceCapacityApplyConfiguration constructs a declarative configuration of the DeviceCapacity type for use with
@@ -41,3 +42,11 @@ func (b *DeviceCapacityApplyConfiguration) WithValue(value resource.Quantity) *D
b.Value = &value
return b
}
// WithRequestPolicy sets the RequestPolicy 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 RequestPolicy field is set to the value of the last call.
func (b *DeviceCapacityApplyConfiguration) WithRequestPolicy(value *CapacityRequestPolicyApplyConfiguration) *DeviceCapacityApplyConfiguration {
b.RequestPolicy = value
return b
}

View File

@@ -25,8 +25,9 @@ import (
// DeviceConstraintApplyConfiguration represents a declarative configuration of the DeviceConstraint type for use
// with apply.
type DeviceConstraintApplyConfiguration struct {
Requests []string `json:"requests,omitempty"`
MatchAttribute *resourcev1.FullyQualifiedName `json:"matchAttribute,omitempty"`
Requests []string `json:"requests,omitempty"`
MatchAttribute *resourcev1.FullyQualifiedName `json:"matchAttribute,omitempty"`
DistinctAttribute *resourcev1.FullyQualifiedName `json:"distinctAttribute,omitempty"`
}
// DeviceConstraintApplyConfiguration constructs a declarative configuration of the DeviceConstraint type for use with
@@ -52,3 +53,11 @@ func (b *DeviceConstraintApplyConfiguration) WithMatchAttribute(value resourcev1
b.MatchAttribute = &value
return b
}
// WithDistinctAttribute sets the DistinctAttribute 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 DistinctAttribute field is set to the value of the last call.
func (b *DeviceConstraintApplyConfiguration) WithDistinctAttribute(value resourcev1.FullyQualifiedName) *DeviceConstraintApplyConfiguration {
b.DistinctAttribute = &value
return b
}

View File

@@ -18,17 +18,25 @@ limitations under the License.
package v1
import (
resourcev1 "k8s.io/api/resource/v1"
resource "k8s.io/apimachinery/pkg/api/resource"
types "k8s.io/apimachinery/pkg/types"
)
// DeviceRequestAllocationResultApplyConfiguration represents a declarative configuration of the DeviceRequestAllocationResult type for use
// with apply.
type DeviceRequestAllocationResultApplyConfiguration struct {
Request *string `json:"request,omitempty"`
Driver *string `json:"driver,omitempty"`
Pool *string `json:"pool,omitempty"`
Device *string `json:"device,omitempty"`
AdminAccess *bool `json:"adminAccess,omitempty"`
Tolerations []DeviceTolerationApplyConfiguration `json:"tolerations,omitempty"`
BindingConditions []string `json:"bindingConditions,omitempty"`
BindingFailureConditions []string `json:"bindingFailureConditions,omitempty"`
Request *string `json:"request,omitempty"`
Driver *string `json:"driver,omitempty"`
Pool *string `json:"pool,omitempty"`
Device *string `json:"device,omitempty"`
AdminAccess *bool `json:"adminAccess,omitempty"`
Tolerations []DeviceTolerationApplyConfiguration `json:"tolerations,omitempty"`
BindingConditions []string `json:"bindingConditions,omitempty"`
BindingFailureConditions []string `json:"bindingFailureConditions,omitempty"`
ShareID *types.UID `json:"shareID,omitempty"`
ConsumedCapacity map[resourcev1.QualifiedName]resource.Quantity `json:"consumedCapacity,omitempty"`
}
// DeviceRequestAllocationResultApplyConfiguration constructs a declarative configuration of the DeviceRequestAllocationResult type for use with
@@ -109,3 +117,25 @@ func (b *DeviceRequestAllocationResultApplyConfiguration) WithBindingFailureCond
}
return b
}
// WithShareID sets the ShareID 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 ShareID field is set to the value of the last call.
func (b *DeviceRequestAllocationResultApplyConfiguration) WithShareID(value types.UID) *DeviceRequestAllocationResultApplyConfiguration {
b.ShareID = &value
return b
}
// WithConsumedCapacity puts the entries into the ConsumedCapacity 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 ConsumedCapacity field,
// overwriting an existing map entries in ConsumedCapacity field with the same key.
func (b *DeviceRequestAllocationResultApplyConfiguration) WithConsumedCapacity(entries map[resourcev1.QualifiedName]resource.Quantity) *DeviceRequestAllocationResultApplyConfiguration {
if b.ConsumedCapacity == nil && len(entries) > 0 {
b.ConsumedCapacity = make(map[resourcev1.QualifiedName]resource.Quantity, len(entries))
}
for k, v := range entries {
b.ConsumedCapacity[k] = v
}
return b
}

View File

@@ -25,12 +25,13 @@ import (
// DeviceSubRequestApplyConfiguration represents a declarative configuration of the DeviceSubRequest type for use
// with apply.
type DeviceSubRequestApplyConfiguration struct {
Name *string `json:"name,omitempty"`
DeviceClassName *string `json:"deviceClassName,omitempty"`
Selectors []DeviceSelectorApplyConfiguration `json:"selectors,omitempty"`
AllocationMode *resourcev1.DeviceAllocationMode `json:"allocationMode,omitempty"`
Count *int64 `json:"count,omitempty"`
Tolerations []DeviceTolerationApplyConfiguration `json:"tolerations,omitempty"`
Name *string `json:"name,omitempty"`
DeviceClassName *string `json:"deviceClassName,omitempty"`
Selectors []DeviceSelectorApplyConfiguration `json:"selectors,omitempty"`
AllocationMode *resourcev1.DeviceAllocationMode `json:"allocationMode,omitempty"`
Count *int64 `json:"count,omitempty"`
Tolerations []DeviceTolerationApplyConfiguration `json:"tolerations,omitempty"`
Capacity *CapacityRequirementsApplyConfiguration `json:"capacity,omitempty"`
}
// DeviceSubRequestApplyConfiguration constructs a declarative configuration of the DeviceSubRequest type for use with
@@ -96,3 +97,11 @@ func (b *DeviceSubRequestApplyConfiguration) WithTolerations(values ...*DeviceTo
}
return b
}
// WithCapacity sets the Capacity 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 Capacity field is set to the value of the last call.
func (b *DeviceSubRequestApplyConfiguration) WithCapacity(value *CapacityRequirementsApplyConfiguration) *DeviceSubRequestApplyConfiguration {
b.Capacity = value
return b
}

View File

@@ -25,12 +25,13 @@ import (
// ExactDeviceRequestApplyConfiguration represents a declarative configuration of the ExactDeviceRequest type for use
// with apply.
type ExactDeviceRequestApplyConfiguration struct {
DeviceClassName *string `json:"deviceClassName,omitempty"`
Selectors []DeviceSelectorApplyConfiguration `json:"selectors,omitempty"`
AllocationMode *resourcev1.DeviceAllocationMode `json:"allocationMode,omitempty"`
Count *int64 `json:"count,omitempty"`
AdminAccess *bool `json:"adminAccess,omitempty"`
Tolerations []DeviceTolerationApplyConfiguration `json:"tolerations,omitempty"`
DeviceClassName *string `json:"deviceClassName,omitempty"`
Selectors []DeviceSelectorApplyConfiguration `json:"selectors,omitempty"`
AllocationMode *resourcev1.DeviceAllocationMode `json:"allocationMode,omitempty"`
Count *int64 `json:"count,omitempty"`
AdminAccess *bool `json:"adminAccess,omitempty"`
Tolerations []DeviceTolerationApplyConfiguration `json:"tolerations,omitempty"`
Capacity *CapacityRequirementsApplyConfiguration `json:"capacity,omitempty"`
}
// ExactDeviceRequestApplyConfiguration constructs a declarative configuration of the ExactDeviceRequest type for use with
@@ -96,3 +97,11 @@ func (b *ExactDeviceRequestApplyConfiguration) WithTolerations(values ...*Device
}
return b
}
// WithCapacity sets the Capacity 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 Capacity field is set to the value of the last call.
func (b *ExactDeviceRequestApplyConfiguration) WithCapacity(value *CapacityRequirementsApplyConfiguration) *ExactDeviceRequestApplyConfiguration {
b.Capacity = value
return b
}

View File

@@ -29,6 +29,7 @@ type AllocatedDeviceStatusApplyConfiguration struct {
Driver *string `json:"driver,omitempty"`
Pool *string `json:"pool,omitempty"`
Device *string `json:"device,omitempty"`
ShareID *string `json:"shareID,omitempty"`
Conditions []v1.ConditionApplyConfiguration `json:"conditions,omitempty"`
Data *runtime.RawExtension `json:"data,omitempty"`
NetworkData *NetworkDeviceDataApplyConfiguration `json:"networkData,omitempty"`
@@ -64,6 +65,14 @@ func (b *AllocatedDeviceStatusApplyConfiguration) WithDevice(value string) *Allo
return b
}
// WithShareID sets the ShareID 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 ShareID field is set to the value of the last call.
func (b *AllocatedDeviceStatusApplyConfiguration) WithShareID(value string) *AllocatedDeviceStatusApplyConfiguration {
b.ShareID = &value
return b
}
// WithConditions adds the given value to the Conditions 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 Conditions field.

View File

@@ -36,6 +36,7 @@ type BasicDeviceApplyConfiguration struct {
BindsToNode *bool `json:"bindsToNode,omitempty"`
BindingConditions []string `json:"bindingConditions,omitempty"`
BindingFailureConditions []string `json:"bindingFailureConditions,omitempty"`
AllowMultipleAllocations *bool `json:"allowMultipleAllocations,omitempty"`
}
// BasicDeviceApplyConfiguration constructs a declarative configuration of the BasicDevice type for use with
@@ -149,3 +150,11 @@ func (b *BasicDeviceApplyConfiguration) WithBindingFailureConditions(values ...s
}
return b
}
// WithAllowMultipleAllocations sets the AllowMultipleAllocations 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 AllowMultipleAllocations field is set to the value of the last call.
func (b *BasicDeviceApplyConfiguration) WithAllowMultipleAllocations(value bool) *BasicDeviceApplyConfiguration {
b.AllowMultipleAllocations = &value
return b
}

View File

@@ -0,0 +1,63 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by applyconfiguration-gen. DO NOT EDIT.
package v1beta1
import (
resource "k8s.io/apimachinery/pkg/api/resource"
)
// CapacityRequestPolicyApplyConfiguration represents a declarative configuration of the CapacityRequestPolicy type for use
// with apply.
type CapacityRequestPolicyApplyConfiguration struct {
Default *resource.Quantity `json:"default,omitempty"`
ValidValues []resource.Quantity `json:"validValues,omitempty"`
ValidRange *CapacityRequestPolicyRangeApplyConfiguration `json:"validRange,omitempty"`
}
// CapacityRequestPolicyApplyConfiguration constructs a declarative configuration of the CapacityRequestPolicy type for use with
// apply.
func CapacityRequestPolicy() *CapacityRequestPolicyApplyConfiguration {
return &CapacityRequestPolicyApplyConfiguration{}
}
// WithDefault sets the Default 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 Default field is set to the value of the last call.
func (b *CapacityRequestPolicyApplyConfiguration) WithDefault(value resource.Quantity) *CapacityRequestPolicyApplyConfiguration {
b.Default = &value
return b
}
// WithValidValues adds the given value to the ValidValues 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 ValidValues field.
func (b *CapacityRequestPolicyApplyConfiguration) WithValidValues(values ...resource.Quantity) *CapacityRequestPolicyApplyConfiguration {
for i := range values {
b.ValidValues = append(b.ValidValues, values[i])
}
return b
}
// WithValidRange sets the ValidRange 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 ValidRange field is set to the value of the last call.
func (b *CapacityRequestPolicyApplyConfiguration) WithValidRange(value *CapacityRequestPolicyRangeApplyConfiguration) *CapacityRequestPolicyApplyConfiguration {
b.ValidRange = value
return b
}

View File

@@ -0,0 +1,61 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by applyconfiguration-gen. DO NOT EDIT.
package v1beta1
import (
resource "k8s.io/apimachinery/pkg/api/resource"
)
// CapacityRequestPolicyRangeApplyConfiguration represents a declarative configuration of the CapacityRequestPolicyRange type for use
// with apply.
type CapacityRequestPolicyRangeApplyConfiguration struct {
Min *resource.Quantity `json:"min,omitempty"`
Max *resource.Quantity `json:"max,omitempty"`
Step *resource.Quantity `json:"step,omitempty"`
}
// CapacityRequestPolicyRangeApplyConfiguration constructs a declarative configuration of the CapacityRequestPolicyRange type for use with
// apply.
func CapacityRequestPolicyRange() *CapacityRequestPolicyRangeApplyConfiguration {
return &CapacityRequestPolicyRangeApplyConfiguration{}
}
// WithMin sets the Min 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 Min field is set to the value of the last call.
func (b *CapacityRequestPolicyRangeApplyConfiguration) WithMin(value resource.Quantity) *CapacityRequestPolicyRangeApplyConfiguration {
b.Min = &value
return b
}
// WithMax sets the Max 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 Max field is set to the value of the last call.
func (b *CapacityRequestPolicyRangeApplyConfiguration) WithMax(value resource.Quantity) *CapacityRequestPolicyRangeApplyConfiguration {
b.Max = &value
return b
}
// WithStep sets the Step 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 Step field is set to the value of the last call.
func (b *CapacityRequestPolicyRangeApplyConfiguration) WithStep(value resource.Quantity) *CapacityRequestPolicyRangeApplyConfiguration {
b.Step = &value
return b
}

View File

@@ -0,0 +1,50 @@
/*
Copyright The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
// Code generated by applyconfiguration-gen. DO NOT EDIT.
package v1beta1
import (
resourcev1beta1 "k8s.io/api/resource/v1beta1"
resource "k8s.io/apimachinery/pkg/api/resource"
)
// CapacityRequirementsApplyConfiguration represents a declarative configuration of the CapacityRequirements type for use
// with apply.
type CapacityRequirementsApplyConfiguration struct {
Requests map[resourcev1beta1.QualifiedName]resource.Quantity `json:"requests,omitempty"`
}
// CapacityRequirementsApplyConfiguration constructs a declarative configuration of the CapacityRequirements type for use with
// apply.
func CapacityRequirements() *CapacityRequirementsApplyConfiguration {
return &CapacityRequirementsApplyConfiguration{}
}
// WithRequests puts the entries into 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, the entries provided by each call will be put on the Requests field,
// overwriting an existing map entries in Requests field with the same key.
func (b *CapacityRequirementsApplyConfiguration) WithRequests(entries map[resourcev1beta1.QualifiedName]resource.Quantity) *CapacityRequirementsApplyConfiguration {
if b.Requests == nil && len(entries) > 0 {
b.Requests = make(map[resourcev1beta1.QualifiedName]resource.Quantity, len(entries))
}
for k, v := range entries {
b.Requests[k] = v
}
return b
}

View File

@@ -25,7 +25,8 @@ import (
// DeviceCapacityApplyConfiguration represents a declarative configuration of the DeviceCapacity type for use
// with apply.
type DeviceCapacityApplyConfiguration struct {
Value *resource.Quantity `json:"value,omitempty"`
Value *resource.Quantity `json:"value,omitempty"`
RequestPolicy *CapacityRequestPolicyApplyConfiguration `json:"requestPolicy,omitempty"`
}
// DeviceCapacityApplyConfiguration constructs a declarative configuration of the DeviceCapacity type for use with
@@ -41,3 +42,11 @@ func (b *DeviceCapacityApplyConfiguration) WithValue(value resource.Quantity) *D
b.Value = &value
return b
}
// WithRequestPolicy sets the RequestPolicy 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 RequestPolicy field is set to the value of the last call.
func (b *DeviceCapacityApplyConfiguration) WithRequestPolicy(value *CapacityRequestPolicyApplyConfiguration) *DeviceCapacityApplyConfiguration {
b.RequestPolicy = value
return b
}

View File

@@ -25,8 +25,9 @@ import (
// DeviceConstraintApplyConfiguration represents a declarative configuration of the DeviceConstraint type for use
// with apply.
type DeviceConstraintApplyConfiguration struct {
Requests []string `json:"requests,omitempty"`
MatchAttribute *resourcev1beta1.FullyQualifiedName `json:"matchAttribute,omitempty"`
Requests []string `json:"requests,omitempty"`
MatchAttribute *resourcev1beta1.FullyQualifiedName `json:"matchAttribute,omitempty"`
DistinctAttribute *resourcev1beta1.FullyQualifiedName `json:"distinctAttribute,omitempty"`
}
// DeviceConstraintApplyConfiguration constructs a declarative configuration of the DeviceConstraint type for use with
@@ -52,3 +53,11 @@ func (b *DeviceConstraintApplyConfiguration) WithMatchAttribute(value resourcev1
b.MatchAttribute = &value
return b
}
// WithDistinctAttribute sets the DistinctAttribute 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 DistinctAttribute field is set to the value of the last call.
func (b *DeviceConstraintApplyConfiguration) WithDistinctAttribute(value resourcev1beta1.FullyQualifiedName) *DeviceConstraintApplyConfiguration {
b.DistinctAttribute = &value
return b
}

View File

@@ -25,14 +25,15 @@ import (
// DeviceRequestApplyConfiguration represents a declarative configuration of the DeviceRequest type for use
// with apply.
type DeviceRequestApplyConfiguration struct {
Name *string `json:"name,omitempty"`
DeviceClassName *string `json:"deviceClassName,omitempty"`
Selectors []DeviceSelectorApplyConfiguration `json:"selectors,omitempty"`
AllocationMode *resourcev1beta1.DeviceAllocationMode `json:"allocationMode,omitempty"`
Count *int64 `json:"count,omitempty"`
AdminAccess *bool `json:"adminAccess,omitempty"`
FirstAvailable []DeviceSubRequestApplyConfiguration `json:"firstAvailable,omitempty"`
Tolerations []DeviceTolerationApplyConfiguration `json:"tolerations,omitempty"`
Name *string `json:"name,omitempty"`
DeviceClassName *string `json:"deviceClassName,omitempty"`
Selectors []DeviceSelectorApplyConfiguration `json:"selectors,omitempty"`
AllocationMode *resourcev1beta1.DeviceAllocationMode `json:"allocationMode,omitempty"`
Count *int64 `json:"count,omitempty"`
AdminAccess *bool `json:"adminAccess,omitempty"`
FirstAvailable []DeviceSubRequestApplyConfiguration `json:"firstAvailable,omitempty"`
Tolerations []DeviceTolerationApplyConfiguration `json:"tolerations,omitempty"`
Capacity *CapacityRequirementsApplyConfiguration `json:"capacity,omitempty"`
}
// DeviceRequestApplyConfiguration constructs a declarative configuration of the DeviceRequest type for use with
@@ -119,3 +120,11 @@ func (b *DeviceRequestApplyConfiguration) WithTolerations(values ...*DeviceToler
}
return b
}
// WithCapacity sets the Capacity 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 Capacity field is set to the value of the last call.
func (b *DeviceRequestApplyConfiguration) WithCapacity(value *CapacityRequirementsApplyConfiguration) *DeviceRequestApplyConfiguration {
b.Capacity = value
return b
}

View File

@@ -18,17 +18,25 @@ limitations under the License.
package v1beta1
import (
resourcev1beta1 "k8s.io/api/resource/v1beta1"
resource "k8s.io/apimachinery/pkg/api/resource"
types "k8s.io/apimachinery/pkg/types"
)
// DeviceRequestAllocationResultApplyConfiguration represents a declarative configuration of the DeviceRequestAllocationResult type for use
// with apply.
type DeviceRequestAllocationResultApplyConfiguration struct {
Request *string `json:"request,omitempty"`
Driver *string `json:"driver,omitempty"`
Pool *string `json:"pool,omitempty"`
Device *string `json:"device,omitempty"`
AdminAccess *bool `json:"adminAccess,omitempty"`
Tolerations []DeviceTolerationApplyConfiguration `json:"tolerations,omitempty"`
BindingConditions []string `json:"bindingConditions,omitempty"`
BindingFailureConditions []string `json:"bindingFailureConditions,omitempty"`
Request *string `json:"request,omitempty"`
Driver *string `json:"driver,omitempty"`
Pool *string `json:"pool,omitempty"`
Device *string `json:"device,omitempty"`
AdminAccess *bool `json:"adminAccess,omitempty"`
Tolerations []DeviceTolerationApplyConfiguration `json:"tolerations,omitempty"`
BindingConditions []string `json:"bindingConditions,omitempty"`
BindingFailureConditions []string `json:"bindingFailureConditions,omitempty"`
ShareID *types.UID `json:"shareID,omitempty"`
ConsumedCapacity map[resourcev1beta1.QualifiedName]resource.Quantity `json:"consumedCapacity,omitempty"`
}
// DeviceRequestAllocationResultApplyConfiguration constructs a declarative configuration of the DeviceRequestAllocationResult type for use with
@@ -109,3 +117,25 @@ func (b *DeviceRequestAllocationResultApplyConfiguration) WithBindingFailureCond
}
return b
}
// WithShareID sets the ShareID 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 ShareID field is set to the value of the last call.
func (b *DeviceRequestAllocationResultApplyConfiguration) WithShareID(value types.UID) *DeviceRequestAllocationResultApplyConfiguration {
b.ShareID = &value
return b
}
// WithConsumedCapacity puts the entries into the ConsumedCapacity 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 ConsumedCapacity field,
// overwriting an existing map entries in ConsumedCapacity field with the same key.
func (b *DeviceRequestAllocationResultApplyConfiguration) WithConsumedCapacity(entries map[resourcev1beta1.QualifiedName]resource.Quantity) *DeviceRequestAllocationResultApplyConfiguration {
if b.ConsumedCapacity == nil && len(entries) > 0 {
b.ConsumedCapacity = make(map[resourcev1beta1.QualifiedName]resource.Quantity, len(entries))
}
for k, v := range entries {
b.ConsumedCapacity[k] = v
}
return b
}

View File

@@ -25,12 +25,13 @@ import (
// DeviceSubRequestApplyConfiguration represents a declarative configuration of the DeviceSubRequest type for use
// with apply.
type DeviceSubRequestApplyConfiguration struct {
Name *string `json:"name,omitempty"`
DeviceClassName *string `json:"deviceClassName,omitempty"`
Selectors []DeviceSelectorApplyConfiguration `json:"selectors,omitempty"`
AllocationMode *resourcev1beta1.DeviceAllocationMode `json:"allocationMode,omitempty"`
Count *int64 `json:"count,omitempty"`
Tolerations []DeviceTolerationApplyConfiguration `json:"tolerations,omitempty"`
Name *string `json:"name,omitempty"`
DeviceClassName *string `json:"deviceClassName,omitempty"`
Selectors []DeviceSelectorApplyConfiguration `json:"selectors,omitempty"`
AllocationMode *resourcev1beta1.DeviceAllocationMode `json:"allocationMode,omitempty"`
Count *int64 `json:"count,omitempty"`
Tolerations []DeviceTolerationApplyConfiguration `json:"tolerations,omitempty"`
Capacity *CapacityRequirementsApplyConfiguration `json:"capacity,omitempty"`
}
// DeviceSubRequestApplyConfiguration constructs a declarative configuration of the DeviceSubRequest type for use with
@@ -96,3 +97,11 @@ func (b *DeviceSubRequestApplyConfiguration) WithTolerations(values ...*DeviceTo
}
return b
}
// WithCapacity sets the Capacity 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 Capacity field is set to the value of the last call.
func (b *DeviceSubRequestApplyConfiguration) WithCapacity(value *CapacityRequirementsApplyConfiguration) *DeviceSubRequestApplyConfiguration {
b.Capacity = value
return b
}

View File

@@ -29,6 +29,7 @@ type AllocatedDeviceStatusApplyConfiguration struct {
Driver *string `json:"driver,omitempty"`
Pool *string `json:"pool,omitempty"`
Device *string `json:"device,omitempty"`
ShareID *string `json:"shareID,omitempty"`
Conditions []v1.ConditionApplyConfiguration `json:"conditions,omitempty"`
Data *runtime.RawExtension `json:"data,omitempty"`
NetworkData *NetworkDeviceDataApplyConfiguration `json:"networkData,omitempty"`
@@ -64,6 +65,14 @@ func (b *AllocatedDeviceStatusApplyConfiguration) WithDevice(value string) *Allo
return b
}
// WithShareID sets the ShareID 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 ShareID field is set to the value of the last call.
func (b *AllocatedDeviceStatusApplyConfiguration) WithShareID(value string) *AllocatedDeviceStatusApplyConfiguration {
b.ShareID = &value
return b
}
// WithConditions adds the given value to the Conditions 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 Conditions field.

View File

@@ -0,0 +1,63 @@
/*
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 v1beta2
import (
resource "k8s.io/apimachinery/pkg/api/resource"
)
// CapacityRequestPolicyApplyConfiguration represents a declarative configuration of the CapacityRequestPolicy type for use
// with apply.
type CapacityRequestPolicyApplyConfiguration struct {
Default *resource.Quantity `json:"default,omitempty"`
ValidValues []resource.Quantity `json:"validValues,omitempty"`
ValidRange *CapacityRequestPolicyRangeApplyConfiguration `json:"validRange,omitempty"`
}
// CapacityRequestPolicyApplyConfiguration constructs a declarative configuration of the CapacityRequestPolicy type for use with
// apply.
func CapacityRequestPolicy() *CapacityRequestPolicyApplyConfiguration {
return &CapacityRequestPolicyApplyConfiguration{}
}
// WithDefault sets the Default 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 Default field is set to the value of the last call.
func (b *CapacityRequestPolicyApplyConfiguration) WithDefault(value resource.Quantity) *CapacityRequestPolicyApplyConfiguration {
b.Default = &value
return b
}
// WithValidValues adds the given value to the ValidValues 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 ValidValues field.
func (b *CapacityRequestPolicyApplyConfiguration) WithValidValues(values ...resource.Quantity) *CapacityRequestPolicyApplyConfiguration {
for i := range values {
b.ValidValues = append(b.ValidValues, values[i])
}
return b
}
// WithValidRange sets the ValidRange 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 ValidRange field is set to the value of the last call.
func (b *CapacityRequestPolicyApplyConfiguration) WithValidRange(value *CapacityRequestPolicyRangeApplyConfiguration) *CapacityRequestPolicyApplyConfiguration {
b.ValidRange = value
return b
}

View File

@@ -0,0 +1,61 @@
/*
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 v1beta2
import (
resource "k8s.io/apimachinery/pkg/api/resource"
)
// CapacityRequestPolicyRangeApplyConfiguration represents a declarative configuration of the CapacityRequestPolicyRange type for use
// with apply.
type CapacityRequestPolicyRangeApplyConfiguration struct {
Min *resource.Quantity `json:"min,omitempty"`
Max *resource.Quantity `json:"max,omitempty"`
Step *resource.Quantity `json:"step,omitempty"`
}
// CapacityRequestPolicyRangeApplyConfiguration constructs a declarative configuration of the CapacityRequestPolicyRange type for use with
// apply.
func CapacityRequestPolicyRange() *CapacityRequestPolicyRangeApplyConfiguration {
return &CapacityRequestPolicyRangeApplyConfiguration{}
}
// WithMin sets the Min 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 Min field is set to the value of the last call.
func (b *CapacityRequestPolicyRangeApplyConfiguration) WithMin(value resource.Quantity) *CapacityRequestPolicyRangeApplyConfiguration {
b.Min = &value
return b
}
// WithMax sets the Max 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 Max field is set to the value of the last call.
func (b *CapacityRequestPolicyRangeApplyConfiguration) WithMax(value resource.Quantity) *CapacityRequestPolicyRangeApplyConfiguration {
b.Max = &value
return b
}
// WithStep sets the Step 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 Step field is set to the value of the last call.
func (b *CapacityRequestPolicyRangeApplyConfiguration) WithStep(value resource.Quantity) *CapacityRequestPolicyRangeApplyConfiguration {
b.Step = &value
return b
}

View File

@@ -0,0 +1,50 @@
/*
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 v1beta2
import (
resourcev1beta2 "k8s.io/api/resource/v1beta2"
resource "k8s.io/apimachinery/pkg/api/resource"
)
// CapacityRequirementsApplyConfiguration represents a declarative configuration of the CapacityRequirements type for use
// with apply.
type CapacityRequirementsApplyConfiguration struct {
Requests map[resourcev1beta2.QualifiedName]resource.Quantity `json:"requests,omitempty"`
}
// CapacityRequirementsApplyConfiguration constructs a declarative configuration of the CapacityRequirements type for use with
// apply.
func CapacityRequirements() *CapacityRequirementsApplyConfiguration {
return &CapacityRequirementsApplyConfiguration{}
}
// WithRequests puts the entries into 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, the entries provided by each call will be put on the Requests field,
// overwriting an existing map entries in Requests field with the same key.
func (b *CapacityRequirementsApplyConfiguration) WithRequests(entries map[resourcev1beta2.QualifiedName]resource.Quantity) *CapacityRequirementsApplyConfiguration {
if b.Requests == nil && len(entries) > 0 {
b.Requests = make(map[resourcev1beta2.QualifiedName]resource.Quantity, len(entries))
}
for k, v := range entries {
b.Requests[k] = v
}
return b
}

View File

@@ -37,6 +37,7 @@ type DeviceApplyConfiguration struct {
BindsToNode *bool `json:"bindsToNode,omitempty"`
BindingConditions []string `json:"bindingConditions,omitempty"`
BindingFailureConditions []string `json:"bindingFailureConditions,omitempty"`
AllowMultipleAllocations *bool `json:"allowMultipleAllocations,omitempty"`
}
// DeviceApplyConfiguration constructs a declarative configuration of the Device type for use with
@@ -158,3 +159,11 @@ func (b *DeviceApplyConfiguration) WithBindingFailureConditions(values ...string
}
return b
}
// WithAllowMultipleAllocations sets the AllowMultipleAllocations 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 AllowMultipleAllocations field is set to the value of the last call.
func (b *DeviceApplyConfiguration) WithAllowMultipleAllocations(value bool) *DeviceApplyConfiguration {
b.AllowMultipleAllocations = &value
return b
}

View File

@@ -25,7 +25,8 @@ import (
// DeviceCapacityApplyConfiguration represents a declarative configuration of the DeviceCapacity type for use
// with apply.
type DeviceCapacityApplyConfiguration struct {
Value *resource.Quantity `json:"value,omitempty"`
Value *resource.Quantity `json:"value,omitempty"`
RequestPolicy *CapacityRequestPolicyApplyConfiguration `json:"requestPolicy,omitempty"`
}
// DeviceCapacityApplyConfiguration constructs a declarative configuration of the DeviceCapacity type for use with
@@ -41,3 +42,11 @@ func (b *DeviceCapacityApplyConfiguration) WithValue(value resource.Quantity) *D
b.Value = &value
return b
}
// WithRequestPolicy sets the RequestPolicy 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 RequestPolicy field is set to the value of the last call.
func (b *DeviceCapacityApplyConfiguration) WithRequestPolicy(value *CapacityRequestPolicyApplyConfiguration) *DeviceCapacityApplyConfiguration {
b.RequestPolicy = value
return b
}

View File

@@ -25,8 +25,9 @@ import (
// DeviceConstraintApplyConfiguration represents a declarative configuration of the DeviceConstraint type for use
// with apply.
type DeviceConstraintApplyConfiguration struct {
Requests []string `json:"requests,omitempty"`
MatchAttribute *resourcev1beta2.FullyQualifiedName `json:"matchAttribute,omitempty"`
Requests []string `json:"requests,omitempty"`
MatchAttribute *resourcev1beta2.FullyQualifiedName `json:"matchAttribute,omitempty"`
DistinctAttribute *resourcev1beta2.FullyQualifiedName `json:"distinctAttribute,omitempty"`
}
// DeviceConstraintApplyConfiguration constructs a declarative configuration of the DeviceConstraint type for use with
@@ -52,3 +53,11 @@ func (b *DeviceConstraintApplyConfiguration) WithMatchAttribute(value resourcev1
b.MatchAttribute = &value
return b
}
// WithDistinctAttribute sets the DistinctAttribute 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 DistinctAttribute field is set to the value of the last call.
func (b *DeviceConstraintApplyConfiguration) WithDistinctAttribute(value resourcev1beta2.FullyQualifiedName) *DeviceConstraintApplyConfiguration {
b.DistinctAttribute = &value
return b
}

View File

@@ -18,17 +18,25 @@ limitations under the License.
package v1beta2
import (
resourcev1beta2 "k8s.io/api/resource/v1beta2"
resource "k8s.io/apimachinery/pkg/api/resource"
types "k8s.io/apimachinery/pkg/types"
)
// DeviceRequestAllocationResultApplyConfiguration represents a declarative configuration of the DeviceRequestAllocationResult type for use
// with apply.
type DeviceRequestAllocationResultApplyConfiguration struct {
Request *string `json:"request,omitempty"`
Driver *string `json:"driver,omitempty"`
Pool *string `json:"pool,omitempty"`
Device *string `json:"device,omitempty"`
AdminAccess *bool `json:"adminAccess,omitempty"`
Tolerations []DeviceTolerationApplyConfiguration `json:"tolerations,omitempty"`
BindingConditions []string `json:"bindingConditions,omitempty"`
BindingFailureConditions []string `json:"bindingFailureConditions,omitempty"`
Request *string `json:"request,omitempty"`
Driver *string `json:"driver,omitempty"`
Pool *string `json:"pool,omitempty"`
Device *string `json:"device,omitempty"`
AdminAccess *bool `json:"adminAccess,omitempty"`
Tolerations []DeviceTolerationApplyConfiguration `json:"tolerations,omitempty"`
BindingConditions []string `json:"bindingConditions,omitempty"`
BindingFailureConditions []string `json:"bindingFailureConditions,omitempty"`
ShareID *types.UID `json:"shareID,omitempty"`
ConsumedCapacity map[resourcev1beta2.QualifiedName]resource.Quantity `json:"consumedCapacity,omitempty"`
}
// DeviceRequestAllocationResultApplyConfiguration constructs a declarative configuration of the DeviceRequestAllocationResult type for use with
@@ -109,3 +117,25 @@ func (b *DeviceRequestAllocationResultApplyConfiguration) WithBindingFailureCond
}
return b
}
// WithShareID sets the ShareID 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 ShareID field is set to the value of the last call.
func (b *DeviceRequestAllocationResultApplyConfiguration) WithShareID(value types.UID) *DeviceRequestAllocationResultApplyConfiguration {
b.ShareID = &value
return b
}
// WithConsumedCapacity puts the entries into the ConsumedCapacity 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 ConsumedCapacity field,
// overwriting an existing map entries in ConsumedCapacity field with the same key.
func (b *DeviceRequestAllocationResultApplyConfiguration) WithConsumedCapacity(entries map[resourcev1beta2.QualifiedName]resource.Quantity) *DeviceRequestAllocationResultApplyConfiguration {
if b.ConsumedCapacity == nil && len(entries) > 0 {
b.ConsumedCapacity = make(map[resourcev1beta2.QualifiedName]resource.Quantity, len(entries))
}
for k, v := range entries {
b.ConsumedCapacity[k] = v
}
return b
}

View File

@@ -25,12 +25,13 @@ import (
// DeviceSubRequestApplyConfiguration represents a declarative configuration of the DeviceSubRequest type for use
// with apply.
type DeviceSubRequestApplyConfiguration struct {
Name *string `json:"name,omitempty"`
DeviceClassName *string `json:"deviceClassName,omitempty"`
Selectors []DeviceSelectorApplyConfiguration `json:"selectors,omitempty"`
AllocationMode *resourcev1beta2.DeviceAllocationMode `json:"allocationMode,omitempty"`
Count *int64 `json:"count,omitempty"`
Tolerations []DeviceTolerationApplyConfiguration `json:"tolerations,omitempty"`
Name *string `json:"name,omitempty"`
DeviceClassName *string `json:"deviceClassName,omitempty"`
Selectors []DeviceSelectorApplyConfiguration `json:"selectors,omitempty"`
AllocationMode *resourcev1beta2.DeviceAllocationMode `json:"allocationMode,omitempty"`
Count *int64 `json:"count,omitempty"`
Tolerations []DeviceTolerationApplyConfiguration `json:"tolerations,omitempty"`
Capacity *CapacityRequirementsApplyConfiguration `json:"capacity,omitempty"`
}
// DeviceSubRequestApplyConfiguration constructs a declarative configuration of the DeviceSubRequest type for use with
@@ -96,3 +97,11 @@ func (b *DeviceSubRequestApplyConfiguration) WithTolerations(values ...*DeviceTo
}
return b
}
// WithCapacity sets the Capacity 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 Capacity field is set to the value of the last call.
func (b *DeviceSubRequestApplyConfiguration) WithCapacity(value *CapacityRequirementsApplyConfiguration) *DeviceSubRequestApplyConfiguration {
b.Capacity = value
return b
}

View File

@@ -25,12 +25,13 @@ import (
// ExactDeviceRequestApplyConfiguration represents a declarative configuration of the ExactDeviceRequest type for use
// with apply.
type ExactDeviceRequestApplyConfiguration struct {
DeviceClassName *string `json:"deviceClassName,omitempty"`
Selectors []DeviceSelectorApplyConfiguration `json:"selectors,omitempty"`
AllocationMode *resourcev1beta2.DeviceAllocationMode `json:"allocationMode,omitempty"`
Count *int64 `json:"count,omitempty"`
AdminAccess *bool `json:"adminAccess,omitempty"`
Tolerations []DeviceTolerationApplyConfiguration `json:"tolerations,omitempty"`
DeviceClassName *string `json:"deviceClassName,omitempty"`
Selectors []DeviceSelectorApplyConfiguration `json:"selectors,omitempty"`
AllocationMode *resourcev1beta2.DeviceAllocationMode `json:"allocationMode,omitempty"`
Count *int64 `json:"count,omitempty"`
AdminAccess *bool `json:"adminAccess,omitempty"`
Tolerations []DeviceTolerationApplyConfiguration `json:"tolerations,omitempty"`
Capacity *CapacityRequirementsApplyConfiguration `json:"capacity,omitempty"`
}
// ExactDeviceRequestApplyConfiguration constructs a declarative configuration of the ExactDeviceRequest type for use with
@@ -96,3 +97,11 @@ func (b *ExactDeviceRequestApplyConfiguration) WithTolerations(values ...*Device
}
return b
}
// WithCapacity sets the Capacity 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 Capacity field is set to the value of the last call.
func (b *ExactDeviceRequestApplyConfiguration) WithCapacity(value *CapacityRequirementsApplyConfiguration) *ExactDeviceRequestApplyConfiguration {
b.Capacity = value
return b
}

View File

@@ -1632,6 +1632,12 @@ func ForKind(kind schema.GroupVersionKind) interface{} {
return &applyconfigurationsresourcev1.AllocatedDeviceStatusApplyConfiguration{}
case resourcev1.SchemeGroupVersion.WithKind("AllocationResult"):
return &applyconfigurationsresourcev1.AllocationResultApplyConfiguration{}
case resourcev1.SchemeGroupVersion.WithKind("CapacityRequestPolicy"):
return &applyconfigurationsresourcev1.CapacityRequestPolicyApplyConfiguration{}
case resourcev1.SchemeGroupVersion.WithKind("CapacityRequestPolicyRange"):
return &applyconfigurationsresourcev1.CapacityRequestPolicyRangeApplyConfiguration{}
case resourcev1.SchemeGroupVersion.WithKind("CapacityRequirements"):
return &applyconfigurationsresourcev1.CapacityRequirementsApplyConfiguration{}
case resourcev1.SchemeGroupVersion.WithKind("CELDeviceSelector"):
return &applyconfigurationsresourcev1.CELDeviceSelectorApplyConfiguration{}
case resourcev1.SchemeGroupVersion.WithKind("Counter"):
@@ -1722,6 +1728,12 @@ func ForKind(kind schema.GroupVersionKind) interface{} {
return &applyconfigurationsresourcev1beta1.AllocationResultApplyConfiguration{}
case resourcev1beta1.SchemeGroupVersion.WithKind("BasicDevice"):
return &applyconfigurationsresourcev1beta1.BasicDeviceApplyConfiguration{}
case resourcev1beta1.SchemeGroupVersion.WithKind("CapacityRequestPolicy"):
return &applyconfigurationsresourcev1beta1.CapacityRequestPolicyApplyConfiguration{}
case resourcev1beta1.SchemeGroupVersion.WithKind("CapacityRequestPolicyRange"):
return &applyconfigurationsresourcev1beta1.CapacityRequestPolicyRangeApplyConfiguration{}
case resourcev1beta1.SchemeGroupVersion.WithKind("CapacityRequirements"):
return &applyconfigurationsresourcev1beta1.CapacityRequirementsApplyConfiguration{}
case resourcev1beta1.SchemeGroupVersion.WithKind("CELDeviceSelector"):
return &applyconfigurationsresourcev1beta1.CELDeviceSelectorApplyConfiguration{}
case resourcev1beta1.SchemeGroupVersion.WithKind("Counter"):
@@ -1794,6 +1806,12 @@ func ForKind(kind schema.GroupVersionKind) interface{} {
return &applyconfigurationsresourcev1beta2.AllocatedDeviceStatusApplyConfiguration{}
case resourcev1beta2.SchemeGroupVersion.WithKind("AllocationResult"):
return &applyconfigurationsresourcev1beta2.AllocationResultApplyConfiguration{}
case resourcev1beta2.SchemeGroupVersion.WithKind("CapacityRequestPolicy"):
return &applyconfigurationsresourcev1beta2.CapacityRequestPolicyApplyConfiguration{}
case resourcev1beta2.SchemeGroupVersion.WithKind("CapacityRequestPolicyRange"):
return &applyconfigurationsresourcev1beta2.CapacityRequestPolicyRangeApplyConfiguration{}
case resourcev1beta2.SchemeGroupVersion.WithKind("CapacityRequirements"):
return &applyconfigurationsresourcev1beta2.CapacityRequirementsApplyConfiguration{}
case resourcev1beta2.SchemeGroupVersion.WithKind("CELDeviceSelector"):
return &applyconfigurationsresourcev1beta2.CELDeviceSelectorApplyConfiguration{}
case resourcev1beta2.SchemeGroupVersion.WithKind("Counter"):

4
go.mod
View File

@@ -25,8 +25,8 @@ require (
golang.org/x/time v0.9.0
google.golang.org/protobuf v1.36.5
gopkg.in/evanphx/json-patch.v4 v4.12.0
k8s.io/api v0.0.0-20250729200427-dd1e23428d50
k8s.io/apimachinery v0.0.0-20250725024258-04507a37f6a4
k8s.io/api v0.34.3
k8s.io/apimachinery v0.34.3
k8s.io/klog/v2 v2.130.1
k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b
k8s.io/utils v0.0.0-20250604170112-4c0f3b243397

8
go.sum
View File

@@ -150,10 +150,10 @@ gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
k8s.io/api v0.0.0-20250729200427-dd1e23428d50 h1:cYzhwY7Bz0lY/yUVbZn/8sVYR/jhsioGEoEbb/6y1WY=
k8s.io/api v0.0.0-20250729200427-dd1e23428d50/go.mod h1:wKZv1VB6nzJ6L449TteVelrBfRsawhrthiOsEylKo8U=
k8s.io/apimachinery v0.0.0-20250725024258-04507a37f6a4 h1:N25HX4lRPTvLHSUPoCMFP+B/oEcOmPESB+BRkYMD8Io=
k8s.io/apimachinery v0.0.0-20250725024258-04507a37f6a4/go.mod h1:/GwIlEcWuTX9zKIg2mbw0LRFIsXwrfoVxn+ef0X13lw=
k8s.io/api v0.34.3 h1:D12sTP257/jSH2vHV2EDYrb16bS7ULlHpdNdNhEw2S4=
k8s.io/api v0.34.3/go.mod h1:PyVQBF886Q5RSQZOim7DybQjAbVs8g7gwJNhGtY5MBk=
k8s.io/apimachinery v0.34.3 h1:/TB+SFEiQvN9HPldtlWOTp0hWbJ+fjU+wkxysf/aQnE=
k8s.io/apimachinery v0.34.3/go.mod h1:/GwIlEcWuTX9zKIg2mbw0LRFIsXwrfoVxn+ef0X13lw=
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
k8s.io/klog/v2 v2.130.1/go.mod h1:3Jpz1GvMt720eyJH1ckRHK1EDfpxISzJ7I9OYgaDtPE=
k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b h1:MloQ9/bdJyIu9lb1PzujOPolHyvO06MXG5TUIj2mNAA=

View File

@@ -596,16 +596,7 @@ func newInformer(clientState Store, options InformerOptions) Controller {
// KeyLister, that way resync operations will result in the correct set
// of update/delete deltas.
var fifo Queue
if clientgofeaturegate.FeatureGates().Enabled(clientgofeaturegate.InOrderInformers) {
fifo = NewRealFIFO(MetaNamespaceKeyFunc, clientState, options.Transform)
} else {
fifo = NewDeltaFIFOWithOptions(DeltaFIFOOptions{
KnownObjects: clientState,
EmitDeltaTypeReplaced: true,
Transformer: options.Transform,
})
}
fifo := newQueueFIFO(clientState, options.Transform)
cfg := &Config{
Queue: fifo,
@@ -623,3 +614,15 @@ func newInformer(clientState Store, options InformerOptions) Controller {
}
return New(cfg)
}
func newQueueFIFO(clientState Store, transform TransformFunc) Queue {
if clientgofeaturegate.FeatureGates().Enabled(clientgofeaturegate.InOrderInformers) {
return NewRealFIFO(MetaNamespaceKeyFunc, clientState, transform)
} else {
return NewDeltaFIFOWithOptions(DeltaFIFOOptions{
KnownObjects: clientState,
EmitDeltaTypeReplaced: true,
Transformer: transform,
})
}
}

View File

@@ -270,7 +270,8 @@ func NewDeltaFIFOWithOptions(opts DeltaFIFOOptions) *DeltaFIFO {
}
var (
_ = Queue(&DeltaFIFO{}) // DeltaFIFO is a Queue
_ = Queue(&DeltaFIFO{}) // DeltaFIFO is a Queue
_ = TransformingStore(&DeltaFIFO{}) // DeltaFIFO implements TransformingStore to allow memory optimizations
)
var (

View File

@@ -28,7 +28,7 @@ import (
// from the most recent Delta.
// You should treat the items returned inside the deltas as immutable.
// This function was moved here because it is not consistent with normal list semantics, but is used in unit testing.
func (f *DeltaFIFO) List() []interface{} {
func (f *DeltaFIFO) list() []interface{} {
f.lock.RLock()
defer f.lock.RUnlock()
return f.listLocked()
@@ -46,7 +46,7 @@ func (f *DeltaFIFO) listLocked() []interface{} {
// ListKeys returns a list of all the keys of the objects currently
// in the FIFO.
// This function was moved here because it is not consistent with normal list semantics, but is used in unit testing.
func (f *DeltaFIFO) ListKeys() []string {
func (f *DeltaFIFO) listKeys() []string {
f.lock.RLock()
defer f.lock.RUnlock()
list := make([]string, 0, len(f.queue))
@@ -60,19 +60,19 @@ func (f *DeltaFIFO) ListKeys() []string {
// or sets exists=false.
// You should treat the items returned inside the deltas as immutable.
// This function was moved here because it is not consistent with normal list semantics, but is used in unit testing.
func (f *DeltaFIFO) Get(obj interface{}) (item interface{}, exists bool, err error) {
func (f *DeltaFIFO) get(obj interface{}) (item interface{}, exists bool, err error) {
key, err := f.KeyOf(obj)
if err != nil {
return nil, false, KeyError{obj, err}
}
return f.GetByKey(key)
return f.getByKey(key)
}
// GetByKey returns the complete list of deltas for the requested item,
// setting exists=false if that list is empty.
// You should treat the items returned inside the deltas as immutable.
// This function was moved here because it is not consistent with normal list semantics, but is used in unit testing.
func (f *DeltaFIFO) GetByKey(key string) (item interface{}, exists bool, err error) {
func (f *DeltaFIFO) getByKey(key string) (item interface{}, exists bool, err error) {
f.lock.RLock()
defer f.lock.RUnlock()
d, exists := f.items[key]
@@ -320,10 +320,10 @@ func TestDeltaFIFO_addUpdate(t *testing.T) {
f.Update(mkFifoObj("foo", 12))
f.Delete(mkFifoObj("foo", 15))
if e, a := []interface{}{mkFifoObj("foo", 15)}, f.List(); !reflect.DeepEqual(e, a) {
if e, a := []interface{}{mkFifoObj("foo", 15)}, f.list(); !reflect.DeepEqual(e, a) {
t.Errorf("Expected %+v, got %+v", e, a)
}
if e, a := []string{"foo"}, f.ListKeys(); !reflect.DeepEqual(e, a) {
if e, a := []string{"foo"}, f.listKeys(); !reflect.DeepEqual(e, a) {
t.Errorf("Expected %+v, got %+v", e, a)
}
@@ -349,7 +349,7 @@ func TestDeltaFIFO_addUpdate(t *testing.T) {
t.Errorf("Got second value %v", unexpected.val)
case <-time.After(50 * time.Millisecond):
}
_, exists, _ := f.Get(mkFifoObj("foo", ""))
_, exists, _ := f.get(mkFifoObj("foo", ""))
if exists {
t.Errorf("item did not get removed")
}
@@ -397,7 +397,7 @@ func TestDeltaFIFO_transformer(t *testing.T) {
must(f.Replace([]interface{}{}, ""))
// Should be empty
if e, a := []string{"foo", "bar"}, f.ListKeys(); !reflect.DeepEqual(e, a) {
if e, a := []string{"foo", "bar"}, f.listKeys(); !reflect.DeepEqual(e, a) {
t.Errorf("Expected %+v, got %+v", e, a)
}
@@ -507,7 +507,7 @@ func TestDeltaFIFO_addReplace(t *testing.T) {
t.Errorf("Got second value %v", unexpected.val)
case <-time.After(50 * time.Millisecond):
}
_, exists, _ := f.Get(mkFifoObj("foo", ""))
_, exists, _ := f.get(mkFifoObj("foo", ""))
if exists {
t.Errorf("item did not get removed")
}
@@ -991,7 +991,7 @@ func BenchmarkDeltaFIFOListKeys(b *testing.B) {
b.ResetTimer()
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
_ = f.ListKeys()
_ = f.listKeys()
}
})
b.StopTimer()

View File

@@ -80,7 +80,7 @@ type ReflectorStore interface {
// TransformingStore is an optional interface that can be implemented by the provided store.
// If implemented on the provided store reflector will use the same transformer in its internal stores.
type TransformingStore interface {
Store
ReflectorStore
Transformer() TransformFunc
}
@@ -726,9 +726,11 @@ func (r *Reflector) watchList(ctx context.Context) (watch.Interface, error) {
return false
}
var transformer TransformFunc
storeOpts := []StoreOption{}
if tr, ok := r.store.(TransformingStore); ok && tr.Transformer() != nil {
storeOpts = append(storeOpts, WithTransformer(tr.Transformer()))
transformer = tr.Transformer()
storeOpts = append(storeOpts, WithTransformer(transformer))
}
initTrace := trace.New("Reflector WatchList", trace.Field{Key: "name", Value: r.name})
@@ -788,7 +790,7 @@ func (r *Reflector) watchList(ctx context.Context) (watch.Interface, error) {
// we utilize the temporaryStore to ensure independence from the current store implementation.
// as of today, the store is implemented as a queue and will be drained by the higher-level
// component as soon as it finishes replacing the content.
checkWatchListDataConsistencyIfRequested(ctx, r.name, resourceVersion, r.listerWatcher.ListWithContext, temporaryStore.List)
checkWatchListDataConsistencyIfRequested(ctx, r.name, resourceVersion, r.listerWatcher.ListWithContext, transformer, temporaryStore.List)
if err := r.store.Replace(temporaryStore.List(), resourceVersion); err != nil {
return nil, fmt.Errorf("unable to sync watch-list result: %w", err)

View File

@@ -33,11 +33,11 @@ import (
//
// Note that this function will panic when data inconsistency is detected.
// This is intentional because we want to catch it in the CI.
func checkWatchListDataConsistencyIfRequested[T runtime.Object, U any](ctx context.Context, identity string, lastSyncedResourceVersion string, listFn consistencydetector.ListFunc[T], retrieveItemsFn consistencydetector.RetrieveItemsFunc[U]) {
func checkWatchListDataConsistencyIfRequested[T runtime.Object, U any](ctx context.Context, identity string, lastSyncedResourceVersion string, listFn consistencydetector.ListFunc[T], listItemTransformFunc func(interface{}) (interface{}, error), retrieveItemsFn consistencydetector.RetrieveItemsFunc[U]) {
if !consistencydetector.IsDataConsistencyDetectionForWatchListEnabled() {
return
}
// for informers we pass an empty ListOptions because
// listFn might be wrapped for filtering during informer construction.
consistencydetector.CheckDataConsistency(ctx, identity, lastSyncedResourceVersion, listFn, metav1.ListOptions{}, retrieveItemsFn)
consistencydetector.CheckDataConsistency(ctx, identity, lastSyncedResourceVersion, listFn, listItemTransformFunc, metav1.ListOptions{}, retrieveItemsFn)
}

View File

@@ -0,0 +1,114 @@
/*
Copyright 2024 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 cache
import (
"context"
"fmt"
"testing"
"time"
v1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/util/wait"
"k8s.io/apimachinery/pkg/watch"
clientfeatures "k8s.io/client-go/features"
clientfeaturestesting "k8s.io/client-go/features/testing"
"k8s.io/client-go/util/consistencydetector"
"k8s.io/klog/v2/ktesting"
)
func TestReflectorDataConsistencyDetector(t *testing.T) {
clientfeaturestesting.SetFeatureDuringTest(t, clientfeatures.WatchListClient, true)
restore := consistencydetector.SetDataConsistencyDetectionForWatchListEnabledForTest(true)
defer restore()
markTransformed := func(obj interface{}) (interface{}, error) {
pod, ok := obj.(*v1.Pod)
if !ok {
return obj, nil
}
newPod := pod.DeepCopy()
if newPod.Labels == nil {
newPod.Labels = make(map[string]string)
}
newPod.Labels["transformed"] = "true"
return newPod, nil
}
for _, inOrder := range []bool{false, true} {
t.Run(fmt.Sprintf("InOrder=%v", inOrder), func(t *testing.T) {
clientfeaturestesting.SetFeatureDuringTest(t, clientfeatures.InOrderInformers, inOrder)
for _, transformerEnabled := range []bool{false, true} {
var transformer TransformFunc
if transformerEnabled {
transformer = markTransformed
}
t.Run(fmt.Sprintf("Transformer=%v", transformerEnabled), func(t *testing.T) {
runTestReflectorDataConsistencyDetector(t, transformer)
})
}
})
}
}
func runTestReflectorDataConsistencyDetector(t *testing.T, transformer TransformFunc) {
_, ctx := ktesting.NewTestContext(t)
ctx, cancel := context.WithCancel(ctx)
defer cancel()
store := NewStore(MetaNamespaceKeyFunc)
fifo := newQueueFIFO(store, transformer)
lw := &ListWatch{
ListFunc: func(options metav1.ListOptions) (runtime.Object, error) {
return &v1.PodList{
ListMeta: metav1.ListMeta{ResourceVersion: "1"},
Items: []v1.Pod{
{ObjectMeta: metav1.ObjectMeta{Name: "pod-1", ResourceVersion: "1"}},
},
}, nil
},
WatchFunc: func(options metav1.ListOptions) (watch.Interface, error) {
w := watch.NewFake()
go func() {
w.Add(&v1.Pod{ObjectMeta: metav1.ObjectMeta{Name: "pod-1", ResourceVersion: "1"}})
w.Action(watch.Bookmark, &v1.Pod{ObjectMeta: metav1.ObjectMeta{
Name: "pod-1",
ResourceVersion: "1",
Annotations: map[string]string{metav1.InitialEventsAnnotationKey: "true"},
}})
}()
return w, nil
},
}
r := NewReflector(lw, &v1.Pod{}, fifo, 0)
go func() {
_ = wait.PollUntilContextTimeout(ctx, 10*time.Millisecond, 5*time.Second, true, func(ctx context.Context) (bool, error) {
return r.LastSyncResourceVersion() != "", nil
})
cancel()
}()
err := r.ListAndWatchWithContext(ctx)
if err != nil {
t.Errorf("ListAndWatchWithContext returned error: %v", err)
}
}

View File

@@ -20,10 +20,12 @@ import (
"context"
"errors"
"fmt"
"maps"
"math/rand"
"net/http"
"reflect"
goruntime "runtime"
"slices"
"strconv"
"sync"
"sync/atomic"
@@ -1962,7 +1964,7 @@ func TestReflectorReplacesStoreOnUnsafeDelete(t *testing.T) {
s := NewFIFO(MetaNamespaceKeyFunc)
var replaceInvoked atomic.Int32
store := &fakeStore{
Store: s,
ReflectorStore: s,
beforeReplace: func(list []interface{}, rv string) {
// interested in the Replace call that happens after the Error event
if rv == lastExpectedRV {
@@ -2057,131 +2059,165 @@ func TestReflectorReplacesStoreOnUnsafeDelete(t *testing.T) {
}
func TestReflectorRespectStoreTransformer(t *testing.T) {
mkPod := func(id string, rv string) *v1.Pod {
return &v1.Pod{
ObjectMeta: metav1.ObjectMeta{Namespace: "ns", Name: id, ResourceVersion: rv},
Spec: v1.PodSpec{
Hostname: "test",
for name, test := range map[string]struct {
storeBuilder func(counter *atomic.Int32) ReflectorStore
items func(rs ReflectorStore) []interface{}
}{
"real-fifo": {
storeBuilder: func(counter *atomic.Int32) ReflectorStore {
return NewRealFIFO(MetaNamespaceKeyFunc, NewStore(MetaNamespaceKeyFunc), func(i interface{}) (interface{}, error) {
counter.Add(1)
cast := i.(*v1.Pod)
cast.Spec.Hostname = "transformed"
return cast, nil
})
},
}
}
preExisting1 := mkPod("foo-1", "1")
preExisting2 := mkPod("foo-2", "2")
pod3 := mkPod("foo-3", "3")
lastExpectedRV := "3"
events := []watch.Event{
{Type: watch.Added, Object: preExisting1},
{Type: watch.Added, Object: preExisting2},
{Type: watch.Bookmark, Object: &v1.Pod{
ObjectMeta: metav1.ObjectMeta{
ResourceVersion: lastExpectedRV,
Annotations: map[string]string{
metav1.InitialEventsAnnotationKey: "true",
},
items: func(rs ReflectorStore) []interface{} {
store := rs.(*RealFIFO)
objects := make(map[string]interface{})
for _, item := range store.getItems() {
key, _ := store.keyFunc(item.Object)
if item.Type == Deleted {
delete(objects, key)
} else {
objects[key] = item.Object
}
}
return slices.Collect(maps.Values(objects))
},
}},
{Type: watch.Added, Object: pod3},
}
s := NewFIFO(MetaNamespaceKeyFunc)
var replaceInvoked atomic.Int32
store := &fakeStore{
Store: s,
beforeReplace: func(list []interface{}, rv string) {
replaceInvoked.Add(1)
// Only two pods are present at the point when Replace is called.
if len(list) != 2 {
t.Errorf("unexpected nb of objects: expected 2 received %d", len(list))
},
"delta-fifo": {
storeBuilder: func(counter *atomic.Int32) ReflectorStore {
return NewDeltaFIFOWithOptions(DeltaFIFOOptions{
KeyFunction: MetaNamespaceKeyFunc,
Transformer: func(i interface{}) (interface{}, error) {
counter.Add(1)
cast := i.(*v1.Pod)
cast.Spec.Hostname = "transformed"
return cast, nil
},
})
},
items: func(rs ReflectorStore) []interface{} {
return rs.(*DeltaFIFO).list()
},
},
} {
t.Run(name, func(t *testing.T) {
mkPod := func(id string, rv string) *v1.Pod {
return &v1.Pod{
ObjectMeta: metav1.ObjectMeta{Namespace: "ns", Name: id, ResourceVersion: rv},
Spec: v1.PodSpec{
Hostname: "test",
},
}
}
for _, obj := range list {
cast := obj.(*v1.Pod)
preExisting1 := mkPod("foo-1", "1")
preExisting2 := mkPod("foo-2", "2")
pod3 := mkPod("foo-3", "3")
lastExpectedRV := "3"
events := []watch.Event{
{Type: watch.Added, Object: preExisting1},
{Type: watch.Added, Object: preExisting2},
{Type: watch.Bookmark, Object: &v1.Pod{
ObjectMeta: metav1.ObjectMeta{
ResourceVersion: lastExpectedRV,
Annotations: map[string]string{
metav1.InitialEventsAnnotationKey: "true",
},
},
}},
{Type: watch.Added, Object: pod3},
}
var transformerInvoked atomic.Int32
s := test.storeBuilder(&transformerInvoked)
var once sync.Once
lw := &ListWatch{
WatchFunc: func(metav1.ListOptions) (watch.Interface, error) {
fw := watch.NewFake()
go func() {
once.Do(func() {
for _, e := range events {
fw.Action(e.Type, e.Object)
}
})
}()
return fw, nil
},
// ListFunc should never be used in WatchList mode
ListFunc: func(metav1.ListOptions) (runtime.Object, error) {
return nil, errors.New("list call not expected in WatchList mode")
},
}
clientfeaturestesting.SetFeatureDuringTest(t, clientfeatures.WatchListClient, true)
r := NewReflector(lw, &v1.Pod{}, s, 0)
ctx, cancel := context.WithCancel(context.Background())
doneCh := make(chan struct{})
go func() {
defer close(doneCh)
r.RunWithContext(ctx)
}()
// wait for the RV to sync to the version returned by the final list
err := wait.PollUntilContextTimeout(context.Background(), 100*time.Millisecond, 5*time.Second, true, func(ctx context.Context) (done bool, err error) {
if rv := r.LastSyncResourceVersion(); rv == lastExpectedRV {
return true, nil
}
return false, nil
})
if err != nil {
t.Fatalf("reflector never caught up with expected revision: %q, err: %v", lastExpectedRV, err)
}
if want, got := lastExpectedRV, r.LastSyncResourceVersion(); want != got {
t.Errorf("expected LastSyncResourceVersion to be %q, but got: %q", want, got)
}
informerItems := test.items(s)
if want, got := 3, len(informerItems); want != got {
t.Errorf("expected informer to contain %d objects, but got: %d", want, got)
}
for _, item := range informerItems {
cast := item.(*v1.Pod)
if cast.Spec.Hostname != "transformed" {
t.Error("Object was not transformed prior to replacement")
}
}
},
afterReplace: func(rv string, err error) {},
transformer: func(i interface{}) (interface{}, error) {
cast := i.(*v1.Pod)
cast.Spec.Hostname = "transformed"
return cast, nil
},
}
var once sync.Once
lw := &ListWatch{
WatchFunc: func(metav1.ListOptions) (watch.Interface, error) {
fw := watch.NewFake()
go func() {
once.Do(func() {
for _, e := range events {
fw.Action(e.Type, e.Object)
}
})
}()
return fw, nil
},
// ListFunc should never be used in WatchList mode
ListFunc: func(metav1.ListOptions) (runtime.Object, error) {
return nil, errors.New("list call not expected in WatchList mode")
},
}
// Transformer should have been invoked twice for the initial sync in the informer on the temporary store,
// then twice on replace, then once on the following update.
if want, got := 5, int(transformerInvoked.Load()); want != got {
t.Errorf("expected transformer to be invoked %d times, but got: %d", want, got)
}
clientfeaturestesting.SetFeatureDuringTest(t, clientfeatures.WatchListClient, true)
r := NewReflector(lw, &v1.Pod{}, store, 0)
ctx, cancel := context.WithCancel(context.Background())
doneCh := make(chan struct{})
go func() {
defer close(doneCh)
r.RunWithContext(ctx)
}()
// wait for the RV to sync to the version returned by the final list
err := wait.PollUntilContextTimeout(context.Background(), 100*time.Millisecond, 5*time.Second, true, func(ctx context.Context) (done bool, err error) {
if rv := r.LastSyncResourceVersion(); rv == lastExpectedRV {
return true, nil
}
return false, nil
})
if err != nil {
t.Fatalf("reflector never caught up with expected revision: %q, err: %v", lastExpectedRV, err)
}
if want, got := lastExpectedRV, r.LastSyncResourceVersion(); want != got {
t.Errorf("expected LastSyncResourceVersion to be %q, but got: %q", want, got)
}
if want, got := 1, int(replaceInvoked.Load()); want != got {
t.Errorf("expected replace to be invoked %d times, but got: %d", want, got)
}
cancel()
select {
case <-doneCh:
case <-time.After(wait.ForeverTestTimeout):
t.Errorf("timed out waiting for Run to return")
cancel()
select {
case <-doneCh:
case <-time.After(wait.ForeverTestTimeout):
t.Errorf("timed out waiting for Run to return")
}
})
}
}
type fakeStore struct {
Store
ReflectorStore
beforeReplace func(list []interface{}, s string)
afterReplace func(rv string, err error)
transformer TransformFunc
}
func (f *fakeStore) Replace(list []interface{}, rv string) error {
f.beforeReplace(list, rv)
err := f.Store.Replace(list, rv)
err := f.ReflectorStore.Replace(list, rv)
f.afterReplace(rv, err)
return err
}
func (f *fakeStore) Transformer() TransformFunc {
return f.transformer
}
func BenchmarkExtractList(b *testing.B) {
_, _, podList := getPodListItems(0, fakeItemsNum)
_, _, configMapList := getConfigmapListItems(0, fakeItemsNum)

View File

@@ -539,16 +539,7 @@ func (s *sharedIndexInformer) RunWithContext(ctx context.Context) {
s.startedLock.Lock()
defer s.startedLock.Unlock()
var fifo Queue
if clientgofeaturegate.FeatureGates().Enabled(clientgofeaturegate.InOrderInformers) {
fifo = NewRealFIFO(MetaNamespaceKeyFunc, s.indexer, s.transform)
} else {
fifo = NewDeltaFIFOWithOptions(DeltaFIFOOptions{
KnownObjects: s.indexer,
EmitDeltaTypeReplaced: true,
Transformer: s.transform,
})
}
fifo := newQueueFIFO(s.indexer, s.transform)
cfg := &Config{
Queue: fifo,

View File

@@ -61,7 +61,8 @@ type RealFIFO struct {
}
var (
_ = Queue(&RealFIFO{}) // RealFIFO is a Queue
_ = Queue(&RealFIFO{}) // RealFIFO is a Queue
_ = TransformingStore(&RealFIFO{}) // RealFIFO implements TransformingStore to allow memory optimizations
)
// Close the queue.

View File

@@ -77,6 +77,9 @@ func (ll *LeaseLock) Update(ctx context.Context, ler LeaderElectionRecord) error
ll.lease.Spec = LeaderElectionRecordToLeaseSpec(&ler)
if ll.Labels != nil {
if ll.lease.Labels == nil {
ll.lease.Labels = map[string]string{}
}
// Only overwrite the labels that are specifically set
for k, v := range ll.Labels {
ll.lease.Labels[k] = v

View File

@@ -266,7 +266,7 @@ func TestLeaseConversion(t *testing.T) {
}
}
func TestUpdateWithNilLabels(t *testing.T) {
func TestUpdateWithNilLabelsOnLease(t *testing.T) {
setup()
// Create initial lease
@@ -278,23 +278,33 @@ func TestUpdateWithNilLabels(t *testing.T) {
t.Fatalf("Failed to get lease: %v", err)
}
leaseLock.lease.Labels = nil
leaseLock.Labels = map[string]string{"custom-key": "custom-val"}
// Update should succeed even with nil Labels on the lease itself
if err := leaseLock.Update(context.Background(), testRecord); err != nil {
t.Errorf("Update failed with nil Labels: %v", err)
}
}
func TestUpdateWithNilLabelsOnLeaseLock(t *testing.T) {
setup()
// Create initial lease
if err := leaseLock.Create(context.Background(), testRecord); err != nil {
t.Fatalf("Failed to create lease: %v", err)
}
// Get the lease to initialize leaseLock.lease
if _, _, err := leaseLock.Get(context.Background()); err != nil {
t.Fatalf("Failed to get lease: %v", err)
}
leaseLock.Labels = nil
leaseLock.lease.Labels = map[string]string{"custom-key": "custom-val"}
// Update labels
lease, err := leaseLock.Client.Leases(testNamespace).Update(context.Background(), leaseLock.lease, metav1.UpdateOptions{})
if err != nil {
t.Fatalf("Failed to update lease labels: %v", err)
}
val, exists := lease.Labels["custom-key"]
if !exists {
t.Error("Label was overidden on the lease")
}
if val != "custom-val" {
t.Errorf("Label value mismatch, got %q want %q", val, "custom-val")
}
// Update should succeed even with nil Labels
// Update should succeed even with nil Labels on the leaselock
if err := leaseLock.Update(context.Background(), testRecord); err != nil {
t.Errorf("Update failed with nil Labels: %v", err)
}

View File

@@ -75,13 +75,15 @@ func NewSelfSignedCACert(cfg Config, key crypto.Signer) (*x509.Certificate, erro
CommonName: cfg.CommonName,
Organization: cfg.Organization,
},
DNSNames: []string{cfg.CommonName},
NotBefore: notBefore,
NotAfter: now.Add(duration365d * 10).UTC(),
KeyUsage: x509.KeyUsageKeyEncipherment | x509.KeyUsageDigitalSignature | x509.KeyUsageCertSign,
BasicConstraintsValid: true,
IsCA: true,
}
if len(cfg.CommonName) > 0 {
tmpl.DNSNames = []string{cfg.CommonName}
}
certDERBytes, err := x509.CreateCertificate(cryptorand.Reader, &tmpl, &tmpl, key.Public(), key)
if err != nil {

View File

@@ -45,16 +45,28 @@ func IsDataConsistencyDetectionForWatchListEnabled() bool {
return dataConsistencyDetectionForWatchListEnabled
}
// SetDataConsistencyDetectionForWatchListEnabledForTest allows to enable/disable data consistency detection for testing purposes.
// It returns a function that restores the original value.
func SetDataConsistencyDetectionForWatchListEnabledForTest(enabled bool) func() {
original := dataConsistencyDetectionForWatchListEnabled
dataConsistencyDetectionForWatchListEnabled = enabled
return func() {
dataConsistencyDetectionForWatchListEnabled = original
}
}
type RetrieveItemsFunc[U any] func() []U
type ListFunc[T runtime.Object] func(ctx context.Context, options metav1.ListOptions) (T, error)
type TransformFunc func(interface{}) (interface{}, error)
// CheckDataConsistency exists solely for testing purposes.
// we cannot use checkWatchListDataConsistencyIfRequested because
// it is guarded by an environmental variable.
// we cannot manipulate the environmental variable because
// it will affect other tests in this package.
func CheckDataConsistency[T runtime.Object, U any](ctx context.Context, identity string, lastSyncedResourceVersion string, listFn ListFunc[T], listOptions metav1.ListOptions, retrieveItemsFn RetrieveItemsFunc[U]) {
func CheckDataConsistency[T runtime.Object, U any](ctx context.Context, identity string, lastSyncedResourceVersion string, listFn ListFunc[T], listItemTransformFunc TransformFunc, listOptions metav1.ListOptions, retrieveItemsFn RetrieveItemsFunc[U]) {
if !canFormAdditionalListCall(lastSyncedResourceVersion, listOptions) {
klog.V(4).Infof("data consistency check for %s is enabled but the parameters (RV, ListOptions) doesn't allow for creating a valid LIST request. Skipping the data consistency check.", identity)
return
@@ -84,6 +96,15 @@ func CheckDataConsistency[T runtime.Object, U any](ctx context.Context, identity
if err != nil {
panic(err) // this should never happen
}
if listItemTransformFunc != nil {
for i := range rawListItems {
obj, err := listItemTransformFunc(rawListItems[i])
if err != nil {
panic(err)
}
rawListItems[i] = obj.(runtime.Object)
}
}
listItems := toMetaObjectSliceOrDie(rawListItems)
sort.Sort(byUID(listItems))

View File

@@ -215,10 +215,10 @@ func TestDataConsistencyChecker(t *testing.T) {
if scenario.expectPanic {
require.Panics(t, func() {
CheckDataConsistency(ctx, "", scenario.lastSyncedResourceVersion, fakeLister.List, scenario.requestOptions, retrievedItemsFunc)
CheckDataConsistency(ctx, "", scenario.lastSyncedResourceVersion, fakeLister.List, nil, scenario.requestOptions, retrievedItemsFunc)
})
} else {
CheckDataConsistency(ctx, "", scenario.lastSyncedResourceVersion, fakeLister.List, scenario.requestOptions, retrievedItemsFunc)
CheckDataConsistency(ctx, "", scenario.lastSyncedResourceVersion, fakeLister.List, nil, scenario.requestOptions, retrievedItemsFunc)
}
require.Equal(t, scenario.expectedListRequests, fakeLister.counter)
@@ -235,7 +235,7 @@ func TestDataConsistencyCheckerRetry(t *testing.T) {
stopListErrorAfter := 5
fakeErrLister := &errorLister{stopErrorAfter: stopListErrorAfter}
CheckDataConsistency(ctx, "", "", fakeErrLister.List, metav1.ListOptions{}, retrievedItemsFunc)
CheckDataConsistency(ctx, "", "", fakeErrLister.List, nil, metav1.ListOptions{}, retrievedItemsFunc)
require.Equal(t, fakeErrLister.listCounter, fakeErrLister.stopErrorAfter)
}