|
| 1 | +/* |
| 2 | +Copyright 2018 The Knative 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 v1alpha1 |
| 18 | + |
| 19 | +import ( |
| 20 | + "github.com/knative/pkg/apis" |
| 21 | + "github.com/knative/pkg/webhook" |
| 22 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 23 | +) |
| 24 | + |
| 25 | +func (t *ClusterTask) TaskSpec() TaskSpec { |
| 26 | + return t.Spec |
| 27 | +} |
| 28 | + |
| 29 | +func (t *ClusterTask) TaskMetadata() metav1.ObjectMeta { |
| 30 | + return t.ObjectMeta |
| 31 | +} |
| 32 | + |
| 33 | +func (t *ClusterTask) Copy() TaskInterface { |
| 34 | + return t.DeepCopy() |
| 35 | +} |
| 36 | + |
| 37 | +func (t *ClusterTask) SetDefaults() { |
| 38 | + t.Spec.SetDefaults() |
| 39 | +} |
| 40 | + |
| 41 | +// Check that Task may be validated and defaulted. |
| 42 | +var _ apis.Validatable = (*ClusterTask)(nil) |
| 43 | +var _ apis.Defaultable = (*ClusterTask)(nil) |
| 44 | + |
| 45 | +// Assert that Task implements the GenericCRD interface. |
| 46 | +var _ webhook.GenericCRD = (*ClusterTask)(nil) |
| 47 | + |
| 48 | +// +genclient |
| 49 | +// +genclient:noStatus |
| 50 | +// +genclient:nonNamespaced |
| 51 | +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 52 | + |
| 53 | +// ClusterTask is a Task with a cluster scope |
| 54 | +type ClusterTask struct { |
| 55 | + metav1.TypeMeta `json:",inline"` |
| 56 | + // +optional |
| 57 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 58 | + |
| 59 | + // Spec holds the desired state of the Task from the client |
| 60 | + // +optional |
| 61 | + Spec TaskSpec `json:"spec,omitempty"` |
| 62 | +} |
| 63 | + |
| 64 | +// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object |
| 65 | + |
| 66 | +// ClusterTaskList contains a list of ClusterTask |
| 67 | +type ClusterTaskList struct { |
| 68 | + metav1.TypeMeta `json:",inline"` |
| 69 | + // +optional |
| 70 | + metav1.ListMeta `json:"metadata,omitempty"` |
| 71 | + Items []Task `json:"items"` |
| 72 | +} |
0 commit comments