mirror of
https://github.com/kubernetes/client-go.git
synced 2025-07-13 15:04:07 +00:00
Merge pull request #130291 from Jefftree/cle-beta
LeaseCandidate v1beta1 API Kubernetes-commit: ef1c659569409471b4bdfeb83ba69cb1772ed37d
This commit is contained in:
commit
ebce4d7b9d
255
applyconfigurations/coordination/v1beta1/leasecandidate.go
Normal file
255
applyconfigurations/coordination/v1beta1/leasecandidate.go
Normal file
@ -0,0 +1,255 @@
|
||||
/*
|
||||
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 (
|
||||
coordinationv1beta1 "k8s.io/api/coordination/v1beta1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
types "k8s.io/apimachinery/pkg/types"
|
||||
managedfields "k8s.io/apimachinery/pkg/util/managedfields"
|
||||
internal "k8s.io/client-go/applyconfigurations/internal"
|
||||
v1 "k8s.io/client-go/applyconfigurations/meta/v1"
|
||||
)
|
||||
|
||||
// LeaseCandidateApplyConfiguration represents a declarative configuration of the LeaseCandidate type for use
|
||||
// with apply.
|
||||
type LeaseCandidateApplyConfiguration struct {
|
||||
v1.TypeMetaApplyConfiguration `json:",inline"`
|
||||
*v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"`
|
||||
Spec *LeaseCandidateSpecApplyConfiguration `json:"spec,omitempty"`
|
||||
}
|
||||
|
||||
// LeaseCandidate constructs a declarative configuration of the LeaseCandidate type for use with
|
||||
// apply.
|
||||
func LeaseCandidate(name, namespace string) *LeaseCandidateApplyConfiguration {
|
||||
b := &LeaseCandidateApplyConfiguration{}
|
||||
b.WithName(name)
|
||||
b.WithNamespace(namespace)
|
||||
b.WithKind("LeaseCandidate")
|
||||
b.WithAPIVersion("coordination.k8s.io/v1beta1")
|
||||
return b
|
||||
}
|
||||
|
||||
// ExtractLeaseCandidate extracts the applied configuration owned by fieldManager from
|
||||
// leaseCandidate. If no managedFields are found in leaseCandidate for fieldManager, a
|
||||
// LeaseCandidateApplyConfiguration is returned with only the Name, Namespace (if applicable),
|
||||
// APIVersion and Kind populated. It is possible that no managed fields were found for because other
|
||||
// field managers have taken ownership of all the fields previously owned by fieldManager, or because
|
||||
// the fieldManager never owned fields any fields.
|
||||
// leaseCandidate must be a unmodified LeaseCandidate API object that was retrieved from the Kubernetes API.
|
||||
// ExtractLeaseCandidate provides a way to perform a extract/modify-in-place/apply workflow.
|
||||
// Note that an extracted apply configuration will contain fewer fields than what the fieldManager previously
|
||||
// applied if another fieldManager has updated or force applied any of the previously applied fields.
|
||||
// Experimental!
|
||||
func ExtractLeaseCandidate(leaseCandidate *coordinationv1beta1.LeaseCandidate, fieldManager string) (*LeaseCandidateApplyConfiguration, error) {
|
||||
return extractLeaseCandidate(leaseCandidate, fieldManager, "")
|
||||
}
|
||||
|
||||
// ExtractLeaseCandidateStatus is the same as ExtractLeaseCandidate except
|
||||
// that it extracts the status subresource applied configuration.
|
||||
// Experimental!
|
||||
func ExtractLeaseCandidateStatus(leaseCandidate *coordinationv1beta1.LeaseCandidate, fieldManager string) (*LeaseCandidateApplyConfiguration, error) {
|
||||
return extractLeaseCandidate(leaseCandidate, fieldManager, "status")
|
||||
}
|
||||
|
||||
func extractLeaseCandidate(leaseCandidate *coordinationv1beta1.LeaseCandidate, fieldManager string, subresource string) (*LeaseCandidateApplyConfiguration, error) {
|
||||
b := &LeaseCandidateApplyConfiguration{}
|
||||
err := managedfields.ExtractInto(leaseCandidate, internal.Parser().Type("io.k8s.api.coordination.v1beta1.LeaseCandidate"), fieldManager, b, subresource)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
b.WithName(leaseCandidate.Name)
|
||||
b.WithNamespace(leaseCandidate.Namespace)
|
||||
|
||||
b.WithKind("LeaseCandidate")
|
||||
b.WithAPIVersion("coordination.k8s.io/v1beta1")
|
||||
return b, nil
|
||||
}
|
||||
|
||||
// WithKind sets the Kind field in the declarative configuration to the given value
|
||||
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||
// If called multiple times, the Kind field is set to the value of the last call.
|
||||
func (b *LeaseCandidateApplyConfiguration) WithKind(value string) *LeaseCandidateApplyConfiguration {
|
||||
b.TypeMetaApplyConfiguration.Kind = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithAPIVersion sets the APIVersion field in the declarative configuration to the given value
|
||||
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||
// If called multiple times, the APIVersion field is set to the value of the last call.
|
||||
func (b *LeaseCandidateApplyConfiguration) WithAPIVersion(value string) *LeaseCandidateApplyConfiguration {
|
||||
b.TypeMetaApplyConfiguration.APIVersion = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithName sets the Name field in the declarative configuration to the given value
|
||||
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||
// If called multiple times, the Name field is set to the value of the last call.
|
||||
func (b *LeaseCandidateApplyConfiguration) WithName(value string) *LeaseCandidateApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
b.ObjectMetaApplyConfiguration.Name = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithGenerateName sets the GenerateName field in the declarative configuration to the given value
|
||||
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||
// If called multiple times, the GenerateName field is set to the value of the last call.
|
||||
func (b *LeaseCandidateApplyConfiguration) WithGenerateName(value string) *LeaseCandidateApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
b.ObjectMetaApplyConfiguration.GenerateName = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithNamespace sets the Namespace field in the declarative configuration to the given value
|
||||
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||
// If called multiple times, the Namespace field is set to the value of the last call.
|
||||
func (b *LeaseCandidateApplyConfiguration) WithNamespace(value string) *LeaseCandidateApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
b.ObjectMetaApplyConfiguration.Namespace = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithUID sets the UID field in the declarative configuration to the given value
|
||||
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||
// If called multiple times, the UID field is set to the value of the last call.
|
||||
func (b *LeaseCandidateApplyConfiguration) WithUID(value types.UID) *LeaseCandidateApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
b.ObjectMetaApplyConfiguration.UID = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithResourceVersion sets the ResourceVersion field in the declarative configuration to the given value
|
||||
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||
// If called multiple times, the ResourceVersion field is set to the value of the last call.
|
||||
func (b *LeaseCandidateApplyConfiguration) WithResourceVersion(value string) *LeaseCandidateApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
b.ObjectMetaApplyConfiguration.ResourceVersion = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithGeneration sets the Generation field in the declarative configuration to the given value
|
||||
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||
// If called multiple times, the Generation field is set to the value of the last call.
|
||||
func (b *LeaseCandidateApplyConfiguration) WithGeneration(value int64) *LeaseCandidateApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
b.ObjectMetaApplyConfiguration.Generation = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithCreationTimestamp sets the CreationTimestamp field in the declarative configuration to the given value
|
||||
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||
// If called multiple times, the CreationTimestamp field is set to the value of the last call.
|
||||
func (b *LeaseCandidateApplyConfiguration) WithCreationTimestamp(value metav1.Time) *LeaseCandidateApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
b.ObjectMetaApplyConfiguration.CreationTimestamp = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithDeletionTimestamp sets the DeletionTimestamp field in the declarative configuration to the given value
|
||||
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||
// If called multiple times, the DeletionTimestamp field is set to the value of the last call.
|
||||
func (b *LeaseCandidateApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *LeaseCandidateApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
b.ObjectMetaApplyConfiguration.DeletionTimestamp = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithDeletionGracePeriodSeconds sets the DeletionGracePeriodSeconds field in the declarative configuration to the given value
|
||||
// and returns the receiver, so that objects can be built by chaining "With" function invocations.
|
||||
// If called multiple times, the DeletionGracePeriodSeconds field is set to the value of the last call.
|
||||
func (b *LeaseCandidateApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *LeaseCandidateApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
b.ObjectMetaApplyConfiguration.DeletionGracePeriodSeconds = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithLabels puts the entries into the Labels field in the declarative configuration
|
||||
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
|
||||
// If called multiple times, the entries provided by each call will be put on the Labels field,
|
||||
// overwriting an existing map entries in Labels field with the same key.
|
||||
func (b *LeaseCandidateApplyConfiguration) WithLabels(entries map[string]string) *LeaseCandidateApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
if b.ObjectMetaApplyConfiguration.Labels == nil && len(entries) > 0 {
|
||||
b.ObjectMetaApplyConfiguration.Labels = make(map[string]string, len(entries))
|
||||
}
|
||||
for k, v := range entries {
|
||||
b.ObjectMetaApplyConfiguration.Labels[k] = v
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
// WithAnnotations puts the entries into the Annotations field in the declarative configuration
|
||||
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
|
||||
// If called multiple times, the entries provided by each call will be put on the Annotations field,
|
||||
// overwriting an existing map entries in Annotations field with the same key.
|
||||
func (b *LeaseCandidateApplyConfiguration) WithAnnotations(entries map[string]string) *LeaseCandidateApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
if b.ObjectMetaApplyConfiguration.Annotations == nil && len(entries) > 0 {
|
||||
b.ObjectMetaApplyConfiguration.Annotations = make(map[string]string, len(entries))
|
||||
}
|
||||
for k, v := range entries {
|
||||
b.ObjectMetaApplyConfiguration.Annotations[k] = v
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
// WithOwnerReferences adds the given value to the OwnerReferences field in the declarative configuration
|
||||
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
|
||||
// If called multiple times, values provided by each call will be appended to the OwnerReferences field.
|
||||
func (b *LeaseCandidateApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *LeaseCandidateApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
for i := range values {
|
||||
if values[i] == nil {
|
||||
panic("nil value passed to WithOwnerReferences")
|
||||
}
|
||||
b.ObjectMetaApplyConfiguration.OwnerReferences = append(b.ObjectMetaApplyConfiguration.OwnerReferences, *values[i])
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
// WithFinalizers adds the given value to the Finalizers field in the declarative configuration
|
||||
// and returns the receiver, so that objects can be build by chaining "With" function invocations.
|
||||
// If called multiple times, values provided by each call will be appended to the Finalizers field.
|
||||
func (b *LeaseCandidateApplyConfiguration) WithFinalizers(values ...string) *LeaseCandidateApplyConfiguration {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
for i := range values {
|
||||
b.ObjectMetaApplyConfiguration.Finalizers = append(b.ObjectMetaApplyConfiguration.Finalizers, values[i])
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func (b *LeaseCandidateApplyConfiguration) ensureObjectMetaApplyConfigurationExists() {
|
||||
if b.ObjectMetaApplyConfiguration == nil {
|
||||
b.ObjectMetaApplyConfiguration = &v1.ObjectMetaApplyConfiguration{}
|
||||
}
|
||||
}
|
||||
|
||||
// WithSpec sets the Spec 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 Spec field is set to the value of the last call.
|
||||
func (b *LeaseCandidateApplyConfiguration) WithSpec(value *LeaseCandidateSpecApplyConfiguration) *LeaseCandidateApplyConfiguration {
|
||||
b.Spec = value
|
||||
return b
|
||||
}
|
||||
|
||||
// GetName retrieves the value of the Name field in the declarative configuration.
|
||||
func (b *LeaseCandidateApplyConfiguration) GetName() *string {
|
||||
b.ensureObjectMetaApplyConfigurationExists()
|
||||
return b.ObjectMetaApplyConfiguration.Name
|
||||
}
|
@ -0,0 +1,89 @@
|
||||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by applyconfiguration-gen. DO NOT EDIT.
|
||||
|
||||
package v1beta1
|
||||
|
||||
import (
|
||||
coordinationv1 "k8s.io/api/coordination/v1"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
)
|
||||
|
||||
// LeaseCandidateSpecApplyConfiguration represents a declarative configuration of the LeaseCandidateSpec type for use
|
||||
// with apply.
|
||||
type LeaseCandidateSpecApplyConfiguration struct {
|
||||
LeaseName *string `json:"leaseName,omitempty"`
|
||||
PingTime *v1.MicroTime `json:"pingTime,omitempty"`
|
||||
RenewTime *v1.MicroTime `json:"renewTime,omitempty"`
|
||||
BinaryVersion *string `json:"binaryVersion,omitempty"`
|
||||
EmulationVersion *string `json:"emulationVersion,omitempty"`
|
||||
Strategy *coordinationv1.CoordinatedLeaseStrategy `json:"strategy,omitempty"`
|
||||
}
|
||||
|
||||
// LeaseCandidateSpecApplyConfiguration constructs a declarative configuration of the LeaseCandidateSpec type for use with
|
||||
// apply.
|
||||
func LeaseCandidateSpec() *LeaseCandidateSpecApplyConfiguration {
|
||||
return &LeaseCandidateSpecApplyConfiguration{}
|
||||
}
|
||||
|
||||
// WithLeaseName sets the LeaseName 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 LeaseName field is set to the value of the last call.
|
||||
func (b *LeaseCandidateSpecApplyConfiguration) WithLeaseName(value string) *LeaseCandidateSpecApplyConfiguration {
|
||||
b.LeaseName = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithPingTime sets the PingTime 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 PingTime field is set to the value of the last call.
|
||||
func (b *LeaseCandidateSpecApplyConfiguration) WithPingTime(value v1.MicroTime) *LeaseCandidateSpecApplyConfiguration {
|
||||
b.PingTime = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithRenewTime sets the RenewTime 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 RenewTime field is set to the value of the last call.
|
||||
func (b *LeaseCandidateSpecApplyConfiguration) WithRenewTime(value v1.MicroTime) *LeaseCandidateSpecApplyConfiguration {
|
||||
b.RenewTime = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithBinaryVersion sets the BinaryVersion 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 BinaryVersion field is set to the value of the last call.
|
||||
func (b *LeaseCandidateSpecApplyConfiguration) WithBinaryVersion(value string) *LeaseCandidateSpecApplyConfiguration {
|
||||
b.BinaryVersion = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithEmulationVersion sets the EmulationVersion 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 EmulationVersion field is set to the value of the last call.
|
||||
func (b *LeaseCandidateSpecApplyConfiguration) WithEmulationVersion(value string) *LeaseCandidateSpecApplyConfiguration {
|
||||
b.EmulationVersion = &value
|
||||
return b
|
||||
}
|
||||
|
||||
// WithStrategy sets the Strategy 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 Strategy field is set to the value of the last call.
|
||||
func (b *LeaseCandidateSpecApplyConfiguration) WithStrategy(value coordinationv1.CoordinatedLeaseStrategy) *LeaseCandidateSpecApplyConfiguration {
|
||||
b.Strategy = &value
|
||||
return b
|
||||
}
|
@ -4543,6 +4543,46 @@ var schemaYAML = typed.YAMLObject(`types:
|
||||
type:
|
||||
namedType: io.k8s.api.coordination.v1beta1.LeaseSpec
|
||||
default: {}
|
||||
- name: io.k8s.api.coordination.v1beta1.LeaseCandidate
|
||||
map:
|
||||
fields:
|
||||
- name: apiVersion
|
||||
type:
|
||||
scalar: string
|
||||
- name: kind
|
||||
type:
|
||||
scalar: string
|
||||
- name: metadata
|
||||
type:
|
||||
namedType: io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta
|
||||
default: {}
|
||||
- name: spec
|
||||
type:
|
||||
namedType: io.k8s.api.coordination.v1beta1.LeaseCandidateSpec
|
||||
default: {}
|
||||
- name: io.k8s.api.coordination.v1beta1.LeaseCandidateSpec
|
||||
map:
|
||||
fields:
|
||||
- name: binaryVersion
|
||||
type:
|
||||
scalar: string
|
||||
default: ""
|
||||
- name: emulationVersion
|
||||
type:
|
||||
scalar: string
|
||||
- name: leaseName
|
||||
type:
|
||||
scalar: string
|
||||
default: ""
|
||||
- name: pingTime
|
||||
type:
|
||||
namedType: io.k8s.apimachinery.pkg.apis.meta.v1.MicroTime
|
||||
- name: renewTime
|
||||
type:
|
||||
namedType: io.k8s.apimachinery.pkg.apis.meta.v1.MicroTime
|
||||
- name: strategy
|
||||
type:
|
||||
scalar: string
|
||||
- name: io.k8s.api.coordination.v1beta1.LeaseSpec
|
||||
map:
|
||||
fields:
|
||||
|
@ -640,6 +640,10 @@ func ForKind(kind schema.GroupVersionKind) interface{} {
|
||||
// Group=coordination.k8s.io, Version=v1beta1
|
||||
case coordinationv1beta1.SchemeGroupVersion.WithKind("Lease"):
|
||||
return &applyconfigurationscoordinationv1beta1.LeaseApplyConfiguration{}
|
||||
case coordinationv1beta1.SchemeGroupVersion.WithKind("LeaseCandidate"):
|
||||
return &applyconfigurationscoordinationv1beta1.LeaseCandidateApplyConfiguration{}
|
||||
case coordinationv1beta1.SchemeGroupVersion.WithKind("LeaseCandidateSpec"):
|
||||
return &applyconfigurationscoordinationv1beta1.LeaseCandidateSpecApplyConfiguration{}
|
||||
case coordinationv1beta1.SchemeGroupVersion.WithKind("LeaseSpec"):
|
||||
return &applyconfigurationscoordinationv1beta1.LeaseSpecApplyConfiguration{}
|
||||
|
||||
|
2
go.mod
2
go.mod
@ -26,7 +26,7 @@ require (
|
||||
golang.org/x/time v0.7.0
|
||||
google.golang.org/protobuf v1.35.1
|
||||
gopkg.in/evanphx/json-patch.v4 v4.12.0
|
||||
k8s.io/api v0.0.0-20250227200351-c3130ba7ba23
|
||||
k8s.io/api v0.0.0-20250228200347-59273a85c4d5
|
||||
k8s.io/apimachinery v0.0.0-20250228120110-6c5685cb7e7d
|
||||
k8s.io/klog/v2 v2.130.1
|
||||
k8s.io/kube-openapi v0.0.0-20241212222426-2c72e554b1e7
|
||||
|
4
go.sum
4
go.sum
@ -148,8 +148,8 @@ 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-20250227200351-c3130ba7ba23 h1:qxms/NcuxDW3w5QnzZFb0YR9QoXhba9rH9JIEBGNDL8=
|
||||
k8s.io/api v0.0.0-20250227200351-c3130ba7ba23/go.mod h1:Kvi7dp+zOd5JPEKkKGEkIQVDxZb85TzOfJHvYpqXOAg=
|
||||
k8s.io/api v0.0.0-20250228200347-59273a85c4d5 h1:/bOsw4v/x0zPVygS2ZPGqRq4D+PlFPduyiufg1FbbUk=
|
||||
k8s.io/api v0.0.0-20250228200347-59273a85c4d5/go.mod h1:vR4QeI4oiyaYKCCOzErtqBrY6tekwTisojr4Ge4Q1hA=
|
||||
k8s.io/apimachinery v0.0.0-20250228120110-6c5685cb7e7d h1:OcgjnFuM8CeOg89nHuCFBQWvL7q0LUrlMxKelamYIYU=
|
||||
k8s.io/apimachinery v0.0.0-20250228120110-6c5685cb7e7d/go.mod h1:861nWA3UpwBXwcIu/k1v7qBnpTrlpPJM9iEX4nngAj8=
|
||||
k8s.io/klog/v2 v2.130.1 h1:n9Xl7H1Xvksem4KFG4PYbdQCQxqc/tTUyrgXaOhHSzk=
|
||||
|
@ -26,6 +26,8 @@ import (
|
||||
type Interface interface {
|
||||
// Leases returns a LeaseInformer.
|
||||
Leases() LeaseInformer
|
||||
// LeaseCandidates returns a LeaseCandidateInformer.
|
||||
LeaseCandidates() LeaseCandidateInformer
|
||||
}
|
||||
|
||||
type version struct {
|
||||
@ -43,3 +45,8 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList
|
||||
func (v *version) Leases() LeaseInformer {
|
||||
return &leaseInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
|
||||
}
|
||||
|
||||
// LeaseCandidates returns a LeaseCandidateInformer.
|
||||
func (v *version) LeaseCandidates() LeaseCandidateInformer {
|
||||
return &leaseCandidateInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions}
|
||||
}
|
||||
|
102
informers/coordination/v1beta1/leasecandidate.go
Normal file
102
informers/coordination/v1beta1/leasecandidate.go
Normal file
@ -0,0 +1,102 @@
|
||||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by informer-gen. DO NOT EDIT.
|
||||
|
||||
package v1beta1
|
||||
|
||||
import (
|
||||
context "context"
|
||||
time "time"
|
||||
|
||||
apicoordinationv1beta1 "k8s.io/api/coordination/v1beta1"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
runtime "k8s.io/apimachinery/pkg/runtime"
|
||||
watch "k8s.io/apimachinery/pkg/watch"
|
||||
internalinterfaces "k8s.io/client-go/informers/internalinterfaces"
|
||||
kubernetes "k8s.io/client-go/kubernetes"
|
||||
coordinationv1beta1 "k8s.io/client-go/listers/coordination/v1beta1"
|
||||
cache "k8s.io/client-go/tools/cache"
|
||||
)
|
||||
|
||||
// LeaseCandidateInformer provides access to a shared informer and lister for
|
||||
// LeaseCandidates.
|
||||
type LeaseCandidateInformer interface {
|
||||
Informer() cache.SharedIndexInformer
|
||||
Lister() coordinationv1beta1.LeaseCandidateLister
|
||||
}
|
||||
|
||||
type leaseCandidateInformer struct {
|
||||
factory internalinterfaces.SharedInformerFactory
|
||||
tweakListOptions internalinterfaces.TweakListOptionsFunc
|
||||
namespace string
|
||||
}
|
||||
|
||||
// NewLeaseCandidateInformer constructs a new informer for LeaseCandidate type.
|
||||
// Always prefer using an informer factory to get a shared informer instead of getting an independent
|
||||
// one. This reduces memory footprint and number of connections to the server.
|
||||
func NewLeaseCandidateInformer(client kubernetes.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer {
|
||||
return NewFilteredLeaseCandidateInformer(client, namespace, resyncPeriod, indexers, nil)
|
||||
}
|
||||
|
||||
// NewFilteredLeaseCandidateInformer constructs a new informer for LeaseCandidate type.
|
||||
// Always prefer using an informer factory to get a shared informer instead of getting an independent
|
||||
// one. This reduces memory footprint and number of connections to the server.
|
||||
func NewFilteredLeaseCandidateInformer(client kubernetes.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers, tweakListOptions internalinterfaces.TweakListOptionsFunc) cache.SharedIndexInformer {
|
||||
return cache.NewSharedIndexInformer(
|
||||
&cache.ListWatch{
|
||||
ListFunc: func(options v1.ListOptions) (runtime.Object, error) {
|
||||
if tweakListOptions != nil {
|
||||
tweakListOptions(&options)
|
||||
}
|
||||
return client.CoordinationV1beta1().LeaseCandidates(namespace).List(context.Background(), options)
|
||||
},
|
||||
WatchFunc: func(options v1.ListOptions) (watch.Interface, error) {
|
||||
if tweakListOptions != nil {
|
||||
tweakListOptions(&options)
|
||||
}
|
||||
return client.CoordinationV1beta1().LeaseCandidates(namespace).Watch(context.Background(), options)
|
||||
},
|
||||
ListWithContextFunc: func(ctx context.Context, options v1.ListOptions) (runtime.Object, error) {
|
||||
if tweakListOptions != nil {
|
||||
tweakListOptions(&options)
|
||||
}
|
||||
return client.CoordinationV1beta1().LeaseCandidates(namespace).List(ctx, options)
|
||||
},
|
||||
WatchFuncWithContext: func(ctx context.Context, options v1.ListOptions) (watch.Interface, error) {
|
||||
if tweakListOptions != nil {
|
||||
tweakListOptions(&options)
|
||||
}
|
||||
return client.CoordinationV1beta1().LeaseCandidates(namespace).Watch(ctx, options)
|
||||
},
|
||||
},
|
||||
&apicoordinationv1beta1.LeaseCandidate{},
|
||||
resyncPeriod,
|
||||
indexers,
|
||||
)
|
||||
}
|
||||
|
||||
func (f *leaseCandidateInformer) defaultInformer(client kubernetes.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer {
|
||||
return NewFilteredLeaseCandidateInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions)
|
||||
}
|
||||
|
||||
func (f *leaseCandidateInformer) Informer() cache.SharedIndexInformer {
|
||||
return f.factory.InformerFor(&apicoordinationv1beta1.LeaseCandidate{}, f.defaultInformer)
|
||||
}
|
||||
|
||||
func (f *leaseCandidateInformer) Lister() coordinationv1beta1.LeaseCandidateLister {
|
||||
return coordinationv1beta1.NewLeaseCandidateLister(f.Informer().GetIndexer())
|
||||
}
|
@ -211,6 +211,8 @@ func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource
|
||||
// Group=coordination.k8s.io, Version=v1beta1
|
||||
case coordinationv1beta1.SchemeGroupVersion.WithResource("leases"):
|
||||
return &genericInformer{resource: resource.GroupResource(), informer: f.Coordination().V1beta1().Leases().Informer()}, nil
|
||||
case coordinationv1beta1.SchemeGroupVersion.WithResource("leasecandidates"):
|
||||
return &genericInformer{resource: resource.GroupResource(), informer: f.Coordination().V1beta1().LeaseCandidates().Informer()}, nil
|
||||
|
||||
// Group=core, Version=v1
|
||||
case corev1.SchemeGroupVersion.WithResource("componentstatuses"):
|
||||
|
@ -29,6 +29,7 @@ import (
|
||||
type CoordinationV1beta1Interface interface {
|
||||
RESTClient() rest.Interface
|
||||
LeasesGetter
|
||||
LeaseCandidatesGetter
|
||||
}
|
||||
|
||||
// CoordinationV1beta1Client is used to interact with features provided by the coordination.k8s.io group.
|
||||
@ -40,6 +41,10 @@ func (c *CoordinationV1beta1Client) Leases(namespace string) LeaseInterface {
|
||||
return newLeases(c, namespace)
|
||||
}
|
||||
|
||||
func (c *CoordinationV1beta1Client) LeaseCandidates(namespace string) LeaseCandidateInterface {
|
||||
return newLeaseCandidates(c, namespace)
|
||||
}
|
||||
|
||||
// NewForConfig creates a new CoordinationV1beta1Client for the given config.
|
||||
// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient),
|
||||
// where httpClient was generated with rest.HTTPClientFor(c).
|
||||
|
@ -32,6 +32,10 @@ func (c *FakeCoordinationV1beta1) Leases(namespace string) v1beta1.LeaseInterfac
|
||||
return newFakeLeases(c, namespace)
|
||||
}
|
||||
|
||||
func (c *FakeCoordinationV1beta1) LeaseCandidates(namespace string) v1beta1.LeaseCandidateInterface {
|
||||
return newFakeLeaseCandidates(c, namespace)
|
||||
}
|
||||
|
||||
// RESTClient returns a RESTClient that is used to communicate
|
||||
// with API server by this client implementation.
|
||||
func (c *FakeCoordinationV1beta1) RESTClient() rest.Interface {
|
||||
|
@ -0,0 +1,53 @@
|
||||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by client-gen. DO NOT EDIT.
|
||||
|
||||
package fake
|
||||
|
||||
import (
|
||||
v1beta1 "k8s.io/api/coordination/v1beta1"
|
||||
coordinationv1beta1 "k8s.io/client-go/applyconfigurations/coordination/v1beta1"
|
||||
gentype "k8s.io/client-go/gentype"
|
||||
typedcoordinationv1beta1 "k8s.io/client-go/kubernetes/typed/coordination/v1beta1"
|
||||
)
|
||||
|
||||
// fakeLeaseCandidates implements LeaseCandidateInterface
|
||||
type fakeLeaseCandidates struct {
|
||||
*gentype.FakeClientWithListAndApply[*v1beta1.LeaseCandidate, *v1beta1.LeaseCandidateList, *coordinationv1beta1.LeaseCandidateApplyConfiguration]
|
||||
Fake *FakeCoordinationV1beta1
|
||||
}
|
||||
|
||||
func newFakeLeaseCandidates(fake *FakeCoordinationV1beta1, namespace string) typedcoordinationv1beta1.LeaseCandidateInterface {
|
||||
return &fakeLeaseCandidates{
|
||||
gentype.NewFakeClientWithListAndApply[*v1beta1.LeaseCandidate, *v1beta1.LeaseCandidateList, *coordinationv1beta1.LeaseCandidateApplyConfiguration](
|
||||
fake.Fake,
|
||||
namespace,
|
||||
v1beta1.SchemeGroupVersion.WithResource("leasecandidates"),
|
||||
v1beta1.SchemeGroupVersion.WithKind("LeaseCandidate"),
|
||||
func() *v1beta1.LeaseCandidate { return &v1beta1.LeaseCandidate{} },
|
||||
func() *v1beta1.LeaseCandidateList { return &v1beta1.LeaseCandidateList{} },
|
||||
func(dst, src *v1beta1.LeaseCandidateList) { dst.ListMeta = src.ListMeta },
|
||||
func(list *v1beta1.LeaseCandidateList) []*v1beta1.LeaseCandidate {
|
||||
return gentype.ToPointerSlice(list.Items)
|
||||
},
|
||||
func(list *v1beta1.LeaseCandidateList, items []*v1beta1.LeaseCandidate) {
|
||||
list.Items = gentype.FromPointerSlice(items)
|
||||
},
|
||||
),
|
||||
fake,
|
||||
}
|
||||
}
|
@ -19,3 +19,5 @@ limitations under the License.
|
||||
package v1beta1
|
||||
|
||||
type LeaseExpansion interface{}
|
||||
|
||||
type LeaseCandidateExpansion interface{}
|
||||
|
71
kubernetes/typed/coordination/v1beta1/leasecandidate.go
Normal file
71
kubernetes/typed/coordination/v1beta1/leasecandidate.go
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by client-gen. DO NOT EDIT.
|
||||
|
||||
package v1beta1
|
||||
|
||||
import (
|
||||
context "context"
|
||||
|
||||
coordinationv1beta1 "k8s.io/api/coordination/v1beta1"
|
||||
v1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
types "k8s.io/apimachinery/pkg/types"
|
||||
watch "k8s.io/apimachinery/pkg/watch"
|
||||
applyconfigurationscoordinationv1beta1 "k8s.io/client-go/applyconfigurations/coordination/v1beta1"
|
||||
gentype "k8s.io/client-go/gentype"
|
||||
scheme "k8s.io/client-go/kubernetes/scheme"
|
||||
)
|
||||
|
||||
// LeaseCandidatesGetter has a method to return a LeaseCandidateInterface.
|
||||
// A group's client should implement this interface.
|
||||
type LeaseCandidatesGetter interface {
|
||||
LeaseCandidates(namespace string) LeaseCandidateInterface
|
||||
}
|
||||
|
||||
// LeaseCandidateInterface has methods to work with LeaseCandidate resources.
|
||||
type LeaseCandidateInterface interface {
|
||||
Create(ctx context.Context, leaseCandidate *coordinationv1beta1.LeaseCandidate, opts v1.CreateOptions) (*coordinationv1beta1.LeaseCandidate, error)
|
||||
Update(ctx context.Context, leaseCandidate *coordinationv1beta1.LeaseCandidate, opts v1.UpdateOptions) (*coordinationv1beta1.LeaseCandidate, error)
|
||||
Delete(ctx context.Context, name string, opts v1.DeleteOptions) error
|
||||
DeleteCollection(ctx context.Context, opts v1.DeleteOptions, listOpts v1.ListOptions) error
|
||||
Get(ctx context.Context, name string, opts v1.GetOptions) (*coordinationv1beta1.LeaseCandidate, error)
|
||||
List(ctx context.Context, opts v1.ListOptions) (*coordinationv1beta1.LeaseCandidateList, error)
|
||||
Watch(ctx context.Context, opts v1.ListOptions) (watch.Interface, error)
|
||||
Patch(ctx context.Context, name string, pt types.PatchType, data []byte, opts v1.PatchOptions, subresources ...string) (result *coordinationv1beta1.LeaseCandidate, err error)
|
||||
Apply(ctx context.Context, leaseCandidate *applyconfigurationscoordinationv1beta1.LeaseCandidateApplyConfiguration, opts v1.ApplyOptions) (result *coordinationv1beta1.LeaseCandidate, err error)
|
||||
LeaseCandidateExpansion
|
||||
}
|
||||
|
||||
// leaseCandidates implements LeaseCandidateInterface
|
||||
type leaseCandidates struct {
|
||||
*gentype.ClientWithListAndApply[*coordinationv1beta1.LeaseCandidate, *coordinationv1beta1.LeaseCandidateList, *applyconfigurationscoordinationv1beta1.LeaseCandidateApplyConfiguration]
|
||||
}
|
||||
|
||||
// newLeaseCandidates returns a LeaseCandidates
|
||||
func newLeaseCandidates(c *CoordinationV1beta1Client, namespace string) *leaseCandidates {
|
||||
return &leaseCandidates{
|
||||
gentype.NewClientWithListAndApply[*coordinationv1beta1.LeaseCandidate, *coordinationv1beta1.LeaseCandidateList, *applyconfigurationscoordinationv1beta1.LeaseCandidateApplyConfiguration](
|
||||
"leasecandidates",
|
||||
c.RESTClient(),
|
||||
scheme.ParameterCodec,
|
||||
namespace,
|
||||
func() *coordinationv1beta1.LeaseCandidate { return &coordinationv1beta1.LeaseCandidate{} },
|
||||
func() *coordinationv1beta1.LeaseCandidateList { return &coordinationv1beta1.LeaseCandidateList{} },
|
||||
gentype.PrefersProtobuf[*coordinationv1beta1.LeaseCandidate](),
|
||||
),
|
||||
}
|
||||
}
|
@ -25,3 +25,11 @@ type LeaseListerExpansion interface{}
|
||||
// LeaseNamespaceListerExpansion allows custom methods to be added to
|
||||
// LeaseNamespaceLister.
|
||||
type LeaseNamespaceListerExpansion interface{}
|
||||
|
||||
// LeaseCandidateListerExpansion allows custom methods to be added to
|
||||
// LeaseCandidateLister.
|
||||
type LeaseCandidateListerExpansion interface{}
|
||||
|
||||
// LeaseCandidateNamespaceListerExpansion allows custom methods to be added to
|
||||
// LeaseCandidateNamespaceLister.
|
||||
type LeaseCandidateNamespaceListerExpansion interface{}
|
||||
|
70
listers/coordination/v1beta1/leasecandidate.go
Normal file
70
listers/coordination/v1beta1/leasecandidate.go
Normal file
@ -0,0 +1,70 @@
|
||||
/*
|
||||
Copyright The Kubernetes Authors.
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
// Code generated by lister-gen. DO NOT EDIT.
|
||||
|
||||
package v1beta1
|
||||
|
||||
import (
|
||||
coordinationv1beta1 "k8s.io/api/coordination/v1beta1"
|
||||
labels "k8s.io/apimachinery/pkg/labels"
|
||||
listers "k8s.io/client-go/listers"
|
||||
cache "k8s.io/client-go/tools/cache"
|
||||
)
|
||||
|
||||
// LeaseCandidateLister helps list LeaseCandidates.
|
||||
// All objects returned here must be treated as read-only.
|
||||
type LeaseCandidateLister interface {
|
||||
// List lists all LeaseCandidates in the indexer.
|
||||
// Objects returned here must be treated as read-only.
|
||||
List(selector labels.Selector) (ret []*coordinationv1beta1.LeaseCandidate, err error)
|
||||
// LeaseCandidates returns an object that can list and get LeaseCandidates.
|
||||
LeaseCandidates(namespace string) LeaseCandidateNamespaceLister
|
||||
LeaseCandidateListerExpansion
|
||||
}
|
||||
|
||||
// leaseCandidateLister implements the LeaseCandidateLister interface.
|
||||
type leaseCandidateLister struct {
|
||||
listers.ResourceIndexer[*coordinationv1beta1.LeaseCandidate]
|
||||
}
|
||||
|
||||
// NewLeaseCandidateLister returns a new LeaseCandidateLister.
|
||||
func NewLeaseCandidateLister(indexer cache.Indexer) LeaseCandidateLister {
|
||||
return &leaseCandidateLister{listers.New[*coordinationv1beta1.LeaseCandidate](indexer, coordinationv1beta1.Resource("leasecandidate"))}
|
||||
}
|
||||
|
||||
// LeaseCandidates returns an object that can list and get LeaseCandidates.
|
||||
func (s *leaseCandidateLister) LeaseCandidates(namespace string) LeaseCandidateNamespaceLister {
|
||||
return leaseCandidateNamespaceLister{listers.NewNamespaced[*coordinationv1beta1.LeaseCandidate](s.ResourceIndexer, namespace)}
|
||||
}
|
||||
|
||||
// LeaseCandidateNamespaceLister helps list and get LeaseCandidates.
|
||||
// All objects returned here must be treated as read-only.
|
||||
type LeaseCandidateNamespaceLister interface {
|
||||
// List lists all LeaseCandidates in the indexer for a given namespace.
|
||||
// Objects returned here must be treated as read-only.
|
||||
List(selector labels.Selector) (ret []*coordinationv1beta1.LeaseCandidate, err error)
|
||||
// Get retrieves the LeaseCandidate from the indexer for a given namespace and name.
|
||||
// Objects returned here must be treated as read-only.
|
||||
Get(name string) (*coordinationv1beta1.LeaseCandidate, error)
|
||||
LeaseCandidateNamespaceListerExpansion
|
||||
}
|
||||
|
||||
// leaseCandidateNamespaceLister implements the LeaseCandidateNamespaceLister
|
||||
// interface.
|
||||
type leaseCandidateNamespaceLister struct {
|
||||
listers.ResourceIndexer[*coordinationv1beta1.LeaseCandidate]
|
||||
}
|
@ -22,14 +22,14 @@ import (
|
||||
"time"
|
||||
|
||||
v1 "k8s.io/api/coordination/v1"
|
||||
v1alpha2 "k8s.io/api/coordination/v1alpha2"
|
||||
v1beta1 "k8s.io/api/coordination/v1beta1"
|
||||
apierrors "k8s.io/apimachinery/pkg/api/errors"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/fields"
|
||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||
"k8s.io/client-go/informers"
|
||||
"k8s.io/client-go/kubernetes"
|
||||
coordinationv1alpha2client "k8s.io/client-go/kubernetes/typed/coordination/v1alpha2"
|
||||
coordinationv1beta1client "k8s.io/client-go/kubernetes/typed/coordination/v1beta1"
|
||||
"k8s.io/client-go/tools/cache"
|
||||
"k8s.io/client-go/util/workqueue"
|
||||
"k8s.io/klog/v2"
|
||||
@ -43,7 +43,7 @@ type CacheSyncWaiter interface {
|
||||
}
|
||||
|
||||
type LeaseCandidate struct {
|
||||
leaseClient coordinationv1alpha2client.LeaseCandidateInterface
|
||||
leaseClient coordinationv1beta1client.LeaseCandidateInterface
|
||||
leaseCandidateInformer cache.SharedIndexInformer
|
||||
informerFactory informers.SharedInformerFactory
|
||||
hasSynced cache.InformerSynced
|
||||
@ -84,10 +84,10 @@ func NewCandidate(clientset kubernetes.Interface,
|
||||
options.FieldSelector = fieldSelector
|
||||
}),
|
||||
)
|
||||
leaseCandidateInformer := informerFactory.Coordination().V1alpha2().LeaseCandidates().Informer()
|
||||
leaseCandidateInformer := informerFactory.Coordination().V1beta1().LeaseCandidates().Informer()
|
||||
|
||||
lc := &LeaseCandidate{
|
||||
leaseClient: clientset.CoordinationV1alpha2().LeaseCandidates(candidateNamespace),
|
||||
leaseClient: clientset.CoordinationV1beta1().LeaseCandidates(candidateNamespace),
|
||||
leaseCandidateInformer: leaseCandidateInformer,
|
||||
informerFactory: informerFactory,
|
||||
name: candidateName,
|
||||
@ -102,7 +102,7 @@ func NewCandidate(clientset kubernetes.Interface,
|
||||
|
||||
h, err := leaseCandidateInformer.AddEventHandler(cache.ResourceEventHandlerFuncs{
|
||||
UpdateFunc: func(oldObj, newObj interface{}) {
|
||||
if leasecandidate, ok := newObj.(*v1alpha2.LeaseCandidate); ok {
|
||||
if leasecandidate, ok := newObj.(*v1beta1.LeaseCandidate); ok {
|
||||
if leasecandidate.Spec.PingTime != nil && leasecandidate.Spec.PingTime.After(leasecandidate.Spec.RenewTime.Time) {
|
||||
lc.enqueueLease()
|
||||
}
|
||||
@ -184,13 +184,13 @@ func (c *LeaseCandidate) ensureLease(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *LeaseCandidate) newLeaseCandidate() *v1alpha2.LeaseCandidate {
|
||||
lc := &v1alpha2.LeaseCandidate{
|
||||
func (c *LeaseCandidate) newLeaseCandidate() *v1beta1.LeaseCandidate {
|
||||
lc := &v1beta1.LeaseCandidate{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: c.name,
|
||||
Namespace: c.namespace,
|
||||
},
|
||||
Spec: v1alpha2.LeaseCandidateSpec{
|
||||
Spec: v1beta1.LeaseCandidateSpec{
|
||||
LeaseName: c.leaseName,
|
||||
BinaryVersion: c.binaryVersion,
|
||||
EmulationVersion: c.emulationVersion,
|
||||
|
@ -101,12 +101,12 @@ func TestLeaseCandidateAck(t *testing.T) {
|
||||
|
||||
// Update PingTime and verify that the client renews
|
||||
ensureAfter := &metav1.MicroTime{Time: time.Now()}
|
||||
lc, err := client.CoordinationV1alpha2().LeaseCandidates(tc.candidateNamespace).Get(ctx, tc.candidateName, metav1.GetOptions{})
|
||||
lc, err := client.CoordinationV1beta1().LeaseCandidates(tc.candidateNamespace).Get(ctx, tc.candidateName, metav1.GetOptions{})
|
||||
if err == nil {
|
||||
if lc.Spec.PingTime == nil {
|
||||
c := lc.DeepCopy()
|
||||
c.Spec.PingTime = &metav1.MicroTime{Time: time.Now()}
|
||||
_, err = client.CoordinationV1alpha2().LeaseCandidates(tc.candidateNamespace).Update(ctx, c, metav1.UpdateOptions{})
|
||||
_, err = client.CoordinationV1beta1().LeaseCandidates(tc.candidateNamespace).Update(ctx, c, metav1.UpdateOptions{})
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
}
|
||||
@ -120,7 +120,7 @@ func TestLeaseCandidateAck(t *testing.T) {
|
||||
|
||||
func pollForLease(ctx context.Context, tc testcase, client *fake.Clientset, t *metav1.MicroTime) error {
|
||||
return wait.PollUntilContextTimeout(ctx, 100*time.Millisecond, 10*time.Second, true, func(ctx context.Context) (done bool, err error) {
|
||||
lc, err := client.CoordinationV1alpha2().LeaseCandidates(tc.candidateNamespace).Get(ctx, tc.candidateName, metav1.GetOptions{})
|
||||
lc, err := client.CoordinationV1beta1().LeaseCandidates(tc.candidateNamespace).Get(ctx, tc.candidateName, metav1.GetOptions{})
|
||||
if err != nil {
|
||||
if errors.IsNotFound(err) {
|
||||
return false, nil
|
||||
|
Loading…
Reference in New Issue
Block a user