-
Notifications
You must be signed in to change notification settings - Fork 37
Restructure qmctl #839
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
Restructure qmctl #839
Conversation
Reviewer's GuideThis MR refactors the monolithic qmctl tool into a clean, command-based architecture inspired by the ramalama project, modularizing command handlers and streamlining the main dispatch logic for easier extension and debugging. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Hey @ArtiomDivak - I've reviewed your changes - here's some feedback:
Blocking issues:
- Detected subprocess function 'run' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'. (link)
- Detected subprocess function 'run' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'. (link)
- Detected subprocess function 'run' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'. (link)
General comments:
- Factor out the repeated container-exists and argument-validation logic into a decorator or helper to DRY up the multiple
exec_*andshow_*methods. - Replace the scattered
sys.exit(1)calls by raising custom exceptions in command handlers and handling them centrally in the CLI entrypoint to simplify control flow. - Consider breaking each command into its own module or class rather than growing a single monolithic QMCTL class to better align with the intended clean, command-based architecture.
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🔴 Security: 3 blocking issues
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
d60705a to
355789e
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.
Hey @ArtiomDivak - I've reviewed your changes and they look great!
Blocking issues:
- Detected subprocess function 'run' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'. (link)
- Detected subprocess function 'run' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'. (link)
- Detected subprocess function 'run' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'. (link)
- Detected subprocess function 'run' without a static string. If this data can be controlled by a malicious actor, it may be an instance of command injection. Audit the use of this call to ensure it is not controllable by an external resource. You may consider using 'shlex.escape()'. (link)
Here's what I looked at during the review
- 🟢 General issues: all looks good
- 🔴 Security: 4 blocking issues
- 🟢 Testing: all looks good
- 🟢 Complexity: all looks good
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Yarboa
left a comment
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.
@ArtiomDivak Did you try to run the tests through tmt locally?
Please refer that one all tier-0 testing are failing due to the changes
Line 139 in daec692
| Refer [FMF](https://fmf.readthedocs.io/en/stable) for tmt test metadata specification |
9d4c8c3 to
11e2cf0
Compare
8f0b6ba to
654f8c2
Compare
engelmi
left a comment
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.
Added a few comments.
This PR is quite big, so I am not sure if it would be better to split it.
6976bb6 to
86fe6e3
Compare
| @@ -1,256 +1,448 @@ | |||
| #!/usr/bin/env python | |||
| # Licensed under the Apache License, Version 2.0 | |||
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.
please keep the license
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.
Added the licence Thank you
engelmi
left a comment
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.
Please remove the __pycache__ (and maybe add it to .gitignore)
d7c14b2 to
6e2ac8a
Compare
This MR I added QMCTL class wich will be responsiable to run all the command function and return the result. Also added all the imports needed to all the file Signed-off-by: Artiom Divak <[email protected]>
ArgumentParserWithDefaults class automatically adds default values to the help text of arguments SubcommandInitializer is a generic class to initialize subparsers for command-line applications Signed-off-by: Artiom Divak <[email protected]>
|
@ArtiomDivak ready for review? |
|
Yes its ready for review |
engelmi
left a comment
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, great work!
|
@sourcery-ai review |
|
@dougsland PR lgtm, PTAL as well |
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.
Hey @ArtiomDivak - I've reviewed your changes and they look great!
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
This commits adds the main function the init of the subcommand and the handle function for the subcommand with other vital function. Signed-off-by: Artiom Divak <[email protected]>
|
@ArtiomDivak @engelmi I have few comments that can be addressed later, for example.
|
|
@ArtiomDivak great stuff, I have created: |
This MR refactors the qmctl file to improve its structure, making it easier to add new commands and debug in the future. The new design is heavily inspired by the clean, command-based architecture of the "ramalama" project, aiming for a more organized and maintainable codebase.
closes #838
Summary by Sourcery
Restructure qmctl into a modular command-based architecture inspired by ramalama to improve maintainability and facilitate adding new commands and debugging
Enhancements:
Chores: