Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 83
Reduce variable count#453
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 |
|---|---|---|
| @@ -63,25 +63,25 @@ func (b *BundlesAndDepsVariableSource) GetVariables(ctx context.Context) ([]depp | ||
| var head *catalogmetadata.Bundle | ||
| head, bundleQueue = bundleQueue[0], bundleQueue[1:] | ||
| for _, id := range olmvariables.BundleToBundleVariableIDs(head) { | ||
| // ignore bundles that have already been processed | ||
| if _, ok := visited[id]; ok { | ||
| continue | ||
| } | ||
| visited[id] = struct{}{} | ||
| // get bundle dependencies | ||
| dependencies, err := b.filterBundleDependencies(allBundles, head) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("could not determine dependencies for bundle with id '%s': %w", id, err) | ||
| } | ||
| id := olmvariables.BundleVariableID(head) | ||
| // add bundle dependencies to queue for processing | ||
| bundleQueue = append(bundleQueue, dependencies...) | ||
| // ignore bundles that have already been processed | ||
| if _, ok := visited[id]; ok { | ||
| continue | ||
| } | ||
| visited[id] = struct{}{} | ||
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. Can we use
| ||
| // create variable | ||
| variables = append(variables, olmvariables.NewBundleVariable(id, head, dependencies)) | ||
| // get bundle dependencies | ||
| dependencies, err := b.filterBundleDependencies(allBundles, head) | ||
| if err != nil { | ||
| return nil, fmt.Errorf("could not determine dependencies for bundle with id '%s': %w", id, err) | ||
| } | ||
| // add bundle dependencies to queue for processing | ||
| bundleQueue = append(bundleQueue, dependencies...) | ||
| // create variable | ||
| variables = append(variables, olmvariables.NewBundleVariable(head, dependencies)) | ||
| } | ||
| return variables, nil | ||
| @@ -101,11 +101,10 @@ func (b *BundlesAndDepsVariableSource) filterBundleDependencies(allBundles []*ca | ||
| } | ||
| for i := 0; i < len(packageDependencyBundles); i++ { | ||
| bundle := packageDependencyBundles[i] | ||
| for _, id := range olmvariables.BundleToBundleVariableIDs(bundle) { | ||
| if _, ok := added[id]; !ok { | ||
| dependencies = append(dependencies, bundle) | ||
| added[id] = struct{}{} | ||
| } | ||
| id := olmvariables.BundleVariableID(bundle) | ||
| if _, ok := added[id]; !ok { | ||
| dependencies = append(dependencies, bundle) | ||
| added[id] = struct{}{} | ||
| } | ||
| } | ||
| } | ||
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.
Nit: unrelated to this PR, but we can we change the loop variable to be called
dependencyinstead ofbundleso that it doesn't shadow thebundlevariable passed in as a parameter?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.
I'll submit a follow up PR straight after merging this one.
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.
#455