Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 83
Add annotations to BundleDeployment#442
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -5,6 +5,7 @@ import ( | ||
| "fmt" | ||
| "sort" | ||
| mmsemver "github.com/Masterminds/semver/v3" | ||
| "github.com/operator-framework/deppy/pkg/deppy" | ||
| "github.com/operator-framework/deppy/pkg/deppy/input" | ||
| @@ -19,7 +20,9 @@ var _ input.VariableSource = &InstalledPackageVariableSource{} | ||
| type InstalledPackageVariableSource struct { | ||
| catalogClient BundleProvider | ||
| successors successorsFunc | ||
| bundleImage string | ||
| pkgName string | ||
| bundleName string | ||
| bundleVersion string | ||
| } | ||
| func (r *InstalledPackageVariableSource) GetVariables(ctx context.Context) ([]deppy.Variable, error) { | ||
| @@ -28,18 +31,23 @@ func (r *InstalledPackageVariableSource) GetVariables(ctx context.Context) ([]de | ||
| return nil, err | ||
| } | ||
| vr, err := mmsemver.NewConstraint(r.bundleVersion) | ||
| if err != nil { | ||
| return nil, err | ||
| } | ||
| // find corresponding bundle for the installed content | ||
| resultSet := catalogfilter.Filter(allBundles, catalogfilter.WithBundleImage(r.bundleImage)) | ||
| resultSet := catalogfilter.Filter(allBundles, catalogfilter.And( | ||
| catalogfilter.WithPackageName(r.pkgName), | ||
| catalogfilter.WithName(r.bundleName), | ||
| catalogfilter.InMastermindsSemverRange(vr), | ||
| )) | ||
| if len(resultSet) == 0 { | ||
| return nil, r.notFoundError() | ||
| return nil, fmt.Errorf("bundle for package %q with name %q at version %q not found", r.pkgName, r.bundleName, r.bundleVersion) | ||
| } | ||
| if len(resultSet) > 1 { | ||
| return nil, fmt.Errorf("more than one bundle for package %q with name %q at version %q found", r.pkgName, r.bundleName, r.bundleVersion) | ||
| } | ||
| // TODO: fast follow - we should check whether we are already supporting the channel attribute in the operator spec. | ||
| // if so, we should take the value from spec of the operator CR in the owner ref of the bundle deployment. | ||
| // If that channel is set, we need to update the filter above to filter by channel as well. | ||
Comment on lines
-37
to
-39
MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe this is no longer relevant given that we filter by package name, bundle name and bundle version. | ||
| sort.SliceStable(resultSet, func(i, j int) bool { | ||
| return catalogsort.ByVersion(resultSet[i], resultSet[j]) | ||
| }) | ||
Comment on lines
-40
to
-42
MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we no longer need sorting by version since we filter bundles by bundle version amongst other things. I assume previously we were doing sorting beucase multiple bundles could in theory use the same image (.e.g some sort of fake version).
| ||
| installedBundle := resultSet[0] | ||
| upgradeEdges, err := r.successors(allBundles, installedBundle) | ||
| @@ -54,16 +62,14 @@ func (r *InstalledPackageVariableSource) GetVariables(ctx context.Context) ([]de | ||
| }, nil | ||
| } | ||
| func (r *InstalledPackageVariableSource) notFoundError() error { | ||
| return fmt.Errorf("bundleImage %q not found", r.bundleImage) | ||
| } | ||
| func NewInstalledPackageVariableSource(catalogClient BundleProvider, bundleImage string) (*InstalledPackageVariableSource, error) { | ||
| func NewInstalledPackageVariableSource(catalogClient BundleProvider, pkgName, bundleName, bundleVersion string) *InstalledPackageVariableSource { | ||
| return &InstalledPackageVariableSource{ | ||
| catalogClient: catalogClient, | ||
| bundleImage: bundleImage, | ||
| successors: legacySemanticsSuccessors, | ||
| }, nil | ||
| pkgName: pkgName, | ||
| bundleName: bundleName, | ||
| bundleVersion: bundleVersion, | ||
| } | ||
| } | ||
| // successorsFunc must return successors of a currently installed bundle | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to care about bundle deployments created directly? These annotations will only be present on bundle deployments reconciled by operator-controller.
Edit: I think we do need to care so this whole thing might not fly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now, I don't think we need to care, at least in this context.
I sorta think this context is: is there a BD for this operator already? (And maybe that means we should have a label on the BD like
operators.operatorframework.io/operator-namewhose value isOperator.metadata.name?Perhaps in the future, there's a separate feature that helps the resolver become aware of other BDs, but I don't think we need to do that now.