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

🌱 Logic extraction refactor #414

Merged
merged 6 commits into from
Feb 4, 2025

Conversation

abrugaro
Copy link
Contributor

@abrugaro abrugaro commented Jan 7, 2025

This PR is an initial refactor and a continuation of the discussion in PR #372 and Issue #249 .

In this PR, I separate the properties of the analyzeCommand that are not arguments of the command itself and move them to another struct called CommandContext, also extracting the functions that do not use properties from analyzeCommand but do rely on CommandContext.

Additionally, I moved some functions that are not specific to analyzeCommand or CommandContext to the "utils" module.

For the next PR, the plan is to extract the logging functionality into a separate struct within its own package. This will allow it to be instantiated as a singleton, enabling decoupling of the logging logic from the rest of the code. Alongside this, I will also separate the constants currently defined at the beginning of analyze so that later, the providers can be moved to their own package.

Signed-off-by: Alejandro Brugarolas <[email protected]>
Signed-off-by: Alejandro Brugarolas <[email protected]>
Signed-off-by: Alejandro Brugarolas <[email protected]>
@jmle jmle requested review from jmle and eemcmullan January 14, 2025 11:53
Copy link
Contributor

@jmle jmle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. I think patterns are starting to emerge from the "god object" file that is analyze.go, and we are on the right direction.

Copy link
Collaborator

@eemcmullan eemcmullan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall, looks really good! My one ask is possibly renaming the CommandContext struct to something more analyzer-specific, e.g. AnalyzeCommandContext. That way, we can use the same logic across other subcommands if necessary. As of now, the only other subcmd is transform, but we are planning to add additional subcommand(s) for the asset generation work. I think this will help keep it more flexible.

Signed-off-by: Alejandro Brugarolas <[email protected]>
Signed-off-by: Alejandro Brugarolas <[email protected]>
Signed-off-by: Alejandro Brugarolas <[email protected]>
Copy link
Collaborator

@eemcmullan eemcmullan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - thank you!

@abrugaro abrugaro changed the title Logic extraction refactor 🌱 Logic extraction refactor Feb 4, 2025
@eemcmullan eemcmullan merged commit 23bce00 into konveyor:main Feb 4, 2025
3 checks passed
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.

3 participants