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
Add bundle size validation #163
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: bentito The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
@@ -95,6 +97,14 @@ func validateBundleOperatorHub(bundle *manifests.Bundle, k8sVersion string) erro | |||
return result | |||
} |
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.
Would that be possible?
- We have an attr https://github.com/operator-framework/api/blob/master/pkg/manifests/bundleloader.go#L20 for the size?
- when we load we set the size
- Is the size criteria for ANY bundle built? Is that a limitation for OLM no matter o what? If yes, wdyt about we check it in the BundleValidator https://github.com/operator-framework/api/blob/master/pkg/validation/internal/bundle.go#L28
Also, note that we need to cover the implementations with unit tests as it is done in _test.go files to ensure the checks.
func checkBundleSize(bundle *manifests.Bundle) BundleChecks { | ||
// Crawl the bundle, mounted at ./bundle, and add up the bytes | ||
checks := BundleChecks{errs: []error{}, warns: []error{}} | ||
bundleDir := "." // pretty sure this isn't right, but how to get bundle path from bundle? |
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.
The bundle is load here:
api/pkg/manifests/bundleloader.go
Lines 32 to 46 in b512869
func (b *bundleLoader) LoadBundle() error { | |
errs := make([]error, 0) | |
if err := filepath.Walk(b.dir, collectWalkErrs(b.LoadBundleWalkFunc, &errs)); err != nil { | |
errs = append(errs, err) | |
} | |
if !b.foundCSV { | |
errs = append(errs, fmt.Errorf("unable to find a csv in bundle directory %s", b.dir)) | |
} else if b.bundle == nil { | |
errs = append(errs, fmt.Errorf("unable to load bundle from directory %s", b.dir)) | |
} | |
return utilerrors.NewAggregate(errs) | |
} | |
bundleDir := "."
Initial take on adding a validation of the bundle size. Please let me know how it is wrong ;-)