From b67d5ea3724ca1b91a1bddd03488fc4ef25f0392 Mon Sep 17 00:00:00 2001 From: Todd Short Date: Wed, 7 Feb 2024 14:43:25 -0500 Subject: [PATCH] fixup! :sparkles: Plumb the Extension API Signed-off-by: Todd Short --- api/v1alpha1/extension_types.go | 6 +----- internal/controllers/extension_controller.go | 5 ++--- .../controllers/validators/extension_validators.go | 14 +++++++------- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/api/v1alpha1/extension_types.go b/api/v1alpha1/extension_types.go index b34d70cc6..69424c860 100644 --- a/api/v1alpha1/extension_types.go +++ b/api/v1alpha1/extension_types.go @@ -60,14 +60,10 @@ type ExtensionSourcePackage struct { UpgradeConstraintPolicy UpgradeConstraintPolicy `json:"upgradeConstraintPolicy,omitempty"` } -// TODO: Implement ExtensionSourceDirect containing a URL or other reference mechanism - +// ExtensionSource defines the source for this Extension, right now, only a package is supported. type ExtensionSource struct { // A source package defined by a name, version and/or channel Package *ExtensionSourcePackage `json:"package,omitempty"` - - // A direct package defined by a URL - // TODO: Direct *ExtensionSourceDirect `json:"direct,omitempty"` } // ExtensionSpec defines the desired state of Extension diff --git a/internal/controllers/extension_controller.go b/internal/controllers/extension_controller.go index 17eb2f9cb..3989d3619 100644 --- a/internal/controllers/extension_controller.go +++ b/internal/controllers/extension_controller.go @@ -134,7 +134,6 @@ func (r *ExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alpha1.Ext } // run resolution - // TODO: Add `selection` return from Solve() _, err = r.Resolver.Solve(vars) if err != nil { ext.Status.InstalledBundleResource = "" @@ -147,8 +146,8 @@ func (r *ExtensionReconciler) reconcile(ctx context.Context, ext *ocv1alpha1.Ext } // TODO: kapp-controller integration - // TODO: lookup the bundle in the solution that corresponds to the Extension's desired Source - // TODO: set the status of the Extension based on the respective deployed application status conditions. + // * lookup the bundle in the solution/selection that corresponds to the Extension's desired Source + // * set the status of the Extension based on the respective deployed application status conditions. return ctrl.Result{}, nil } diff --git a/internal/controllers/validators/extension_validators.go b/internal/controllers/validators/extension_validators.go index e85802e77..61467690b 100644 --- a/internal/controllers/validators/extension_validators.go +++ b/internal/controllers/validators/extension_validators.go @@ -29,8 +29,8 @@ func validatePackageSemver(e *ocv1alpha1.Extension) error { } // validatePackageOrDirect validates that one or the other exists -// TODO: For now, this just makes sure there's a Package, as Direct has not been defined -func validatePackageOrDirect(e *ocv1alpha1.Extension) error { +// For now, this just makes sure there's a Package, as no other Source type has been defined +func validatePackage(e *ocv1alpha1.Extension) error { pkg := e.GetPackageSpec() if pkg == nil { return fmt.Errorf("package not found") @@ -42,13 +42,13 @@ func validatePackageOrDirect(e *ocv1alpha1.Extension) error { func ValidateExtensionSpec(e *ocv1alpha1.Extension) error { validators := []extensionCRValidatorFunc{ validatePackageSemver, - validatePackageOrDirect, + validatePackage, } - // TODO: currently we only have a two validators, but more will likely be added in the future - // we need to make a decision on whether we want to run all validators or stop at the first error. If the the former, - // we should consider how to present this to the user in a way that is easy to understand and fix. - // this issue is tracked here: https://github.com/operator-framework/operator-controller/issues/167 + // Currently we only have a two validators, but more will likely be added in the future + // we need to make a decision on whether we want to run all validators or stop at the first error. If the the former, + // we should consider how to present this to the user in a way that is easy to understand and fix. + // this issue is tracked here: https://github.com/operator-framework/operator-controller/issues/167 for _, validator := range validators { if err := validator(e); err != nil { return err