From 5866abc5d8a89c329c9a80a971c5d9fdbfba5a4d Mon Sep 17 00:00:00 2001 From: GoingCharlie <1040279008@qq.com> Date: Wed, 20 Aug 2025 16:30:10 +0800 Subject: [PATCH] feat: add cron volcano job Signed-off-by: GoingCharlie <1040279008@qq.com> --- pkg/apis/batch/v1alpha1/job.go | 144 ++++++++++- pkg/apis/batch/v1alpha1/labels.go | 4 +- pkg/apis/batch/v1alpha1/register.go | 2 + .../batch/v1alpha1/zz_generated.deepcopy.go | 164 ++++++++++++- .../batch/v1alpha1/cronjob.go | 224 ++++++++++++++++++ .../batch/v1alpha1/cronjobspec.go | 105 ++++++++ .../batch/v1alpha1/cronjobstatus.go | 63 +++++ .../batch/v1alpha1/jobtemplatespec.go | 193 +++++++++++++++ pkg/client/applyconfiguration/utils.go | 8 + .../typed/batch/v1alpha1/batch_client.go | 5 + .../versioned/typed/batch/v1alpha1/cronjob.go | 73 ++++++ .../batch/v1alpha1/fake/fake_batch_client.go | 4 + .../typed/batch/v1alpha1/fake/fake_cronjob.go | 50 ++++ .../batch/v1alpha1/generated_expansion.go | 2 + .../batch/v1alpha1/cronjob.go | 101 ++++++++ .../batch/v1alpha1/interface.go | 7 + .../informers/externalversions/generic.go | 2 + pkg/client/listers/batch/v1alpha1/cronjob.go | 69 ++++++ .../batch/v1alpha1/expansion_generated.go | 8 + 19 files changed, 1219 insertions(+), 9 deletions(-) create mode 100644 pkg/client/applyconfiguration/batch/v1alpha1/cronjob.go create mode 100644 pkg/client/applyconfiguration/batch/v1alpha1/cronjobspec.go create mode 100644 pkg/client/applyconfiguration/batch/v1alpha1/cronjobstatus.go create mode 100644 pkg/client/applyconfiguration/batch/v1alpha1/jobtemplatespec.go create mode 100644 pkg/client/clientset/versioned/typed/batch/v1alpha1/cronjob.go create mode 100644 pkg/client/clientset/versioned/typed/batch/v1alpha1/fake/fake_cronjob.go create mode 100644 pkg/client/informers/externalversions/batch/v1alpha1/cronjob.go create mode 100644 pkg/client/listers/batch/v1alpha1/cronjob.go diff --git a/pkg/apis/batch/v1alpha1/job.go b/pkg/apis/batch/v1alpha1/job.go index 9da2f88b..5d9be3c2 100644 --- a/pkg/apis/batch/v1alpha1/job.go +++ b/pkg/apis/batch/v1alpha1/job.go @@ -1,5 +1,6 @@ /* -Copyright 2018 The Volcano Authors. +Copyright 2018 The Kubernetes Authors. +Copyright 2018-2025 The Volcano Authors. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -412,3 +413,144 @@ type DependsOn struct { // +optional Iteration Iteration `json:"iteration,omitempty" protobuf:"bytes,2,opt,name=iteration"` } + +// ConcurrencyPolicy describes how the job will be handled. +// Only one of the following concurrent policies may be specified. +// If none of the following policies is specified, the default one +// is AllowConcurrent. +type ConcurrencyPolicy string + +const ( + // AllowConcurrent allows CronJobs to run concurrently. + AllowConcurrent ConcurrencyPolicy = "Allow" + + // ForbidConcurrent forbids concurrent runs, skipping next run if previous + // hasn't finished yet. + ForbidConcurrent ConcurrencyPolicy = "Forbid" + + // ReplaceConcurrent cancels currently running job and replaces it with a new one. + ReplaceConcurrent ConcurrencyPolicy = "Replace" +) + +// JobTemplateSpec describes the data a Job should have when created from a template +type JobTemplateSpec struct { + // Standard object's metadata of the jobs created from this template. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + // +optional + metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` + + // Specification of the desired behavior of the job. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status + // +optional + Spec JobSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` +} + +// CronJobSpec defines the desired state of Cronjob +type CronJobSpec struct { + // The schedule in Cron format, see https://en.wikipedia.org/wiki/Cron. + Schedule string `json:"schedule" protobuf:"bytes,1,opt,name=schedule"` + + // The time zone name for the given schedule, see https://en.wikipedia.org/wiki/List_of_tz_database_time_zones. + // If not specified, this will default to the time zone of the kube-controller-manager process. + // The set of valid time zone names and the time zone offset is loaded from the system-wide time zone + // database by the API server during CronJob validation and the controller manager during execution. + // If no system-wide time zone database can be found a bundled version of the database is used instead. + // If the time zone name becomes invalid during the lifetime of a CronJob or due to a change in host + // configuration, the controller will stop creating new new Jobs and will create a system event with the + // reason UnknownTimeZone. + // More information can be found in https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#time-zones + // +optional + TimeZone *string `json:"timeZone,omitempty" protobuf:"bytes,2,opt,name=timeZone"` + + // Optional deadline in seconds for starting the job if it misses scheduled + // time for any reason. Missed jobs executions will be counted as failed ones. + // +kubebuilder:validation:Minimum=0 + // +optional + StartingDeadlineSeconds *int64 `json:"startingDeadlineSeconds,omitempty" protobuf:"varint,3,opt,name=startingDeadlineSeconds"` + + // Specifies how to treat concurrent executions of a Job. + // Valid values are: + // - "Allow" (default): allows CronJobs to run concurrently; + // - "Forbid": forbids concurrent runs, skipping next run if previous run hasn't finished yet; + // - "Replace": cancels currently running job and replaces it with a new one + // +kubebuilder:default=Allow + // +kubebuilder:validation:Enum=Allow;Forbid;Replace + // +optional + ConcurrencyPolicy ConcurrencyPolicy `json:"concurrencyPolicy,omitempty" protobuf:"bytes,4,opt,name=concurrencyPolicy,casttype=ConcurrencyPolicy"` + + // This flag tells the controller to suspend subsequent executions, it does + // not apply to already started executions. Defaults to false. + // +kubebuilder:default=false + // +optional + Suspend *bool `json:"suspend,omitempty" protobuf:"varint,5,opt,name=suspend"` + + // Specifies the job that will be created when executing a CronJob. + JobTemplate JobTemplateSpec `json:"jobTemplate" protobuf:"bytes,6,opt,name=jobTemplate"` + + // The number of successful finished jobs to retain. + // This is a pointer to distinguish between explicit zero and not specified. + // Defaults to 3. + // +kubebuilder:default=3 + // +kubebuilder:validation:Minimum=0 + // +optional + SuccessfulJobsHistoryLimit *int32 `json:"successfulJobsHistoryLimit,omitempty" protobuf:"varint,7,opt,name=successfulJobsHistoryLimit"` + + // The number of failed finished jobs to retain. + // This is a pointer to distinguish between explicit zero and not specified. + // Defaults to 3. + // +kubebuilder:default=1 + // +kubebuilder:validation:Minimum=0 + // +optional + FailedJobsHistoryLimit *int32 `json:"failedJobsHistoryLimit,omitempty" protobuf:"varint,8,opt,name=failedJobsHistoryLimit"` +} + +// CronJobStatus represents the current state of a cron job. +type CronJobStatus struct { + // A list of pointers to currently running jobs. + // +optional + // +listType=atomic + Active []v1.ObjectReference `json:"active,omitempty" protobuf:"bytes,1,rep,name=active"` + + // Information when was the last time the job was successfully scheduled. + // +optional + LastScheduleTime *metav1.Time `json:"lastScheduleTime,omitempty" protobuf:"bytes,2,opt,name=lastScheduleTime"` + + // Information when was the last time the job successfully completed. + // +optional + LastSuccessfulTime *metav1.Time `json:"lastSuccessfulTime,omitempty" protobuf:"bytes,3,opt,name=lastSuccessfulTime"` +} + +// +genclient +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object +// +kubebuilder:object:root=true +// +kubebuilder:resource:shortName=cronvcjob;cronvj +// +kubebuilder:subresource:status + +// CronJob is the Schema for the cronjobs API +type CronJob struct { + metav1.TypeMeta `json:",inline"` + // Standard object's metadata. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata + // +optional + metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` + + // Specification of the desired behavior of a cron job, including the schedule. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status + // +optional + Spec CronJobSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` + + // Current status of a cron job. + // More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status + // +optional + Status CronJobStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` +} + +// +kubebuilder:object:root=true +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object + +// CronJobList contains a list of Cronjob +type CronJobList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` + Items []CronJob `json:"items" protobuf:"bytes,2,rep,name=items"` +} diff --git a/pkg/apis/batch/v1alpha1/labels.go b/pkg/apis/batch/v1alpha1/labels.go index c41515d3..82d8bf14 100644 --- a/pkg/apis/batch/v1alpha1/labels.go +++ b/pkg/apis/batch/v1alpha1/labels.go @@ -46,5 +46,7 @@ const ( // OrginalNameKey annotation key for resource name OrginalNameKey = "volcano.sh/burst-name" // BurstToSiloClusterAnnotation labels key for resource only in silo cluster - BurstToSiloClusterAnnotation = "volcano.sh/silo-resource" + BurstToSiloClusterAnnotation = "volcano.sh/silo-resource" + // CronJobScheduledTimestampAnnotation records the intended scheduled timestamp for a job triggered by a CronJob. + CronJobScheduledTimestampAnnotation = "volcano.sh/cronjob-scheduled-timestamp" ) diff --git a/pkg/apis/batch/v1alpha1/register.go b/pkg/apis/batch/v1alpha1/register.go index ec3f6aeb..a36beaf9 100644 --- a/pkg/apis/batch/v1alpha1/register.go +++ b/pkg/apis/batch/v1alpha1/register.go @@ -45,6 +45,8 @@ func addKnownTypes(scheme *runtime.Scheme) error { scheme.AddKnownTypes(SchemeGroupVersion, &Job{}, &JobList{}, + &CronJob{}, + &CronJobList{}, ) metav1.AddToGroupVersion(scheme, SchemeGroupVersion) diff --git a/pkg/apis/batch/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/batch/v1alpha1/zz_generated.deepcopy.go index cdaa99e2..b2c6c2f5 100644 --- a/pkg/apis/batch/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/batch/v1alpha1/zz_generated.deepcopy.go @@ -21,12 +21,144 @@ limitations under the License. package v1alpha1 import ( - corev1 "k8s.io/api/core/v1" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + v1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" runtime "k8s.io/apimachinery/pkg/runtime" busv1alpha1 "volcano.sh/apis/pkg/apis/bus/v1alpha1" ) +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CronJob) DeepCopyInto(out *CronJob) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CronJob. +func (in *CronJob) DeepCopy() *CronJob { + if in == nil { + return nil + } + out := new(CronJob) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *CronJob) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CronJobList) DeepCopyInto(out *CronJobList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]CronJob, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CronJobList. +func (in *CronJobList) DeepCopy() *CronJobList { + if in == nil { + return nil + } + out := new(CronJobList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *CronJobList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CronJobSpec) DeepCopyInto(out *CronJobSpec) { + *out = *in + if in.TimeZone != nil { + in, out := &in.TimeZone, &out.TimeZone + *out = new(string) + **out = **in + } + if in.StartingDeadlineSeconds != nil { + in, out := &in.StartingDeadlineSeconds, &out.StartingDeadlineSeconds + *out = new(int64) + **out = **in + } + if in.Suspend != nil { + in, out := &in.Suspend, &out.Suspend + *out = new(bool) + **out = **in + } + in.JobTemplate.DeepCopyInto(&out.JobTemplate) + if in.SuccessfulJobsHistoryLimit != nil { + in, out := &in.SuccessfulJobsHistoryLimit, &out.SuccessfulJobsHistoryLimit + *out = new(int32) + **out = **in + } + if in.FailedJobsHistoryLimit != nil { + in, out := &in.FailedJobsHistoryLimit, &out.FailedJobsHistoryLimit + *out = new(int32) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CronJobSpec. +func (in *CronJobSpec) DeepCopy() *CronJobSpec { + if in == nil { + return nil + } + out := new(CronJobSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CronJobStatus) DeepCopyInto(out *CronJobStatus) { + *out = *in + if in.Active != nil { + in, out := &in.Active, &out.Active + *out = make([]v1.ObjectReference, len(*in)) + copy(*out, *in) + } + if in.LastScheduleTime != nil { + in, out := &in.LastScheduleTime, &out.LastScheduleTime + *out = (*in).DeepCopy() + } + if in.LastSuccessfulTime != nil { + in, out := &in.LastSuccessfulTime, &out.LastSuccessfulTime + *out = (*in).DeepCopy() + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CronJobStatus. +func (in *CronJobStatus) DeepCopy() *CronJobStatus { + if in == nil { + return nil + } + out := new(CronJobStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *DependsOn) DeepCopyInto(out *DependsOn) { *out = *in @@ -170,7 +302,7 @@ func (in *JobSpec) DeepCopyInto(out *JobSpec) { } if in.RunningEstimate != nil { in, out := &in.RunningEstimate, &out.RunningEstimate - *out = new(v1.Duration) + *out = new(metav1.Duration) **out = **in } if in.TTLSecondsAfterFinished != nil { @@ -231,7 +363,7 @@ func (in *JobStatus) DeepCopyInto(out *JobStatus) { } if in.RunningDuration != nil { in, out := &in.RunningDuration, &out.RunningDuration - *out = new(v1.Duration) + *out = new(metav1.Duration) **out = **in } if in.ControlledResources != nil { @@ -261,6 +393,24 @@ func (in *JobStatus) DeepCopy() *JobStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *JobTemplateSpec) DeepCopyInto(out *JobTemplateSpec) { + *out = *in + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new JobTemplateSpec. +func (in *JobTemplateSpec) DeepCopy() *JobTemplateSpec { + if in == nil { + return nil + } + out := new(JobTemplateSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *LifecyclePolicy) DeepCopyInto(out *LifecyclePolicy) { *out = *in @@ -276,7 +426,7 @@ func (in *LifecyclePolicy) DeepCopyInto(out *LifecyclePolicy) { } if in.Timeout != nil { in, out := &in.Timeout, &out.Timeout - *out = new(v1.Duration) + *out = new(metav1.Duration) **out = **in } return @@ -352,7 +502,7 @@ func (in *TaskState) DeepCopyInto(out *TaskState) { *out = *in if in.Phase != nil { in, out := &in.Phase, &out.Phase - *out = make(map[corev1.PodPhase]int32, len(*in)) + *out = make(map[v1.PodPhase]int32, len(*in)) for key, val := range *in { (*out)[key] = val } @@ -375,7 +525,7 @@ func (in *VolumeSpec) DeepCopyInto(out *VolumeSpec) { *out = *in if in.VolumeClaim != nil { in, out := &in.VolumeClaim, &out.VolumeClaim - *out = new(corev1.PersistentVolumeClaimSpec) + *out = new(v1.PersistentVolumeClaimSpec) (*in).DeepCopyInto(*out) } return diff --git a/pkg/client/applyconfiguration/batch/v1alpha1/cronjob.go b/pkg/client/applyconfiguration/batch/v1alpha1/cronjob.go new file mode 100644 index 00000000..a993d6e0 --- /dev/null +++ b/pkg/client/applyconfiguration/batch/v1alpha1/cronjob.go @@ -0,0 +1,224 @@ +/* +Copyright The Volcano 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 v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + v1 "k8s.io/client-go/applyconfigurations/meta/v1" +) + +// CronJobApplyConfiguration represents a declarative configuration of the CronJob type for use +// with apply. +type CronJobApplyConfiguration struct { + v1.TypeMetaApplyConfiguration `json:",inline"` + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *CronJobSpecApplyConfiguration `json:"spec,omitempty"` + Status *CronJobStatusApplyConfiguration `json:"status,omitempty"` +} + +// CronJob constructs a declarative configuration of the CronJob type for use with +// apply. +func CronJob(name, namespace string) *CronJobApplyConfiguration { + b := &CronJobApplyConfiguration{} + b.WithName(name) + b.WithNamespace(namespace) + b.WithKind("CronJob") + b.WithAPIVersion("batch.volcano.sh/v1alpha1") + return b +} + +// 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 *CronJobApplyConfiguration) WithKind(value string) *CronJobApplyConfiguration { + 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 *CronJobApplyConfiguration) WithAPIVersion(value string) *CronJobApplyConfiguration { + 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 *CronJobApplyConfiguration) WithName(value string) *CronJobApplyConfiguration { + 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 *CronJobApplyConfiguration) WithGenerateName(value string) *CronJobApplyConfiguration { + 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 *CronJobApplyConfiguration) WithNamespace(value string) *CronJobApplyConfiguration { + 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 *CronJobApplyConfiguration) WithUID(value types.UID) *CronJobApplyConfiguration { + 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 *CronJobApplyConfiguration) WithResourceVersion(value string) *CronJobApplyConfiguration { + 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 *CronJobApplyConfiguration) WithGeneration(value int64) *CronJobApplyConfiguration { + 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 *CronJobApplyConfiguration) WithCreationTimestamp(value metav1.Time) *CronJobApplyConfiguration { + 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 *CronJobApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *CronJobApplyConfiguration { + 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 *CronJobApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *CronJobApplyConfiguration { + 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 *CronJobApplyConfiguration) WithLabels(entries map[string]string) *CronJobApplyConfiguration { + 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 *CronJobApplyConfiguration) WithAnnotations(entries map[string]string) *CronJobApplyConfiguration { + 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 *CronJobApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *CronJobApplyConfiguration { + 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 *CronJobApplyConfiguration) WithFinalizers(values ...string) *CronJobApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.ObjectMetaApplyConfiguration.Finalizers = append(b.ObjectMetaApplyConfiguration.Finalizers, values[i]) + } + return b +} + +func (b *CronJobApplyConfiguration) 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 *CronJobApplyConfiguration) WithSpec(value *CronJobSpecApplyConfiguration) *CronJobApplyConfiguration { + b.Spec = value + return b +} + +// WithStatus sets the Status 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 Status field is set to the value of the last call. +func (b *CronJobApplyConfiguration) WithStatus(value *CronJobStatusApplyConfiguration) *CronJobApplyConfiguration { + b.Status = value + return b +} + +// GetName retrieves the value of the Name field in the declarative configuration. +func (b *CronJobApplyConfiguration) GetName() *string { + b.ensureObjectMetaApplyConfigurationExists() + return b.ObjectMetaApplyConfiguration.Name +} diff --git a/pkg/client/applyconfiguration/batch/v1alpha1/cronjobspec.go b/pkg/client/applyconfiguration/batch/v1alpha1/cronjobspec.go new file mode 100644 index 00000000..5a9807fd --- /dev/null +++ b/pkg/client/applyconfiguration/batch/v1alpha1/cronjobspec.go @@ -0,0 +1,105 @@ +/* +Copyright The Volcano 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 v1alpha1 + +import ( + batchv1alpha1 "volcano.sh/apis/pkg/apis/batch/v1alpha1" +) + +// CronJobSpecApplyConfiguration represents a declarative configuration of the CronJobSpec type for use +// with apply. +type CronJobSpecApplyConfiguration struct { + Schedule *string `json:"schedule,omitempty"` + TimeZone *string `json:"timeZone,omitempty"` + StartingDeadlineSeconds *int64 `json:"startingDeadlineSeconds,omitempty"` + ConcurrencyPolicy *batchv1alpha1.ConcurrencyPolicy `json:"concurrencyPolicy,omitempty"` + Suspend *bool `json:"suspend,omitempty"` + JobTemplate *JobTemplateSpecApplyConfiguration `json:"jobTemplate,omitempty"` + SuccessfulJobsHistoryLimit *int32 `json:"successfulJobsHistoryLimit,omitempty"` + FailedJobsHistoryLimit *int32 `json:"failedJobsHistoryLimit,omitempty"` +} + +// CronJobSpecApplyConfiguration constructs a declarative configuration of the CronJobSpec type for use with +// apply. +func CronJobSpec() *CronJobSpecApplyConfiguration { + return &CronJobSpecApplyConfiguration{} +} + +// WithSchedule sets the Schedule 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 Schedule field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithSchedule(value string) *CronJobSpecApplyConfiguration { + b.Schedule = &value + return b +} + +// WithTimeZone sets the TimeZone 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 TimeZone field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithTimeZone(value string) *CronJobSpecApplyConfiguration { + b.TimeZone = &value + return b +} + +// WithStartingDeadlineSeconds sets the StartingDeadlineSeconds 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 StartingDeadlineSeconds field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithStartingDeadlineSeconds(value int64) *CronJobSpecApplyConfiguration { + b.StartingDeadlineSeconds = &value + return b +} + +// WithConcurrencyPolicy sets the ConcurrencyPolicy 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 ConcurrencyPolicy field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithConcurrencyPolicy(value batchv1alpha1.ConcurrencyPolicy) *CronJobSpecApplyConfiguration { + b.ConcurrencyPolicy = &value + return b +} + +// WithSuspend sets the Suspend 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 Suspend field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithSuspend(value bool) *CronJobSpecApplyConfiguration { + b.Suspend = &value + return b +} + +// WithJobTemplate sets the JobTemplate 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 JobTemplate field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithJobTemplate(value *JobTemplateSpecApplyConfiguration) *CronJobSpecApplyConfiguration { + b.JobTemplate = value + return b +} + +// WithSuccessfulJobsHistoryLimit sets the SuccessfulJobsHistoryLimit 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 SuccessfulJobsHistoryLimit field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithSuccessfulJobsHistoryLimit(value int32) *CronJobSpecApplyConfiguration { + b.SuccessfulJobsHistoryLimit = &value + return b +} + +// WithFailedJobsHistoryLimit sets the FailedJobsHistoryLimit 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 FailedJobsHistoryLimit field is set to the value of the last call. +func (b *CronJobSpecApplyConfiguration) WithFailedJobsHistoryLimit(value int32) *CronJobSpecApplyConfiguration { + b.FailedJobsHistoryLimit = &value + return b +} diff --git a/pkg/client/applyconfiguration/batch/v1alpha1/cronjobstatus.go b/pkg/client/applyconfiguration/batch/v1alpha1/cronjobstatus.go new file mode 100644 index 00000000..683a898d --- /dev/null +++ b/pkg/client/applyconfiguration/batch/v1alpha1/cronjobstatus.go @@ -0,0 +1,63 @@ +/* +Copyright The Volcano 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 v1alpha1 + +import ( + v1 "k8s.io/api/core/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" +) + +// CronJobStatusApplyConfiguration represents a declarative configuration of the CronJobStatus type for use +// with apply. +type CronJobStatusApplyConfiguration struct { + Active []v1.ObjectReference `json:"active,omitempty"` + LastScheduleTime *metav1.Time `json:"lastScheduleTime,omitempty"` + LastSuccessfulTime *metav1.Time `json:"lastSuccessfulTime,omitempty"` +} + +// CronJobStatusApplyConfiguration constructs a declarative configuration of the CronJobStatus type for use with +// apply. +func CronJobStatus() *CronJobStatusApplyConfiguration { + return &CronJobStatusApplyConfiguration{} +} + +// WithActive adds the given value to the Active 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 Active field. +func (b *CronJobStatusApplyConfiguration) WithActive(values ...v1.ObjectReference) *CronJobStatusApplyConfiguration { + for i := range values { + b.Active = append(b.Active, values[i]) + } + return b +} + +// WithLastScheduleTime sets the LastScheduleTime 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 LastScheduleTime field is set to the value of the last call. +func (b *CronJobStatusApplyConfiguration) WithLastScheduleTime(value metav1.Time) *CronJobStatusApplyConfiguration { + b.LastScheduleTime = &value + return b +} + +// WithLastSuccessfulTime sets the LastSuccessfulTime 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 LastSuccessfulTime field is set to the value of the last call. +func (b *CronJobStatusApplyConfiguration) WithLastSuccessfulTime(value metav1.Time) *CronJobStatusApplyConfiguration { + b.LastSuccessfulTime = &value + return b +} diff --git a/pkg/client/applyconfiguration/batch/v1alpha1/jobtemplatespec.go b/pkg/client/applyconfiguration/batch/v1alpha1/jobtemplatespec.go new file mode 100644 index 00000000..965c18c3 --- /dev/null +++ b/pkg/client/applyconfiguration/batch/v1alpha1/jobtemplatespec.go @@ -0,0 +1,193 @@ +/* +Copyright The Volcano 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 v1alpha1 + +import ( + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + v1 "k8s.io/client-go/applyconfigurations/meta/v1" +) + +// JobTemplateSpecApplyConfiguration represents a declarative configuration of the JobTemplateSpec type for use +// with apply. +type JobTemplateSpecApplyConfiguration struct { + *v1.ObjectMetaApplyConfiguration `json:"metadata,omitempty"` + Spec *JobSpecApplyConfiguration `json:"spec,omitempty"` +} + +// JobTemplateSpecApplyConfiguration constructs a declarative configuration of the JobTemplateSpec type for use with +// apply. +func JobTemplateSpec() *JobTemplateSpecApplyConfiguration { + return &JobTemplateSpecApplyConfiguration{} +} + +// 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 *JobTemplateSpecApplyConfiguration) WithName(value string) *JobTemplateSpecApplyConfiguration { + 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 *JobTemplateSpecApplyConfiguration) WithGenerateName(value string) *JobTemplateSpecApplyConfiguration { + 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 *JobTemplateSpecApplyConfiguration) WithNamespace(value string) *JobTemplateSpecApplyConfiguration { + 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 *JobTemplateSpecApplyConfiguration) WithUID(value types.UID) *JobTemplateSpecApplyConfiguration { + 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 *JobTemplateSpecApplyConfiguration) WithResourceVersion(value string) *JobTemplateSpecApplyConfiguration { + 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 *JobTemplateSpecApplyConfiguration) WithGeneration(value int64) *JobTemplateSpecApplyConfiguration { + 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 *JobTemplateSpecApplyConfiguration) WithCreationTimestamp(value metav1.Time) *JobTemplateSpecApplyConfiguration { + 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 *JobTemplateSpecApplyConfiguration) WithDeletionTimestamp(value metav1.Time) *JobTemplateSpecApplyConfiguration { + 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 *JobTemplateSpecApplyConfiguration) WithDeletionGracePeriodSeconds(value int64) *JobTemplateSpecApplyConfiguration { + 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 *JobTemplateSpecApplyConfiguration) WithLabels(entries map[string]string) *JobTemplateSpecApplyConfiguration { + 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 *JobTemplateSpecApplyConfiguration) WithAnnotations(entries map[string]string) *JobTemplateSpecApplyConfiguration { + 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 *JobTemplateSpecApplyConfiguration) WithOwnerReferences(values ...*v1.OwnerReferenceApplyConfiguration) *JobTemplateSpecApplyConfiguration { + 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 *JobTemplateSpecApplyConfiguration) WithFinalizers(values ...string) *JobTemplateSpecApplyConfiguration { + b.ensureObjectMetaApplyConfigurationExists() + for i := range values { + b.ObjectMetaApplyConfiguration.Finalizers = append(b.ObjectMetaApplyConfiguration.Finalizers, values[i]) + } + return b +} + +func (b *JobTemplateSpecApplyConfiguration) 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 *JobTemplateSpecApplyConfiguration) WithSpec(value *JobSpecApplyConfiguration) *JobTemplateSpecApplyConfiguration { + b.Spec = value + return b +} + +// GetName retrieves the value of the Name field in the declarative configuration. +func (b *JobTemplateSpecApplyConfiguration) GetName() *string { + b.ensureObjectMetaApplyConfigurationExists() + return b.ObjectMetaApplyConfiguration.Name +} diff --git a/pkg/client/applyconfiguration/utils.go b/pkg/client/applyconfiguration/utils.go index 44d95e94..b39fd451 100644 --- a/pkg/client/applyconfiguration/utils.go +++ b/pkg/client/applyconfiguration/utils.go @@ -41,6 +41,12 @@ import ( func ForKind(kind schema.GroupVersionKind) interface{} { switch kind { // Group=batch.volcano.sh, Version=v1alpha1 + case v1alpha1.SchemeGroupVersion.WithKind("CronJob"): + return &batchv1alpha1.CronJobApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("CronJobSpec"): + return &batchv1alpha1.CronJobSpecApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("CronJobStatus"): + return &batchv1alpha1.CronJobStatusApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("DependsOn"): return &batchv1alpha1.DependsOnApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("Job"): @@ -53,6 +59,8 @@ func ForKind(kind schema.GroupVersionKind) interface{} { return &batchv1alpha1.JobStateApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("JobStatus"): return &batchv1alpha1.JobStatusApplyConfiguration{} + case v1alpha1.SchemeGroupVersion.WithKind("JobTemplateSpec"): + return &batchv1alpha1.JobTemplateSpecApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("LifecyclePolicy"): return &batchv1alpha1.LifecyclePolicyApplyConfiguration{} case v1alpha1.SchemeGroupVersion.WithKind("NetworkTopologySpec"): diff --git a/pkg/client/clientset/versioned/typed/batch/v1alpha1/batch_client.go b/pkg/client/clientset/versioned/typed/batch/v1alpha1/batch_client.go index f81274ac..0f18581a 100644 --- a/pkg/client/clientset/versioned/typed/batch/v1alpha1/batch_client.go +++ b/pkg/client/clientset/versioned/typed/batch/v1alpha1/batch_client.go @@ -27,6 +27,7 @@ import ( type BatchV1alpha1Interface interface { RESTClient() rest.Interface + CronJobsGetter JobsGetter } @@ -35,6 +36,10 @@ type BatchV1alpha1Client struct { restClient rest.Interface } +func (c *BatchV1alpha1Client) CronJobs(namespace string) CronJobInterface { + return newCronJobs(c, namespace) +} + func (c *BatchV1alpha1Client) Jobs(namespace string) JobInterface { return newJobs(c, namespace) } diff --git a/pkg/client/clientset/versioned/typed/batch/v1alpha1/cronjob.go b/pkg/client/clientset/versioned/typed/batch/v1alpha1/cronjob.go new file mode 100644 index 00000000..716bede7 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/batch/v1alpha1/cronjob.go @@ -0,0 +1,73 @@ +/* +Copyright The Volcano 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 v1alpha1 + +import ( + context "context" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + types "k8s.io/apimachinery/pkg/types" + watch "k8s.io/apimachinery/pkg/watch" + gentype "k8s.io/client-go/gentype" + batchv1alpha1 "volcano.sh/apis/pkg/apis/batch/v1alpha1" + applyconfigurationbatchv1alpha1 "volcano.sh/apis/pkg/client/applyconfiguration/batch/v1alpha1" + scheme "volcano.sh/apis/pkg/client/clientset/versioned/scheme" +) + +// CronJobsGetter has a method to return a CronJobInterface. +// A group's client should implement this interface. +type CronJobsGetter interface { + CronJobs(namespace string) CronJobInterface +} + +// CronJobInterface has methods to work with CronJob resources. +type CronJobInterface interface { + Create(ctx context.Context, cronJob *batchv1alpha1.CronJob, opts v1.CreateOptions) (*batchv1alpha1.CronJob, error) + Update(ctx context.Context, cronJob *batchv1alpha1.CronJob, opts v1.UpdateOptions) (*batchv1alpha1.CronJob, error) + // Add a +genclient:noStatus comment above the type to avoid generating UpdateStatus(). + UpdateStatus(ctx context.Context, cronJob *batchv1alpha1.CronJob, opts v1.UpdateOptions) (*batchv1alpha1.CronJob, 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) (*batchv1alpha1.CronJob, error) + List(ctx context.Context, opts v1.ListOptions) (*batchv1alpha1.CronJobList, 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 *batchv1alpha1.CronJob, err error) + Apply(ctx context.Context, cronJob *applyconfigurationbatchv1alpha1.CronJobApplyConfiguration, opts v1.ApplyOptions) (result *batchv1alpha1.CronJob, err error) + // Add a +genclient:noStatus comment above the type to avoid generating ApplyStatus(). + ApplyStatus(ctx context.Context, cronJob *applyconfigurationbatchv1alpha1.CronJobApplyConfiguration, opts v1.ApplyOptions) (result *batchv1alpha1.CronJob, err error) + CronJobExpansion +} + +// cronJobs implements CronJobInterface +type cronJobs struct { + *gentype.ClientWithListAndApply[*batchv1alpha1.CronJob, *batchv1alpha1.CronJobList, *applyconfigurationbatchv1alpha1.CronJobApplyConfiguration] +} + +// newCronJobs returns a CronJobs +func newCronJobs(c *BatchV1alpha1Client, namespace string) *cronJobs { + return &cronJobs{ + gentype.NewClientWithListAndApply[*batchv1alpha1.CronJob, *batchv1alpha1.CronJobList, *applyconfigurationbatchv1alpha1.CronJobApplyConfiguration]( + "cronjobs", + c.RESTClient(), + scheme.ParameterCodec, + namespace, + func() *batchv1alpha1.CronJob { return &batchv1alpha1.CronJob{} }, + func() *batchv1alpha1.CronJobList { return &batchv1alpha1.CronJobList{} }, + ), + } +} diff --git a/pkg/client/clientset/versioned/typed/batch/v1alpha1/fake/fake_batch_client.go b/pkg/client/clientset/versioned/typed/batch/v1alpha1/fake/fake_batch_client.go index 3dcfda26..acb96ca9 100644 --- a/pkg/client/clientset/versioned/typed/batch/v1alpha1/fake/fake_batch_client.go +++ b/pkg/client/clientset/versioned/typed/batch/v1alpha1/fake/fake_batch_client.go @@ -27,6 +27,10 @@ type FakeBatchV1alpha1 struct { *testing.Fake } +func (c *FakeBatchV1alpha1) CronJobs(namespace string) v1alpha1.CronJobInterface { + return newFakeCronJobs(c, namespace) +} + func (c *FakeBatchV1alpha1) Jobs(namespace string) v1alpha1.JobInterface { return newFakeJobs(c, namespace) } diff --git a/pkg/client/clientset/versioned/typed/batch/v1alpha1/fake/fake_cronjob.go b/pkg/client/clientset/versioned/typed/batch/v1alpha1/fake/fake_cronjob.go new file mode 100644 index 00000000..534c4227 --- /dev/null +++ b/pkg/client/clientset/versioned/typed/batch/v1alpha1/fake/fake_cronjob.go @@ -0,0 +1,50 @@ +/* +Copyright The Volcano 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 ( + gentype "k8s.io/client-go/gentype" + v1alpha1 "volcano.sh/apis/pkg/apis/batch/v1alpha1" + batchv1alpha1 "volcano.sh/apis/pkg/client/applyconfiguration/batch/v1alpha1" + typedbatchv1alpha1 "volcano.sh/apis/pkg/client/clientset/versioned/typed/batch/v1alpha1" +) + +// fakeCronJobs implements CronJobInterface +type fakeCronJobs struct { + *gentype.FakeClientWithListAndApply[*v1alpha1.CronJob, *v1alpha1.CronJobList, *batchv1alpha1.CronJobApplyConfiguration] + Fake *FakeBatchV1alpha1 +} + +func newFakeCronJobs(fake *FakeBatchV1alpha1, namespace string) typedbatchv1alpha1.CronJobInterface { + return &fakeCronJobs{ + gentype.NewFakeClientWithListAndApply[*v1alpha1.CronJob, *v1alpha1.CronJobList, *batchv1alpha1.CronJobApplyConfiguration]( + fake.Fake, + namespace, + v1alpha1.SchemeGroupVersion.WithResource("cronjobs"), + v1alpha1.SchemeGroupVersion.WithKind("CronJob"), + func() *v1alpha1.CronJob { return &v1alpha1.CronJob{} }, + func() *v1alpha1.CronJobList { return &v1alpha1.CronJobList{} }, + func(dst, src *v1alpha1.CronJobList) { dst.ListMeta = src.ListMeta }, + func(list *v1alpha1.CronJobList) []*v1alpha1.CronJob { return gentype.ToPointerSlice(list.Items) }, + func(list *v1alpha1.CronJobList, items []*v1alpha1.CronJob) { + list.Items = gentype.FromPointerSlice(items) + }, + ), + fake, + } +} diff --git a/pkg/client/clientset/versioned/typed/batch/v1alpha1/generated_expansion.go b/pkg/client/clientset/versioned/typed/batch/v1alpha1/generated_expansion.go index 6479959c..8a33de00 100644 --- a/pkg/client/clientset/versioned/typed/batch/v1alpha1/generated_expansion.go +++ b/pkg/client/clientset/versioned/typed/batch/v1alpha1/generated_expansion.go @@ -17,4 +17,6 @@ limitations under the License. package v1alpha1 +type CronJobExpansion interface{} + type JobExpansion interface{} diff --git a/pkg/client/informers/externalversions/batch/v1alpha1/cronjob.go b/pkg/client/informers/externalversions/batch/v1alpha1/cronjob.go new file mode 100644 index 00000000..9fcdf1bd --- /dev/null +++ b/pkg/client/informers/externalversions/batch/v1alpha1/cronjob.go @@ -0,0 +1,101 @@ +/* +Copyright The Volcano 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 v1alpha1 + +import ( + context "context" + time "time" + + v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + runtime "k8s.io/apimachinery/pkg/runtime" + watch "k8s.io/apimachinery/pkg/watch" + cache "k8s.io/client-go/tools/cache" + apisbatchv1alpha1 "volcano.sh/apis/pkg/apis/batch/v1alpha1" + versioned "volcano.sh/apis/pkg/client/clientset/versioned" + internalinterfaces "volcano.sh/apis/pkg/client/informers/externalversions/internalinterfaces" + batchv1alpha1 "volcano.sh/apis/pkg/client/listers/batch/v1alpha1" +) + +// CronJobInformer provides access to a shared informer and lister for +// CronJobs. +type CronJobInformer interface { + Informer() cache.SharedIndexInformer + Lister() batchv1alpha1.CronJobLister +} + +type cronJobInformer struct { + factory internalinterfaces.SharedInformerFactory + tweakListOptions internalinterfaces.TweakListOptionsFunc + namespace string +} + +// NewCronJobInformer constructs a new informer for CronJob 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 NewCronJobInformer(client versioned.Interface, namespace string, resyncPeriod time.Duration, indexers cache.Indexers) cache.SharedIndexInformer { + return NewFilteredCronJobInformer(client, namespace, resyncPeriod, indexers, nil) +} + +// NewFilteredCronJobInformer constructs a new informer for CronJob 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 NewFilteredCronJobInformer(client versioned.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.BatchV1alpha1().CronJobs(namespace).List(context.Background(), options) + }, + WatchFunc: func(options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.BatchV1alpha1().CronJobs(namespace).Watch(context.Background(), options) + }, + ListWithContextFunc: func(ctx context.Context, options v1.ListOptions) (runtime.Object, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.BatchV1alpha1().CronJobs(namespace).List(ctx, options) + }, + WatchFuncWithContext: func(ctx context.Context, options v1.ListOptions) (watch.Interface, error) { + if tweakListOptions != nil { + tweakListOptions(&options) + } + return client.BatchV1alpha1().CronJobs(namespace).Watch(ctx, options) + }, + }, + &apisbatchv1alpha1.CronJob{}, + resyncPeriod, + indexers, + ) +} + +func (f *cronJobInformer) defaultInformer(client versioned.Interface, resyncPeriod time.Duration) cache.SharedIndexInformer { + return NewFilteredCronJobInformer(client, f.namespace, resyncPeriod, cache.Indexers{cache.NamespaceIndex: cache.MetaNamespaceIndexFunc}, f.tweakListOptions) +} + +func (f *cronJobInformer) Informer() cache.SharedIndexInformer { + return f.factory.InformerFor(&apisbatchv1alpha1.CronJob{}, f.defaultInformer) +} + +func (f *cronJobInformer) Lister() batchv1alpha1.CronJobLister { + return batchv1alpha1.NewCronJobLister(f.Informer().GetIndexer()) +} diff --git a/pkg/client/informers/externalversions/batch/v1alpha1/interface.go b/pkg/client/informers/externalversions/batch/v1alpha1/interface.go index 45a7a99a..e999ab9a 100644 --- a/pkg/client/informers/externalversions/batch/v1alpha1/interface.go +++ b/pkg/client/informers/externalversions/batch/v1alpha1/interface.go @@ -23,6 +23,8 @@ import ( // Interface provides access to all the informers in this group version. type Interface interface { + // CronJobs returns a CronJobInformer. + CronJobs() CronJobInformer // Jobs returns a JobInformer. Jobs() JobInformer } @@ -38,6 +40,11 @@ func New(f internalinterfaces.SharedInformerFactory, namespace string, tweakList return &version{factory: f, namespace: namespace, tweakListOptions: tweakListOptions} } +// CronJobs returns a CronJobInformer. +func (v *version) CronJobs() CronJobInformer { + return &cronJobInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} +} + // Jobs returns a JobInformer. func (v *version) Jobs() JobInformer { return &jobInformer{factory: v.factory, namespace: v.namespace, tweakListOptions: v.tweakListOptions} diff --git a/pkg/client/informers/externalversions/generic.go b/pkg/client/informers/externalversions/generic.go index 45eee673..f462477e 100644 --- a/pkg/client/informers/externalversions/generic.go +++ b/pkg/client/informers/externalversions/generic.go @@ -57,6 +57,8 @@ func (f *genericInformer) Lister() cache.GenericLister { func (f *sharedInformerFactory) ForResource(resource schema.GroupVersionResource) (GenericInformer, error) { switch resource { // Group=batch.volcano.sh, Version=v1alpha1 + case v1alpha1.SchemeGroupVersion.WithResource("cronjobs"): + return &genericInformer{resource: resource.GroupResource(), informer: f.Batch().V1alpha1().CronJobs().Informer()}, nil case v1alpha1.SchemeGroupVersion.WithResource("jobs"): return &genericInformer{resource: resource.GroupResource(), informer: f.Batch().V1alpha1().Jobs().Informer()}, nil diff --git a/pkg/client/listers/batch/v1alpha1/cronjob.go b/pkg/client/listers/batch/v1alpha1/cronjob.go new file mode 100644 index 00000000..c6f5406a --- /dev/null +++ b/pkg/client/listers/batch/v1alpha1/cronjob.go @@ -0,0 +1,69 @@ +/* +Copyright The Volcano 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 v1alpha1 + +import ( + labels "k8s.io/apimachinery/pkg/labels" + listers "k8s.io/client-go/listers" + cache "k8s.io/client-go/tools/cache" + batchv1alpha1 "volcano.sh/apis/pkg/apis/batch/v1alpha1" +) + +// CronJobLister helps list CronJobs. +// All objects returned here must be treated as read-only. +type CronJobLister interface { + // List lists all CronJobs in the indexer. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*batchv1alpha1.CronJob, err error) + // CronJobs returns an object that can list and get CronJobs. + CronJobs(namespace string) CronJobNamespaceLister + CronJobListerExpansion +} + +// cronJobLister implements the CronJobLister interface. +type cronJobLister struct { + listers.ResourceIndexer[*batchv1alpha1.CronJob] +} + +// NewCronJobLister returns a new CronJobLister. +func NewCronJobLister(indexer cache.Indexer) CronJobLister { + return &cronJobLister{listers.New[*batchv1alpha1.CronJob](indexer, batchv1alpha1.Resource("cronjob"))} +} + +// CronJobs returns an object that can list and get CronJobs. +func (s *cronJobLister) CronJobs(namespace string) CronJobNamespaceLister { + return cronJobNamespaceLister{listers.NewNamespaced[*batchv1alpha1.CronJob](s.ResourceIndexer, namespace)} +} + +// CronJobNamespaceLister helps list and get CronJobs. +// All objects returned here must be treated as read-only. +type CronJobNamespaceLister interface { + // List lists all CronJobs in the indexer for a given namespace. + // Objects returned here must be treated as read-only. + List(selector labels.Selector) (ret []*batchv1alpha1.CronJob, err error) + // Get retrieves the CronJob from the indexer for a given namespace and name. + // Objects returned here must be treated as read-only. + Get(name string) (*batchv1alpha1.CronJob, error) + CronJobNamespaceListerExpansion +} + +// cronJobNamespaceLister implements the CronJobNamespaceLister +// interface. +type cronJobNamespaceLister struct { + listers.ResourceIndexer[*batchv1alpha1.CronJob] +} diff --git a/pkg/client/listers/batch/v1alpha1/expansion_generated.go b/pkg/client/listers/batch/v1alpha1/expansion_generated.go index 24780f08..91a95fb0 100644 --- a/pkg/client/listers/batch/v1alpha1/expansion_generated.go +++ b/pkg/client/listers/batch/v1alpha1/expansion_generated.go @@ -17,6 +17,14 @@ limitations under the License. package v1alpha1 +// CronJobListerExpansion allows custom methods to be added to +// CronJobLister. +type CronJobListerExpansion interface{} + +// CronJobNamespaceListerExpansion allows custom methods to be added to +// CronJobNamespaceLister. +type CronJobNamespaceListerExpansion interface{} + // JobListerExpansion allows custom methods to be added to // JobLister. type JobListerExpansion interface{}