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