Skip to content
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

✨ Migrate Command Handling to Cobra for Simplified Flag Management #1598

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Horiodino
Copy link

This PR fixes the issue described in #1567.


Description:

This PR migrates the command-line handling logic in the cmd/manager/main.go file to utilize the [Cobra CLI framework]. The migration simplifies flag handling, improves readability, and enhances the extensibility of the CLI for future development.


Key Changes:

  1. Cobra Root Command:

    • Introduced the rootCmd for top-level command handling, providing a clean and standardized entry point for the CLI.
  2. Flag Migration:

    • Migrated all existing flags from the standard flag package to Cobra’s cmd.Flags() and cmd.PersistentFlags().
  3. Subcommand Restructuring:

    • Refactored and restructured any existing subcommands under Cobra’s subcommand system.
  4. Helper Functions:

    • Refined the main function by extracting logic into dedicated helper functions.

@Horiodino Horiodino requested a review from a team as a code owner January 10, 2025 16:28
Copy link

netlify bot commented Jan 10, 2025

Deploy Preview for olmv1 ready!

Name Link
🔨 Latest commit fc636ce
🔍 Latest deploy log https://app.netlify.com/sites/olmv1/deploys/6782147ff374570008a55cd9
😎 Deploy Preview https://deploy-preview-1598--olmv1.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@kevinrizza
Copy link
Member

👋 Thanks for the contribution! Quick question, if we're going to do this for the catalogd binary, should we do the same for the operator-controller binary? I.e. https://github.com/operator-framework/operator-controller/blob/main/cmd/operator-controller/main.go

I suspect there will be some opinions on the functional refactoring as the controllers are set up (isn't some of that handled by controller runtime and kubebuilder?) and it would probably be good for us to match in those places. I know that's outside the scope of that github issue, but I think that's an artifact of these two binaries being part of separate repositories until very recently.

@LalatenduMohanty
Copy link
Member

/assign @LalatenduMohanty

Copy link

codecov bot commented Jan 10, 2025

Codecov Report

Attention: Patch coverage is 0% with 185 lines in your changes missing coverage. Please review.

Project coverage is 66.48%. Comparing base (fff1896) to head (6c4c4ab).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
catalogd/cmd/catalogd/main.go 0.00% 185 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1598      +/-   ##
==========================================
- Coverage   66.68%   66.48%   -0.21%     
==========================================
  Files          57       57              
  Lines        4584     4598      +14     
==========================================
  Hits         3057     3057              
- Misses       1302     1316      +14     
  Partials      225      225              
Flag Coverage Δ
e2e 52.72% <ø> (ø)
unit 53.45% <0.00%> (-0.17%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@grokspawn
Copy link
Contributor

Hey @Horiodino! Thanks for your PR (especially since you noticed catalogd's new home and reproduced it here).
Could you do a make verify in your local and commit the dependency updates please?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants