-
Notifications
You must be signed in to change notification settings - Fork 78
OperatorHub io validator #42
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
Conversation
Pass by value to validator instead of pointer which ignores type
pkg/manifests/bundle.go
Outdated
Dependencies []*Dependency | ||
} | ||
|
||
func (b *Bundle) ObjsToValidate() []interface{} { |
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 would prefer the full name here for func method ObjectsToValidate
for clarity.
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.
Thank you Kevin, for finishing this work. I definitely was underestimating the amount of work here. I have gone through the list of validations and they all matches. Thank you.
Just comments centered around support for the incoming media types. I understand they are not supported by this validation library yet, but a small change might help next time when we have to update this. Thanks.
pkg/manifests/bundleloader.go
Outdated
if b.foundCSV == false { | ||
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 generate bundle from directory %s", b.dir)) |
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.
errs = append(errs, fmt.Errorf("unable to generate bundle from directory %s", b.dir)) | |
errs = append(errs, fmt.Errorf("unable to load bundle from directory %s", b.dir)) |
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.
Looking good so far. A few comments.
} | ||
|
||
if capability, ok := csv.ObjectMeta.Annotations["capabilities"]; ok { | ||
validCapabilities := map[string]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.
This would be clearer as a global variable.
errs = append(errs, fmt.Errorf("csv.Spec.Icon should only have one element")) | ||
} | ||
|
||
for _, icon := range csv.Spec.Icon { |
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.
Should all icons be validated if there should be exactly one? Was this intended to be a no-op if len(csv.Spec.Icon) == 0
?
if categories, ok := csv.ObjectMeta.Annotations["categories"]; ok { | ||
categorySlice := strings.Split(categories, ",") | ||
|
||
validCategories := map[string]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.
Global variable.
return errs | ||
} | ||
|
||
func checkAlmExamples(csv v1alpha1.ClusterServiceVersion) []error { |
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 think this check is already done in the CSV validator.
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.
Correct.
@kevinrizza
Is is possible to enumerate the issues this PR attempts to solve for better summary? |
@anik120 They are enumerated in the commit messages:
Small enough changes that I didn't want to clutter the actual purpose of the pr description, but were needed in order to actually create parity. |
Addressed everyone's feedback as much as possible, please take another look. |
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.
/lgtm
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.
A few nits
*Add new operatorhub.io validator *Add parity for other default validators to operator-courier *Modify verify manifest function to expose example validation call *Expose new bundle function to get all objects for default validators
@estroz okay, updated once again based on feedback. thanks! |
/lgtm |
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.
/lgtm
This pr attempts to create parity in the API project with the existing operator-courier tool's validation command which validates package manifest format operator bundles. It does this only for the new operator bundle image directory format. It updates and resolves several issues with existing validators, as well as introduces a new optional validator for OperatorHub.io validation.
Additionally, it overhauls the internal test
operator-verify
command line tool to serve as an example for import implementation.