Code refactoring for bpa operator
[icn.git] / cmd / bpa-operator / vendor / k8s.io / api / batch / v1beta1 / types.go
1 /*
2 Copyright 2017 The Kubernetes Authors.
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8     http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 */
16
17 package v1beta1
18
19 import (
20         batchv1 "k8s.io/api/batch/v1"
21         "k8s.io/api/core/v1"
22         metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
23 )
24
25 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
26
27 // JobTemplate describes a template for creating copies of a predefined pod.
28 type JobTemplate struct {
29         metav1.TypeMeta `json:",inline"`
30         // Standard object's metadata.
31         // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
32         // +optional
33         metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
34
35         // Defines jobs that will be created from this template.
36         // https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status
37         // +optional
38         Template JobTemplateSpec `json:"template,omitempty" protobuf:"bytes,2,opt,name=template"`
39 }
40
41 // JobTemplateSpec describes the data a Job should have when created from a template
42 type JobTemplateSpec struct {
43         // Standard object's metadata of the jobs created from this template.
44         // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
45         // +optional
46         metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
47
48         // Specification of the desired behavior of the job.
49         // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status
50         // +optional
51         Spec batchv1.JobSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
52 }
53
54 // +genclient
55 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
56
57 // CronJob represents the configuration of a single cron job.
58 type CronJob struct {
59         metav1.TypeMeta `json:",inline"`
60         // Standard object's metadata.
61         // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
62         // +optional
63         metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
64
65         // Specification of the desired behavior of a cron job, including the schedule.
66         // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status
67         // +optional
68         Spec CronJobSpec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"`
69
70         // Current status of a cron job.
71         // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#spec-and-status
72         // +optional
73         Status CronJobStatus `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"`
74 }
75
76 // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
77
78 // CronJobList is a collection of cron jobs.
79 type CronJobList struct {
80         metav1.TypeMeta `json:",inline"`
81
82         // Standard list metadata.
83         // More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#metadata
84         // +optional
85         metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"`
86
87         // items is the list of CronJobs.
88         Items []CronJob `json:"items" protobuf:"bytes,2,rep,name=items"`
89 }
90
91 // CronJobSpec describes how the job execution will look like and when it will actually run.
92 type CronJobSpec struct {
93
94         // The schedule in Cron format, see https://en.wikipedia.org/wiki/Cron.
95         Schedule string `json:"schedule" protobuf:"bytes,1,opt,name=schedule"`
96
97         // Optional deadline in seconds for starting the job if it misses scheduled
98         // time for any reason.  Missed jobs executions will be counted as failed ones.
99         // +optional
100         StartingDeadlineSeconds *int64 `json:"startingDeadlineSeconds,omitempty" protobuf:"varint,2,opt,name=startingDeadlineSeconds"`
101
102         // Specifies how to treat concurrent executions of a Job.
103         // Valid values are:
104         // - "Allow" (default): allows CronJobs to run concurrently;
105         // - "Forbid": forbids concurrent runs, skipping next run if previous run hasn't finished yet;
106         // - "Replace": cancels currently running job and replaces it with a new one
107         // +optional
108         ConcurrencyPolicy ConcurrencyPolicy `json:"concurrencyPolicy,omitempty" protobuf:"bytes,3,opt,name=concurrencyPolicy,casttype=ConcurrencyPolicy"`
109
110         // This flag tells the controller to suspend subsequent executions, it does
111         // not apply to already started executions.  Defaults to false.
112         // +optional
113         Suspend *bool `json:"suspend,omitempty" protobuf:"varint,4,opt,name=suspend"`
114
115         // Specifies the job that will be created when executing a CronJob.
116         JobTemplate JobTemplateSpec `json:"jobTemplate" protobuf:"bytes,5,opt,name=jobTemplate"`
117
118         // The number of successful finished jobs to retain.
119         // This is a pointer to distinguish between explicit zero and not specified.
120         // Defaults to 3.
121         // +optional
122         SuccessfulJobsHistoryLimit *int32 `json:"successfulJobsHistoryLimit,omitempty" protobuf:"varint,6,opt,name=successfulJobsHistoryLimit"`
123
124         // The number of failed finished jobs to retain.
125         // This is a pointer to distinguish between explicit zero and not specified.
126         // Defaults to 1.
127         // +optional
128         FailedJobsHistoryLimit *int32 `json:"failedJobsHistoryLimit,omitempty" protobuf:"varint,7,opt,name=failedJobsHistoryLimit"`
129 }
130
131 // ConcurrencyPolicy describes how the job will be handled.
132 // Only one of the following concurrent policies may be specified.
133 // If none of the following policies is specified, the default one
134 // is AllowConcurrent.
135 type ConcurrencyPolicy string
136
137 const (
138         // AllowConcurrent allows CronJobs to run concurrently.
139         AllowConcurrent ConcurrencyPolicy = "Allow"
140
141         // ForbidConcurrent forbids concurrent runs, skipping next run if previous
142         // hasn't finished yet.
143         ForbidConcurrent ConcurrencyPolicy = "Forbid"
144
145         // ReplaceConcurrent cancels currently running job and replaces it with a new one.
146         ReplaceConcurrent ConcurrencyPolicy = "Replace"
147 )
148
149 // CronJobStatus represents the current state of a cron job.
150 type CronJobStatus struct {
151         // A list of pointers to currently running jobs.
152         // +optional
153         Active []v1.ObjectReference `json:"active,omitempty" protobuf:"bytes,1,rep,name=active"`
154
155         // Information when was the last time the job was successfully scheduled.
156         // +optional
157         LastScheduleTime *metav1.Time `json:"lastScheduleTime,omitempty" protobuf:"bytes,4,opt,name=lastScheduleTime"`
158 }