|
6 | 6 | console "github.com/pluralsh/console/go/client" |
7 | 7 | consoleclient "github.com/pluralsh/console/go/controller/internal/client" |
8 | 8 | "github.com/pluralsh/console/go/controller/internal/common" |
9 | | - internalerror "github.com/pluralsh/console/go/controller/internal/errors" |
10 | 9 | "github.com/pluralsh/console/go/controller/internal/utils" |
11 | 10 | "github.com/samber/lo" |
12 | 11 | "k8s.io/apimachinery/pkg/api/errors" |
@@ -68,8 +67,7 @@ func (r *ServiceContextReconciler) Reconcile(ctx context.Context, req ctrl.Reque |
68 | 67 | return *result, reterr |
69 | 68 | } |
70 | 69 |
|
71 | | - exists, err := r.handleExisting(serviceContext) |
72 | | - if !exists && err == nil && !serviceContext.DriftDetect() { |
| 70 | + if !r.handleExisting(serviceContext) && !serviceContext.DriftDetect() { |
73 | 71 | utils.MarkCondition(serviceContext.SetCondition, v1alpha1.SynchronizedConditionType, v1.ConditionTrue, v1alpha1.SynchronizedConditionReason, "") |
74 | 72 | utils.MarkCondition(serviceContext.SetCondition, v1alpha1.ReadonlyConditionType, v1.ConditionTrue, v1alpha1.ReadyConditionReason, v1alpha1.ReadonlyTrueConditionMessage.String()) |
75 | 73 | return serviceContext.Spec.Reconciliation.Requeue(), err |
@@ -119,24 +117,21 @@ func (r *ServiceContextReconciler) sync(sc *v1alpha1.ServiceContext, project *v1 |
119 | 117 | return r.ConsoleClient.SaveServiceContext(sc.ConsoleName(), attributes) |
120 | 118 | } |
121 | 119 |
|
122 | | -func (r *ServiceContextReconciler) handleExisting(sc *v1alpha1.ServiceContext) (bool, error) { |
123 | | - apiServiceContext, err := r.ConsoleClient.GetServiceContext(sc.ConsoleName()) |
124 | | - if err != nil || apiServiceContext == nil { |
| 120 | +func (r *ServiceContextReconciler) handleExisting(sc *v1alpha1.ServiceContext) bool { |
| 121 | + apiServiceContext, _ := r.ConsoleClient.GetServiceContext(sc.ConsoleName()) |
| 122 | + if apiServiceContext == nil { |
125 | 123 | utils.MarkCondition(sc.SetCondition, v1alpha1.SynchronizedConditionType, v1.ConditionFalse, v1alpha1.SynchronizedConditionReasonNotFound, v1alpha1.SynchronizedNotFoundConditionMessage.String()) |
126 | 124 | utils.MarkCondition(sc.SetCondition, v1alpha1.ReadyConditionType, v1.ConditionFalse, v1alpha1.ReadyConditionReason, "") |
127 | | - if internalerror.IsNotFound(err) || err == nil { |
128 | | - sc.Status.ID = nil |
129 | | - return false, nil |
130 | | - } |
131 | | - return false, err |
| 125 | + sc.Status.ID = nil |
| 126 | + return false |
132 | 127 | } |
133 | 128 |
|
134 | 129 | sc.Status.ID = &apiServiceContext.ID |
135 | 130 |
|
136 | 131 | utils.MarkCondition(sc.SetCondition, v1alpha1.SynchronizedConditionType, v1.ConditionTrue, v1alpha1.SynchronizedConditionReason, "") |
137 | 132 | utils.MarkCondition(sc.SetCondition, v1alpha1.ReadyConditionType, v1.ConditionTrue, v1alpha1.ReadyConditionReason, "") |
138 | 133 |
|
139 | | - return true, nil |
| 134 | + return true |
140 | 135 | } |
141 | 136 |
|
142 | 137 | func (r *ServiceContextReconciler) addOrRemoveFinalizer(serviceContext *v1alpha1.ServiceContext) *ctrl.Result { |
|
0 commit comments