Skip to content

Commit

Permalink
fixup! ✨ Plumb the Extension API
Browse files Browse the repository at this point in the history
Signed-off-by: Todd Short <tshort@redhat.com>
  • Loading branch information
tmshort committed Feb 7, 2024
1 parent 4324b88 commit b67d5ea
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 15 deletions.
6 changes: 1 addition & 5 deletions api/v1alpha1/extension_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions internal/controllers/extension_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Expand All @@ -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
}
Expand Down
14 changes: 7 additions & 7 deletions internal/controllers/validators/extension_validators.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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
Expand Down

0 comments on commit b67d5ea

Please sign in to comment.