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

pkg: commands: refactor commands to make them reusable #103

Merged
merged 3 commits into from
Jul 4, 2022

Conversation

ffromani
Copy link
Collaborator

@ffromani ffromani commented Jul 1, 2022

The original intent of the commands pkg was to be reusable, to enable clients to inject deployer commands in their own programs. This turns out harder than expected in practice, because of somehow excessive coupling in the commands pkg.
This PR relaxes these contraints and make sure that these commands, at least the render subtree, is actually reusable in external projects.

@ffromani ffromani requested review from Tal-or and swatisehgal July 4, 2022 08:02
@ffromani ffromani force-pushed the reusable-commands branch from 6d8c76c to 71a084a Compare July 4, 2022 11:38
ffromani added 3 commits July 4, 2022 13:41
In order to facilitate integration of the `commands` package - which
was an original goal, extract helpers to register flags and parse
options. This is useful because subcommands all require the
CommonOptions, which are handled by the `root` command using
the code being factored out.

This change makes it easier to integrate the subcommands without
requiring anymore the root command.

Signed-off-by: Francesco Romani <[email protected]>
Subcommand require sub-options structs, which were not
exported previously, forcing client code to pass `nil`,
which is fragile and works on a very narrow subset of cases.

Exporting the sub-options enables clients to register
subcommands safely.

Signed-off-by: Francesco Romani <[email protected]>
expose and simplify RenderManifests, to enable client of
the `commands` package to register sub-commands without
requiring to (possibly akwardly) register the full render
subcommand.

This allow to unnest the command tree.

Signed-off-by: Francesco Romani <[email protected]>
@ffromani ffromani force-pushed the reusable-commands branch from 71a084a to 9a7cf0a Compare July 4, 2022 11:42
@ffromani ffromani merged commit b6335be into k8stopologyawareschedwg:main Jul 4, 2022
@ffromani ffromani deleted the reusable-commands branch July 4, 2022 12:01
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.

1 participant