Update Source API to v1beta2
The creation of oldConditions, statusableConditions and reconcilableConditions is an adhoc solution to deal with the upstream changes on `pkg/apis/meta`, which are yet to be replicated across other Flux API components. Signed-off-by: Paulo Gomes <paulo.gomes@weave.works>
This commit is contained in:
committed by
Hidde Beydals
parent
a929d24924
commit
e5ede275f8
@@ -20,6 +20,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/fluxcd/pkg/apis/meta"
|
||||
apimeta "k8s.io/apimachinery/pkg/api/meta"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/runtime/schema"
|
||||
@@ -27,8 +28,6 @@ import (
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
"sigs.k8s.io/cli-utils/pkg/object"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
|
||||
"github.com/fluxcd/pkg/apis/meta"
|
||||
)
|
||||
|
||||
// statusable is used to see if a resource is considered ready in the usual way
|
||||
@@ -37,10 +36,26 @@ type statusable interface {
|
||||
// this is implemented by ObjectMeta
|
||||
GetGeneration() int64
|
||||
getObservedGeneration() int64
|
||||
}
|
||||
|
||||
// oldConditions represents the deprecated API which is sunsetting.
|
||||
type oldConditions interface {
|
||||
// this is usually implemented by GOTK API objects because it's used by pkg/apis/meta
|
||||
GetStatusConditions() *[]metav1.Condition
|
||||
}
|
||||
|
||||
func statusableConditions(object statusable) []metav1.Condition {
|
||||
if s, ok := object.(meta.ObjectWithConditions); ok {
|
||||
return s.GetConditions()
|
||||
}
|
||||
|
||||
if s, ok := object.(oldConditions); ok {
|
||||
return *s.GetStatusConditions()
|
||||
}
|
||||
|
||||
return []metav1.Condition{}
|
||||
}
|
||||
|
||||
func isReady(ctx context.Context, kubeClient client.Client,
|
||||
namespacedName types.NamespacedName, object statusable) wait.ConditionFunc {
|
||||
return func() (bool, error) {
|
||||
@@ -54,7 +69,7 @@ func isReady(ctx context.Context, kubeClient client.Client,
|
||||
return false, nil
|
||||
}
|
||||
|
||||
if c := apimeta.FindStatusCondition(*object.GetStatusConditions(), meta.ReadyCondition); c != nil {
|
||||
if c := apimeta.FindStatusCondition(statusableConditions(object), meta.ReadyCondition); c != nil {
|
||||
switch c.Status {
|
||||
case metav1.ConditionTrue:
|
||||
return true, nil
|
||||
|
||||
Reference in New Issue
Block a user