-
Notifications
You must be signed in to change notification settings - Fork 15
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
Refactor decouple #188
Refactor decouple #188
Conversation
On this commit all capAudit objects and methods were changed to lower case in order to be non exported. The capAudit interface was removed also to prevent confusion once the only interface to this package is CapAuditor and not capAudit. CapAuditor now should be upper case and exported. More on the documentation commit. Signed-off-by: acmenezes <[email protected]>
We don't need a builder for this simple object and buildWorkQueue can be run as the first step of an audit. That makes the code simpler and easier to understand. All flag data interesting to capability package can be passed by using the CapAuditor object and add to it as needed. It makes CapAuditor the single entry point of flag data to the capabiltiy package. Signed-off-by: acmenezes <[email protected]>
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.
looks good other than some cosmetic nits
@@ -90,5 +100,4 @@ func init() { | |||
flags.StringSliceVar(&checkflags.AuditPlan, "auditplan", defaultAuditPlan, "audit plan is the ordered list of operator test functions to be called during a capability audit.") | |||
flags.BoolVar(&checkflags.ListPackages, "list-packages", false, "list packages in the catalog") | |||
flags.StringSliceVar(&checkflags.FilterPackages, "filter-packages", []string{}, "a list of package(s) which limits audits and/or other flag(s) output") | |||
flags.BoolVar(&checkflags.AllInstallModes, "all-installmodes", false, "when set, all install modes supported by an operator will be tested") |
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.
Take note of any functionality removed. Here I can see the functionality to test all install modes has been removed.
Create a new issue if you want this reworked at a future time.
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.
Totally agree. Here is the new issue: Enable all supported install modes testing #189
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.
@acmenezes , regarding the name convention for parameters, should we create them with the -
(i.e --list-packages
) or not like --auditplan
?
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.
My vote would be to include the '-'.
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.
There we go 9929e85 - dash included.
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.
Just a few comments.
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.
Everything else looks great. Tested.
Signed-off-by: acmenezes <[email protected]>
Signed-off-by: acmenezes <[email protected]>
Signed-off-by: acmenezes <[email protected]>
Signed-off-by: acmenezes <[email protected]>
Signed-off-by: acmenezes <[email protected]>
Signed-off-by: acmenezes <[email protected]>
This allow for testing as well as other implementations of writers such as writing to databases when we develop a more solid reporting mechanism. - Reports now are simpler functions taking io.writer - operand and operator install will handle file creation and where to write reports to Signed-off-by: acmenezes <[email protected]>
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 changes and general comments.
@@ -90,5 +100,4 @@ func init() { | |||
flags.StringSliceVar(&checkflags.AuditPlan, "auditplan", defaultAuditPlan, "audit plan is the ordered list of operator test functions to be called during a capability audit.") | |||
flags.BoolVar(&checkflags.ListPackages, "list-packages", false, "list packages in the catalog") | |||
flags.StringSliceVar(&checkflags.FilterPackages, "filter-packages", []string{}, "a list of package(s) which limits audits and/or other flag(s) output") | |||
flags.BoolVar(&checkflags.AllInstallModes, "all-installmodes", false, "when set, all install modes supported by an operator will be tested") |
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.
My vote would be to include the '-'.
@@ -105,7 +106,15 @@ func (ca *CapAudit) OperandInstall() error { | |||
logger.Debug("exiting OperandInstall since no ALM_Examples found in CSV") | |||
} | |||
|
|||
ca.Report(OperandInstallRptOptionFile{FilePath: "operand_install_report.json"}, OperandInstallRptOptionPrint{}) | |||
file, err := os.OpenFile("operand_install_report.json", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) |
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.
Creating a report doesn't seem to be the job of this function. It should either be passed in an io.Reader, or return the data for someone else to log/report.
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 is not a blocker. Just wanted to point this out for future discussion.
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.
Hi @bcrochet the ca or capAudit object contains the data. And the method. And it's lifecycle ends with this install function. What do you suggest?
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.
Don't have a suggestion just yet. I need to get a fuller understanding of the flow here.
logger.Debugf("Error creating subscriptions: %w", err) | ||
return err | ||
} | ||
|
||
// Get a Succeeded or Failed CSV with one minute timeout | ||
ca.Csv, err = ca.Client.GetCompletedCsvWithTimeout(ca.Namespace, ca.CsvWaitTime) | ||
var err error | ||
ca.csv, err = ca.client.GetCompletedCsvWithTimeout(ca.namespace, ca.csvWaitTime) |
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.
These two lines can be collaped, and just have 'ca.csv, err := ...'
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.
Hi @bcrochet apparently VSCode doesn't like that way. That's what happens when we remove and try to collapse the lines. **
**
Didn't have time to troubleshoot this. Do you have any suggestions?
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.
Leave it for now. Not a blocker.
…ntation Signed-off-by: acmenezes <[email protected]>
Signed-off-by: acmenezes <[email protected]>
Signed-off-by: acmenezes <[email protected]>
Signed-off-by: acmenezes <[email protected]>
Signed-off-by: acmenezes <[email protected]>
Signed-off-by: acmenezes <[email protected]>
9218f0b
to
8d227c2
Compare
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
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: acmenezes, bcrochet, skattoju, yashoza19 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
1 similar comment
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: acmenezes, bcrochet, skattoju, yashoza19 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
This refactor is supposed to revert the potential risk for redundant circular reference caused by importing from operator package options or flags that belong to the command level. At the same time avoid the risk of having a tight coupling trying to pass all options to the operator package that doesn't care about most of them.
Now new functionality like adding CRs from the command line are very hard to implement. It's definitely a no go having to change the package on the bottom of the stack to implement a new flag that will be used on middle of the stack.
The flow of opcap packages is designed to be
check
--> consumes -->capability
--> that consumes -->operator
. It is still not perfect. But we should avoid as much as possible trying to pass parameters across the packages to the bottom of the stack or importing in reverse order which may lead to circular reference when we need to add new functionality in the future.I've also took the opportunity to eliminate some unnecessary code a make the interfaces mode clear by not exporting a bunch of things that were unnecessarily exported on the capability package.
Here is what's being removed from the operator package:
The flags should be processed on the top of the stack and not on the bottom.
We still need to redo the all install mode strategy though.