|
| 1 | +/* |
| 2 | +Copyright 2022 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 | + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" |
| 21 | + clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1" |
| 22 | +) |
| 23 | + |
| 24 | +// NOTE: json tags are required. Any new fields you add must have json tags for the fields to be serialized. |
| 25 | + |
| 26 | +const ( |
| 27 | + // IBMPowerVSImageFinalizer allows IBMPowerVSImageReconciler to clean up resources associated with IBMPowerVSImage before |
| 28 | + // removing it from the apiserver. |
| 29 | + IBMPowerVSImageFinalizer = "ibmpowervsimage.infrastructure.cluster.x-k8s.io" |
| 30 | +) |
| 31 | + |
| 32 | +// IBMPowerVSImageSpec defines the desired state of IBMPowerVSImage |
| 33 | +type IBMPowerVSImageSpec struct { |
| 34 | + |
| 35 | + // ClusterName is the name of the Cluster this object belongs to. |
| 36 | + // +kubebuilder:validation:MinLength=1 |
| 37 | + ClusterName string `json:"clusterName"` |
| 38 | + |
| 39 | + // ServiceInstanceID is the id of the power cloud instance where the image will get imported |
| 40 | + ServiceInstanceID string `json:"serviceInstanceID"` |
| 41 | + |
| 42 | + // Cloud Object Storage bucket name; bucket-name[/optional/folder] |
| 43 | + Bucket *string `json:"bucket"` |
| 44 | + |
| 45 | + // Cloud Object Storage image filename |
| 46 | + Object *string `json:"object"` |
| 47 | + |
| 48 | + // Cloud Object Storage region |
| 49 | + Region *string `json:"region"` |
| 50 | + |
| 51 | + // Type of storage, storage pool with the most available space will be selected |
| 52 | + // +kubebuilder:default=tier1 |
| 53 | + // +kubebuilder:validation:Enum=tier1;tier3 |
| 54 | + // +optional |
| 55 | + StorageType string `json:"storageType,omitempty"` |
| 56 | +} |
| 57 | + |
| 58 | +// IBMPowerVSImageStatus defines the observed state of IBMPowerVSImage |
| 59 | +type IBMPowerVSImageStatus struct { |
| 60 | + |
| 61 | + // Ready is true when the provider resource is ready. |
| 62 | + // +optional |
| 63 | + Ready bool `json:"ready,omitempty"` |
| 64 | + |
| 65 | + // ImageID is the id of the imported image |
| 66 | + ImageID string `json:"imageID,omitempty"` |
| 67 | + |
| 68 | + // ImageState is the status of the imported image |
| 69 | + // +optional |
| 70 | + ImageState PowerVSImageState `json:"imageState,omitempty"` |
| 71 | + |
| 72 | + // Conditions defines current service state of the IBMPowerVSImage. |
| 73 | + // +optional |
| 74 | + Conditions clusterv1.Conditions `json:"conditions,omitempty"` |
| 75 | +} |
| 76 | + |
| 77 | +//+kubebuilder:object:root=true |
| 78 | +//+kubebuilder:subresource:status |
| 79 | +//+kubebuilder:storageversion |
| 80 | +// +kubebuilder:printcolumn:name="State",type="string",JSONPath=".status.imageState",description="PowerVS image state" |
| 81 | +// +kubebuilder:printcolumn:name="Ready",type="string",JSONPath=".status.ready",description="Image is ready for IBM PowerVS instances" |
| 82 | + |
| 83 | +// IBMPowerVSImage is the Schema for the ibmpowervsimages API |
| 84 | +type IBMPowerVSImage struct { |
| 85 | + metav1.TypeMeta `json:",inline"` |
| 86 | + metav1.ObjectMeta `json:"metadata,omitempty"` |
| 87 | + |
| 88 | + Spec IBMPowerVSImageSpec `json:"spec,omitempty"` |
| 89 | + Status IBMPowerVSImageStatus `json:"status,omitempty"` |
| 90 | +} |
| 91 | + |
| 92 | +// GetConditions returns the observations of the operational state of the IBMPowerVSImage resource. |
| 93 | +func (r *IBMPowerVSImage) GetConditions() clusterv1.Conditions { |
| 94 | + return r.Status.Conditions |
| 95 | +} |
| 96 | + |
| 97 | +// SetConditions sets the underlying service state of the IBMPowerVSImage to the predescribed clusterv1.Conditions. |
| 98 | +func (r *IBMPowerVSImage) SetConditions(conditions clusterv1.Conditions) { |
| 99 | + r.Status.Conditions = conditions |
| 100 | +} |
| 101 | + |
| 102 | +//+kubebuilder:object:root=true |
| 103 | + |
| 104 | +// IBMPowerVSImageList contains a list of IBMPowerVSImage |
| 105 | +type IBMPowerVSImageList struct { |
| 106 | + metav1.TypeMeta `json:",inline"` |
| 107 | + metav1.ListMeta `json:"metadata,omitempty"` |
| 108 | + Items []IBMPowerVSImage `json:"items"` |
| 109 | +} |
| 110 | + |
| 111 | +func init() { |
| 112 | + SchemeBuilder.Register(&IBMPowerVSImage{}, &IBMPowerVSImageList{}) |
| 113 | +} |
0 commit comments