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

Move files from src/cmd/tools and src/cmd/common to src/cmd #3254

Open
AustinAbro321 opened this issue Nov 20, 2024 · 0 comments
Open

Move files from src/cmd/tools and src/cmd/common to src/cmd #3254

AustinAbro321 opened this issue Nov 20, 2024 · 0 comments

Comments

@AustinAbro321
Copy link
Contributor

Describe what should be investigated or refactored

We should delete the packages src/cmd/tools and src/cmd/common and move the code into src/cmd. Having src/cmd/tools separate from from the rest of src/cmd forces us to maintain src/cmd/common to share functions used by both packages. I do not think the benefit of having separate packages warrant the extra complexity in this case.

The current setup makes sharing code between packages harder. For example, zarf tools crane is the only command with a PersistentPreRunE function, other than root. PersistentPreRunE is always called for child commands, unless it's overwritten. This means zarf tools crane and it's children are the only commands that don't run the root pre-run. This makes it harder to setup a logger. This is problematic because we wrap crane commands with additional logic, and add Zarf specific commands to crane.

Ideally, we could call the root pre-run function at the start of the crane pre-run, however it would cause an import cycle if we did that since src/cmd/tools is currently already imported by src/cmd. We could instead add the root pre-run function to common, but it would be simpler to move the code together

Links to any relevant code

PersistentPreRunE: func(cmd *cobra.Command, _ []string) error {

Additional context

We have a helm package under src/tools. IMO this can stay separate as it's mostly a means of implementing the helm commands we can not import as a library.

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

No branches or pull requests

1 participant