Skip to content

Commit

Permalink
[improvement] Change conditions pkg to use kubernetes metav1 (#590)
Browse files Browse the repository at this point in the history
  • Loading branch information
komer3 authored Dec 16, 2024
1 parent a431a05 commit a698fdf
Show file tree
Hide file tree
Showing 33 changed files with 820 additions and 386 deletions.
22 changes: 15 additions & 7 deletions api/v1alpha2/linodecluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
"sigs.k8s.io/cluster-api/errors"
)

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

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

// Conditions defines current service state of the LinodeCluster.
// +optional
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
Conditions []metav1.Condition `json:"conditions,omitempty"`
}

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

func (lm *LinodeCluster) GetConditions() clusterv1.Conditions {
return lm.Status.Conditions
func (lc *LinodeCluster) GetConditions() []metav1.Condition {
return lc.Status.Conditions
}

func (lm *LinodeCluster) SetConditions(conditions clusterv1.Conditions) {
lm.Status.Conditions = conditions
func (lc *LinodeCluster) SetConditions(conditions []metav1.Condition) {
lc.Status.Conditions = conditions
}

// We need V1Beta2Conditions helpers to be able to use the conditions package from cluster-api
func (lc *LinodeCluster) GetV1Beta2Conditions() []metav1.Condition {
return lc.GetConditions()
}

func (lc *LinodeCluster) SetV1Beta2Conditions(conditions []metav1.Condition) {
lc.SetConditions(conditions)
}

// NetworkSpec encapsulates Linode networking resources.
Expand Down
16 changes: 12 additions & 4 deletions api/v1alpha2/linodefirewall_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package v1alpha2
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
)

const (
Expand Down Expand Up @@ -118,7 +117,7 @@ type LinodeFirewallStatus struct {

// Conditions defines current service state of the LinodeFirewall.
// +optional
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
Conditions []metav1.Condition `json:"conditions,omitempty"`
}

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

func (lfw *LinodeFirewall) GetConditions() clusterv1.Conditions {
func (lfw *LinodeFirewall) GetConditions() []metav1.Condition {
return lfw.Status.Conditions
}

func (lfw *LinodeFirewall) SetConditions(conditions clusterv1.Conditions) {
func (lfw *LinodeFirewall) SetConditions(conditions []metav1.Condition) {
lfw.Status.Conditions = conditions
}

// We need V1Beta2Conditions helpers to be able to use the conditions package from cluster-api
func (lfw *LinodeFirewall) GetV1Beta2Conditions() []metav1.Condition {
return lfw.GetConditions()
}

func (lfw *LinodeFirewall) SetV1Beta2Conditions(conditions []metav1.Condition) {
lfw.SetConditions(conditions)
}

//+kubebuilder:object:root=true

// LinodeFirewallList contains a list of LinodeFirewall
Expand Down
17 changes: 12 additions & 5 deletions api/v1alpha2/linodemachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
"sigs.k8s.io/cluster-api/errors"
)

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

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

// Conditions defines current service state of the LinodeMachine.
// +optional
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
Conditions []metav1.Condition `json:"conditions,omitempty"`
}

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

func (lm *LinodeMachine) GetConditions() clusterv1.Conditions {
func (lm *LinodeMachine) GetConditions() []metav1.Condition {
return lm.Status.Conditions
}

func (lm *LinodeMachine) SetConditions(conditions clusterv1.Conditions) {
func (lm *LinodeMachine) SetConditions(conditions []metav1.Condition) {
lm.Status.Conditions = conditions
}

func (lm *LinodeMachine) GetV1Beta2Conditions() []metav1.Condition {
return lm.GetConditions()
}

func (lm *LinodeMachine) SetV1Beta2Conditions(conditions []metav1.Condition) {
lm.SetConditions(conditions)
}

// +kubebuilder:object:root=true

// LinodeMachineList contains a list of LinodeMachine
Expand Down
19 changes: 13 additions & 6 deletions api/v1alpha2/linodeobjectstoragebucket_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package v1alpha2
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
)

type ObjectStorageACL string
Expand Down Expand Up @@ -76,7 +75,7 @@ type LinodeObjectStorageBucketStatus struct {

// Conditions specify the service state of the LinodeObjectStorageBucket.
// +optional
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
Conditions []metav1.Condition `json:"conditions,omitempty"`

// Hostname is the address assigned to the bucket.
// +optional
Expand Down Expand Up @@ -105,12 +104,20 @@ type LinodeObjectStorageBucket struct {
Status LinodeObjectStorageBucketStatus `json:"status,omitempty"`
}

func (b *LinodeObjectStorageBucket) GetConditions() clusterv1.Conditions {
return b.Status.Conditions
func (losb *LinodeObjectStorageBucket) GetConditions() []metav1.Condition {
return losb.Status.Conditions
}

func (b *LinodeObjectStorageBucket) SetConditions(conditions clusterv1.Conditions) {
b.Status.Conditions = conditions
func (losb *LinodeObjectStorageBucket) SetConditions(conditions []metav1.Condition) {
losb.Status.Conditions = conditions
}

func (losb *LinodeObjectStorageBucket) GetV1Beta2Conditions() []metav1.Condition {
return losb.GetConditions()
}

func (losb *LinodeObjectStorageBucket) SetV1Beta2Conditions(conditions []metav1.Condition) {
losb.SetConditions(conditions)
}

// +kubebuilder:object:root=true
Expand Down
19 changes: 13 additions & 6 deletions api/v1alpha2/linodeobjectstoragekey_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package v1alpha2
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
)

const (
Expand Down Expand Up @@ -101,7 +100,7 @@ type LinodeObjectStorageKeyStatus struct {

// Conditions specify the service state of the LinodeObjectStorageKey.
// +optional
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
Conditions []metav1.Condition `json:"conditions,omitempty"`

// CreationTime specifies the creation timestamp for the secret.
// +optional
Expand Down Expand Up @@ -133,12 +132,20 @@ type LinodeObjectStorageKey struct {
Status LinodeObjectStorageKeyStatus `json:"status,omitempty"`
}

func (b *LinodeObjectStorageKey) GetConditions() clusterv1.Conditions {
return b.Status.Conditions
func (losk *LinodeObjectStorageKey) GetConditions() []metav1.Condition {
return losk.Status.Conditions
}

func (b *LinodeObjectStorageKey) SetConditions(conditions clusterv1.Conditions) {
b.Status.Conditions = conditions
func (losk *LinodeObjectStorageKey) SetConditions(conditions []metav1.Condition) {
losk.Status.Conditions = conditions
}

func (losk *LinodeObjectStorageKey) GetV1Beta2Conditions() []metav1.Condition {
return losk.GetConditions()
}

func (losk *LinodeObjectStorageKey) SetV1Beta2Conditions(conditions []metav1.Condition) {
losk.SetConditions(conditions)
}

// +kubebuilder:object:root=true
Expand Down
19 changes: 13 additions & 6 deletions api/v1alpha2/linodeplacementgroup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package v1alpha2
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
)

const (
Expand Down Expand Up @@ -100,7 +99,7 @@ type LinodePlacementGroupStatus struct {

// Conditions defines current service state of the LinodePlacementGroup.
// +optional
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
Conditions []metav1.Condition `json:"conditions,omitempty"`
}

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

func (lm *LinodePlacementGroup) GetConditions() clusterv1.Conditions {
return lm.Status.Conditions
func (lpg *LinodePlacementGroup) GetConditions() []metav1.Condition {
return lpg.Status.Conditions
}

func (lm *LinodePlacementGroup) SetConditions(conditions clusterv1.Conditions) {
lm.Status.Conditions = conditions
func (lpg *LinodePlacementGroup) SetConditions(conditions []metav1.Condition) {
lpg.Status.Conditions = conditions
}

func (lpg *LinodePlacementGroup) GetV1Beta2Conditions() []metav1.Condition {
return lpg.GetConditions()
}

func (lpg *LinodePlacementGroup) SetV1Beta2Conditions(conditions []metav1.Condition) {
lpg.SetConditions(conditions)
}

// +kubebuilder:object:root=true
Expand Down
15 changes: 11 additions & 4 deletions api/v1alpha2/linodevpc_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package v1alpha2
import (
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
)

const (
Expand Down Expand Up @@ -105,7 +104,7 @@ type LinodeVPCStatus struct {

// Conditions defines current service state of the LinodeVPC.
// +optional
Conditions clusterv1.Conditions `json:"conditions,omitempty"`
Conditions []metav1.Condition `json:"conditions,omitempty"`
}

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

func (lv *LinodeVPC) GetConditions() clusterv1.Conditions {
func (lv *LinodeVPC) GetConditions() []metav1.Condition {
return lv.Status.Conditions
}

func (lv *LinodeVPC) SetConditions(conditions clusterv1.Conditions) {
func (lv *LinodeVPC) SetConditions(conditions []metav1.Condition) {
lv.Status.Conditions = conditions
}

func (lv *LinodeVPC) GetV1Beta2Conditions() []metav1.Condition {
return lv.GetConditions()
}

func (lv *LinodeVPC) SetV1Beta2Conditions(conditions []metav1.Condition) {
lv.SetConditions(conditions)
}

// +kubebuilder:object:root=true

// LinodeVPCList contains a list of LinodeVPC
Expand Down
Loading

0 comments on commit a698fdf

Please sign in to comment.