|
| 1 | +/* |
| 2 | +Copyright 2016 The Kubernetes Authors All rights reserved. |
| 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 v1 |
| 18 | + |
| 19 | +import ( |
| 20 | + batch "k8s.io/api/batch/v2alpha1" |
| 21 | + api "k8s.io/api/core/v1" |
| 22 | + |
| 23 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 24 | +) |
| 25 | + |
| 26 | +// +genclient |
| 27 | +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 28 | + |
| 29 | +// DaemonSetJob represents a DaemonSet Job |
| 30 | +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 31 | +type DaemonSetJob struct { |
| 32 | + metav1.TypeMeta `json:",inline"` |
| 33 | + // Standard object's metadata. |
| 34 | + // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata |
| 35 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 36 | + |
| 37 | + // Spec represents the desired behaviour of the DaemonSetJob. |
| 38 | + Spec DaemonSetJobSpec `json:"spec,omitempty"` |
| 39 | + |
| 40 | + // Status contains the current status off the DaemonSetJob |
| 41 | + Status DaemonSetJobStatus `json:"status,omitempty"` |
| 42 | +} |
| 43 | + |
| 44 | +// DaemonSetJobList implements list of DaemonSetJob. |
| 45 | +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 46 | +type DaemonSetJobList struct { |
| 47 | + metav1.TypeMeta `json:",inline"` |
| 48 | + // Standard list metadata |
| 49 | + // More info: http://releases.k8s.io/HEAD/docs/devel/api-conventions.md#metadata |
| 50 | + metav1.ListMeta `json:"metadata,omitempty"` |
| 51 | + |
| 52 | + // Items is the list of DaemonSetJob |
| 53 | + Items []DaemonSetJob `json:"items"` |
| 54 | +} |
| 55 | + |
| 56 | +// DaemonSetJobSpec contains DaemonSetJob specification |
| 57 | +type DaemonSetJobSpec struct { |
| 58 | + ActiveDeadlineSeconds *int64 `json:"activeDeadlineSeconds,omitempty"` |
| 59 | + |
| 60 | + // JobTemplate contains the job specificaton that should be run in this Workflow. |
| 61 | + // Only one between externalRef and JobTemplate can be set. |
| 62 | + JobTemplate *batch.JobTemplateSpec `json:"jobTemplate,omitempty"` |
| 63 | + |
| 64 | + // NodeSelector use to create DaemonSetJobs only on selected nodes |
| 65 | + NodeSelector *metav1.LabelSelector `json:"nodeSelector,omitempty"` |
| 66 | + |
| 67 | + // Selector for created jobs (if any) |
| 68 | + Selector *metav1.LabelSelector `json:"selector,omitempty"` |
| 69 | +} |
| 70 | + |
| 71 | +// DaemonSetJobStatus represents the status of DaemonSetJob |
| 72 | +type DaemonSetJobStatus struct { |
| 73 | + // Conditions represent the latest available observations of an object's current state. |
| 74 | + Conditions []DaemonSetJobCondition `json:"conditions,omitempty" patchStrategy:"merge" patchMergeKey:"type"` |
| 75 | + |
| 76 | + // StartTime represents time when the workflow was acknowledged by the DaemonSetJob controller |
| 77 | + // It is not guaranteed to be set in happens-before order across separate operations. |
| 78 | + // It is represented in RFC3339 form and is in UTC. |
| 79 | + // StartTime doesn't consider startime of `ExternalReference` |
| 80 | + StartTime *metav1.Time `json:"startTime,omitempty"` |
| 81 | + |
| 82 | + // CompletionTime represents time when the workflow was completed. It is not guaranteed to |
| 83 | + // be set in happens-before order across separate operations. |
| 84 | + // It is represented in RFC3339 form and is in UTC. |
| 85 | + CompletionTime *metav1.Time `json:"completionTime,omitempty"` |
| 86 | + |
| 87 | + // Statuses represent status of different steps |
| 88 | + Statuses []DaemonSetJobNodeJobStatus `json:"statuses"` |
| 89 | +} |
| 90 | + |
| 91 | +// DaemonSetJobNodeJobStatus contains necessary information for the step status |
| 92 | +type DaemonSetJobNodeJobStatus struct { |
| 93 | + // Name represents the Name of the Step |
| 94 | + Name string `json:"name,omitempty"` |
| 95 | + // Complete reports the completion of status` |
| 96 | + Complete bool `json:"complete"` |
| 97 | + // Reference contains a reference to the DaemonSetJob JobNode |
| 98 | + Reference api.ObjectReference `json:"reference"` |
| 99 | +} |
| 100 | + |
| 101 | +// DaemonSetJobCondition represent the condition of the DaemonSetJob |
| 102 | +type DaemonSetJobCondition struct { |
| 103 | + // Type of workflow condition |
| 104 | + Type DaemonSetJobConditionType `json:"type"` |
| 105 | + // Status of the condition, one of True, False, Unknown. |
| 106 | + Status api.ConditionStatus `json:"status"` |
| 107 | + // Last time the condition was checked. |
| 108 | + LastProbeTime metav1.Time `json:"lastProbeTime,omitempty"` |
| 109 | + // Last time the condition transited from one status to another. |
| 110 | + LastTransitionTime metav1.Time `json:"lastTransitionTime,omitempty"` |
| 111 | + // (brief) reason for the condition's last transition. |
| 112 | + Reason string `json:"reason,omitempty"` |
| 113 | + // Human readable message indicating details about last transition. |
| 114 | + Message string `json:"message,omitempty"` |
| 115 | +} |
| 116 | + |
| 117 | +// DaemonSetJobConditionType is the type of DaemonSetJobCondition |
| 118 | +type DaemonSetJobConditionType string |
| 119 | + |
| 120 | +// These are valid conditions of a workflow. |
| 121 | +const ( |
| 122 | + // DaemonSetJobComplete means the workflow has completed its execution. |
| 123 | + DaemonSetJobComplete DaemonSetJobConditionType = "Complete" |
| 124 | + // DaemonSetJobFailed means the workflow has failed its execution. |
| 125 | + DaemonSetJobFailed DaemonSetJobConditionType = "Failed" |
| 126 | +) |
0 commit comments