@@ -78,17 +78,6 @@ import (
78
78
"github.com/operator-framework/operator-controller/internal/labels"
79
79
)
80
80
81
- // ResolutionError type
82
- // If a more specific error type needs to be distinguished,
83
- // add another type here
84
- type ResolutionError struct {
85
- message string
86
- }
87
-
88
- func (e ResolutionError ) Error () string {
89
- return e .message
90
- }
91
-
92
81
// ClusterExtensionReconciler reconciles a ClusterExtension object
93
82
type ClusterExtensionReconciler struct {
94
83
client.Client
@@ -207,15 +196,11 @@ func (r *ClusterExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alp
207
196
// run resolution
208
197
bundle , err := r .resolve (ctx , * ext )
209
198
if err != nil {
199
+ // Note: We don't distinguish between resolution-specific errors and generic errors
210
200
ext .Status .ResolvedBundle = nil
211
201
ext .Status .InstalledBundle = nil
212
202
setResolvedStatusConditionFailed (& ext .Status .Conditions , err .Error (), ext .GetGeneration ())
213
- // TODO: indicate Progressing state based on whether error is ResolutionError or not
214
- if errors .As (err , & ResolutionError {}) {
215
- ensureAllConditionsWithReason (ext , ocv1alpha1 .ReasonResolutionFailed , err .Error ())
216
- } else {
217
- ensureAllConditionsWithReason (ext , ocv1alpha1 .ReasonInstallationStatusUnknown , err .Error ())
218
- }
203
+ ensureAllConditionsWithReason (ext , ocv1alpha1 .ReasonResolutionFailed , err .Error ())
219
204
return ctrl.Result {}, err
220
205
}
221
206
@@ -405,7 +390,7 @@ func (r *ClusterExtensionReconciler) resolve(ctx context.Context, ext ocv1alpha1
405
390
if versionRange != "" {
406
391
vr , err := mmsemver .NewConstraint (versionRange )
407
392
if err != nil {
408
- return nil , ResolutionError { fmt .Sprintf ("invalid version range %q: %v " , versionRange , err )}
393
+ return nil , fmt .Errorf ("invalid version range %q: %w " , versionRange , err )
409
394
}
410
395
predicates = append (predicates , catalogfilter .InMastermindsSemverRange (vr ))
411
396
}
@@ -432,13 +417,13 @@ func (r *ClusterExtensionReconciler) resolve(ctx context.Context, ext ocv1alpha1
432
417
if len (resultSet ) == 0 {
433
418
switch {
434
419
case versionRange != "" && channelName != "" :
435
- return nil , ResolutionError { fmt .Sprintf ("%sno package %q matching version %q in channel %q found" , upgradeErrorPrefix , packageName , versionRange , channelName )}
420
+ return nil , fmt .Errorf ("%sno package %q matching version %q in channel %q found" , upgradeErrorPrefix , packageName , versionRange , channelName )
436
421
case versionRange != "" :
437
- return nil , ResolutionError { fmt .Sprintf ("%sno package %q matching version %q found" , upgradeErrorPrefix , packageName , versionRange )}
422
+ return nil , fmt .Errorf ("%sno package %q matching version %q found" , upgradeErrorPrefix , packageName , versionRange )
438
423
case channelName != "" :
439
- return nil , ResolutionError { fmt .Sprintf ("%sno package %q in channel %q found" , upgradeErrorPrefix , packageName , channelName )}
424
+ return nil , fmt .Errorf ("%sno package %q in channel %q found" , upgradeErrorPrefix , packageName , channelName )
440
425
default :
441
- return nil , ResolutionError { fmt .Sprintf ("%sno package %q found" , upgradeErrorPrefix , packageName )}
426
+ return nil , fmt .Errorf ("%sno package %q found" , upgradeErrorPrefix , packageName )
442
427
}
443
428
}
444
429
0 commit comments