Skip to content

Commit a698fdf

Browse files
authored
[improvement] Change conditions pkg to use kubernetes metav1 (#590)
1 parent a431a05 commit a698fdf

33 files changed

+820
-386
lines changed

api/v1alpha2/linodecluster_types.go

+15-7
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import (
2020
corev1 "k8s.io/api/core/v1"
2121
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2222
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
23-
"sigs.k8s.io/cluster-api/errors"
2423
)
2524

2625
const (
@@ -73,7 +72,7 @@ type LinodeClusterStatus struct {
7372
// reconciling the LinodeCluster and will contain a succinct value suitable
7473
// for machine interpretation.
7574
// +optional
76-
FailureReason *errors.ClusterStatusError `json:"failureReason,omitempty"`
75+
FailureReason *string `json:"failureReason,omitempty"`
7776

7877
// FailureMessage will be set in the event that there is a terminal problem
7978
// reconciling the LinodeCluster and will contain a more verbose string suitable
@@ -83,7 +82,7 @@ type LinodeClusterStatus struct {
8382

8483
// Conditions defines current service state of the LinodeCluster.
8584
// +optional
86-
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
85+
Conditions []metav1.Condition `json:"conditions,omitempty"`
8786
}
8887

8988
// +kubebuilder:object:root=true
@@ -103,12 +102,21 @@ type LinodeCluster struct {
103102
Status LinodeClusterStatus `json:"status,omitempty"`
104103
}
105104

106-
func (lm *LinodeCluster) GetConditions() clusterv1.Conditions {
107-
return lm.Status.Conditions
105+
func (lc *LinodeCluster) GetConditions() []metav1.Condition {
106+
return lc.Status.Conditions
108107
}
109108

110-
func (lm *LinodeCluster) SetConditions(conditions clusterv1.Conditions) {
111-
lm.Status.Conditions = conditions
109+
func (lc *LinodeCluster) SetConditions(conditions []metav1.Condition) {
110+
lc.Status.Conditions = conditions
111+
}
112+
113+
// We need V1Beta2Conditions helpers to be able to use the conditions package from cluster-api
114+
func (lc *LinodeCluster) GetV1Beta2Conditions() []metav1.Condition {
115+
return lc.GetConditions()
116+
}
117+
118+
func (lc *LinodeCluster) SetV1Beta2Conditions(conditions []metav1.Condition) {
119+
lc.SetConditions(conditions)
112120
}
113121

114122
// NetworkSpec encapsulates Linode networking resources.

api/v1alpha2/linodefirewall_types.go

+12-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package v1alpha2
1919
import (
2020
corev1 "k8s.io/api/core/v1"
2121
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22-
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
2322
)
2423

2524
const (
@@ -118,7 +117,7 @@ type LinodeFirewallStatus struct {
118117

119118
// Conditions defines current service state of the LinodeFirewall.
120119
// +optional
121-
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
120+
Conditions []metav1.Condition `json:"conditions,omitempty"`
122121
}
123122

124123
// +kubebuilder:object:root=true
@@ -137,14 +136,23 @@ type LinodeFirewall struct {
137136
Status LinodeFirewallStatus `json:"status,omitempty"`
138137
}
139138

140-
func (lfw *LinodeFirewall) GetConditions() clusterv1.Conditions {
139+
func (lfw *LinodeFirewall) GetConditions() []metav1.Condition {
141140
return lfw.Status.Conditions
142141
}
143142

144-
func (lfw *LinodeFirewall) SetConditions(conditions clusterv1.Conditions) {
143+
func (lfw *LinodeFirewall) SetConditions(conditions []metav1.Condition) {
145144
lfw.Status.Conditions = conditions
146145
}
147146

147+
// We need V1Beta2Conditions helpers to be able to use the conditions package from cluster-api
148+
func (lfw *LinodeFirewall) GetV1Beta2Conditions() []metav1.Condition {
149+
return lfw.GetConditions()
150+
}
151+
152+
func (lfw *LinodeFirewall) SetV1Beta2Conditions(conditions []metav1.Condition) {
153+
lfw.SetConditions(conditions)
154+
}
155+
148156
//+kubebuilder:object:root=true
149157

150158
// LinodeFirewallList contains a list of LinodeFirewall

api/v1alpha2/linodemachine_types.go

+12-5
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
"k8s.io/apimachinery/pkg/api/resource"
2323
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2424
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
25-
"sigs.k8s.io/cluster-api/errors"
2625
)
2726

2827
const (
@@ -192,7 +191,7 @@ type LinodeMachineStatus struct {
192191
// can be added as events to the Machine object and/or logged in the
193192
// controller's output.
194193
// +optional
195-
FailureReason *errors.MachineStatusError `json:"failureReason,omitempty"`
194+
FailureReason *string `json:"failureReason,omitempty"`
196195

197196
// FailureMessage will be set in the event that there is a terminal problem
198197
// reconciling the Machine and will contain a more verbose string suitable
@@ -215,7 +214,7 @@ type LinodeMachineStatus struct {
215214

216215
// Conditions defines current service state of the LinodeMachine.
217216
// +optional
218-
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
217+
Conditions []metav1.Condition `json:"conditions,omitempty"`
219218
}
220219

221220
// +kubebuilder:object:root=true
@@ -237,14 +236,22 @@ type LinodeMachine struct {
237236
Status LinodeMachineStatus `json:"status,omitempty"`
238237
}
239238

240-
func (lm *LinodeMachine) GetConditions() clusterv1.Conditions {
239+
func (lm *LinodeMachine) GetConditions() []metav1.Condition {
241240
return lm.Status.Conditions
242241
}
243242

244-
func (lm *LinodeMachine) SetConditions(conditions clusterv1.Conditions) {
243+
func (lm *LinodeMachine) SetConditions(conditions []metav1.Condition) {
245244
lm.Status.Conditions = conditions
246245
}
247246

247+
func (lm *LinodeMachine) GetV1Beta2Conditions() []metav1.Condition {
248+
return lm.GetConditions()
249+
}
250+
251+
func (lm *LinodeMachine) SetV1Beta2Conditions(conditions []metav1.Condition) {
252+
lm.SetConditions(conditions)
253+
}
254+
248255
// +kubebuilder:object:root=true
249256

250257
// LinodeMachineList contains a list of LinodeMachine

api/v1alpha2/linodeobjectstoragebucket_types.go

+13-6
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package v1alpha2
1919
import (
2020
corev1 "k8s.io/api/core/v1"
2121
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22-
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
2322
)
2423

2524
type ObjectStorageACL string
@@ -76,7 +75,7 @@ type LinodeObjectStorageBucketStatus struct {
7675

7776
// Conditions specify the service state of the LinodeObjectStorageBucket.
7877
// +optional
79-
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
78+
Conditions []metav1.Condition `json:"conditions,omitempty"`
8079

8180
// Hostname is the address assigned to the bucket.
8281
// +optional
@@ -105,12 +104,20 @@ type LinodeObjectStorageBucket struct {
105104
Status LinodeObjectStorageBucketStatus `json:"status,omitempty"`
106105
}
107106

108-
func (b *LinodeObjectStorageBucket) GetConditions() clusterv1.Conditions {
109-
return b.Status.Conditions
107+
func (losb *LinodeObjectStorageBucket) GetConditions() []metav1.Condition {
108+
return losb.Status.Conditions
110109
}
111110

112-
func (b *LinodeObjectStorageBucket) SetConditions(conditions clusterv1.Conditions) {
113-
b.Status.Conditions = conditions
111+
func (losb *LinodeObjectStorageBucket) SetConditions(conditions []metav1.Condition) {
112+
losb.Status.Conditions = conditions
113+
}
114+
115+
func (losb *LinodeObjectStorageBucket) GetV1Beta2Conditions() []metav1.Condition {
116+
return losb.GetConditions()
117+
}
118+
119+
func (losb *LinodeObjectStorageBucket) SetV1Beta2Conditions(conditions []metav1.Condition) {
120+
losb.SetConditions(conditions)
114121
}
115122

116123
// +kubebuilder:object:root=true

api/v1alpha2/linodeobjectstoragekey_types.go

+13-6
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package v1alpha2
1919
import (
2020
corev1 "k8s.io/api/core/v1"
2121
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22-
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
2322
)
2423

2524
const (
@@ -101,7 +100,7 @@ type LinodeObjectStorageKeyStatus struct {
101100

102101
// Conditions specify the service state of the LinodeObjectStorageKey.
103102
// +optional
104-
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
103+
Conditions []metav1.Condition `json:"conditions,omitempty"`
105104

106105
// CreationTime specifies the creation timestamp for the secret.
107106
// +optional
@@ -133,12 +132,20 @@ type LinodeObjectStorageKey struct {
133132
Status LinodeObjectStorageKeyStatus `json:"status,omitempty"`
134133
}
135134

136-
func (b *LinodeObjectStorageKey) GetConditions() clusterv1.Conditions {
137-
return b.Status.Conditions
135+
func (losk *LinodeObjectStorageKey) GetConditions() []metav1.Condition {
136+
return losk.Status.Conditions
138137
}
139138

140-
func (b *LinodeObjectStorageKey) SetConditions(conditions clusterv1.Conditions) {
141-
b.Status.Conditions = conditions
139+
func (losk *LinodeObjectStorageKey) SetConditions(conditions []metav1.Condition) {
140+
losk.Status.Conditions = conditions
141+
}
142+
143+
func (losk *LinodeObjectStorageKey) GetV1Beta2Conditions() []metav1.Condition {
144+
return losk.GetConditions()
145+
}
146+
147+
func (losk *LinodeObjectStorageKey) SetV1Beta2Conditions(conditions []metav1.Condition) {
148+
losk.SetConditions(conditions)
142149
}
143150

144151
// +kubebuilder:object:root=true

api/v1alpha2/linodeplacementgroup_types.go

+13-6
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package v1alpha2
1919
import (
2020
corev1 "k8s.io/api/core/v1"
2121
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22-
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
2322
)
2423

2524
const (
@@ -100,7 +99,7 @@ type LinodePlacementGroupStatus struct {
10099

101100
// Conditions defines current service state of the LinodePlacementGroup.
102101
// +optional
103-
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
102+
Conditions []metav1.Condition `json:"conditions,omitempty"`
104103
}
105104

106105
// +kubebuilder:object:root=true
@@ -118,12 +117,20 @@ type LinodePlacementGroup struct {
118117
Status LinodePlacementGroupStatus `json:"status,omitempty"`
119118
}
120119

121-
func (lm *LinodePlacementGroup) GetConditions() clusterv1.Conditions {
122-
return lm.Status.Conditions
120+
func (lpg *LinodePlacementGroup) GetConditions() []metav1.Condition {
121+
return lpg.Status.Conditions
123122
}
124123

125-
func (lm *LinodePlacementGroup) SetConditions(conditions clusterv1.Conditions) {
126-
lm.Status.Conditions = conditions
124+
func (lpg *LinodePlacementGroup) SetConditions(conditions []metav1.Condition) {
125+
lpg.Status.Conditions = conditions
126+
}
127+
128+
func (lpg *LinodePlacementGroup) GetV1Beta2Conditions() []metav1.Condition {
129+
return lpg.GetConditions()
130+
}
131+
132+
func (lpg *LinodePlacementGroup) SetV1Beta2Conditions(conditions []metav1.Condition) {
133+
lpg.SetConditions(conditions)
127134
}
128135

129136
// +kubebuilder:object:root=true

api/v1alpha2/linodevpc_types.go

+11-4
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ package v1alpha2
1919
import (
2020
corev1 "k8s.io/api/core/v1"
2121
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
22-
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
2322
)
2423

2524
const (
@@ -105,7 +104,7 @@ type LinodeVPCStatus struct {
105104

106105
// Conditions defines current service state of the LinodeVPC.
107106
// +optional
108-
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
107+
Conditions []metav1.Condition `json:"conditions,omitempty"`
109108
}
110109

111110
// +kubebuilder:object:root=true
@@ -124,14 +123,22 @@ type LinodeVPC struct {
124123
Status LinodeVPCStatus `json:"status,omitempty"`
125124
}
126125

127-
func (lv *LinodeVPC) GetConditions() clusterv1.Conditions {
126+
func (lv *LinodeVPC) GetConditions() []metav1.Condition {
128127
return lv.Status.Conditions
129128
}
130129

131-
func (lv *LinodeVPC) SetConditions(conditions clusterv1.Conditions) {
130+
func (lv *LinodeVPC) SetConditions(conditions []metav1.Condition) {
132131
lv.Status.Conditions = conditions
133132
}
134133

134+
func (lv *LinodeVPC) GetV1Beta2Conditions() []metav1.Condition {
135+
return lv.GetConditions()
136+
}
137+
138+
func (lv *LinodeVPC) SetV1Beta2Conditions(conditions []metav1.Condition) {
139+
lv.SetConditions(conditions)
140+
}
141+
135142
// +kubebuilder:object:root=true
136143

137144
// LinodeVPCList contains a list of LinodeVPC

0 commit comments

Comments
 (0)