Skip to content

refactor(helm): Make all functions returning cobra.Command public - #5353

Closed
melan wants to merge 1 commit into
helm:masterfrom
melan:refactor/public-cobra-commands
Closed

melan wants to merge 1 commit into
helm:masterfrom
melan:refactor/public-cobra-commands

Conversation

@melan

@melan melan commented Feb 25, 2019

Copy link
Copy Markdown

What this PR does / why we need it:
This change enables developers to compose commands from helm, from kubectl and other tools into custom CLI for their projects running on kubernetes.

Closes #5311

Special notes for your reviewer:
None. It's a trivial change

If applicable:

  • [-] this PR contains documentation
  • [-] this PR contains unit tests
  • [+] this PR has been tested for backwards compatibility

This change enables developers to compose commands from helm, from kubectl and other tools into custom CLI for
their projects running on kubernetes.

Closes helm#5311

Signed-off-by: Dmitry Melanchenko <[email protected]>
@bacongobbler

Copy link
Copy Markdown
Member

IIRC Go considers the cmd package as an "internal" package, so even with this change, third-parties won't be able to take advantage of these commands. The internals of cmd changes often as well, which is why we have avoided exposing these commands in the past. I'm not sure if we're still comfortable with the idea of exposing these endpoints.

That being said, @adamreese and I are refactoring these packages for Helm 3 so that they can be consumed by other third parties in a more meaningful way. We should have more to report in a few weeks. Will that help?

@melan

melan commented Feb 26, 2019

Copy link
Copy Markdown
Author

@bacongobbler it's fine if content of the cmd package changes a frequently. CLI composition using cobra.Command allows to hide and ignore the most of the implementation details. That's why I made the New...Cmd functions public but not the run... ones.

If you think the functions should be moved to somewhere at pkg/ - it's a much bigger change and it requires more coordination but I can help with this too.

@bacongobbler

Copy link
Copy Markdown
Member

it's fine if content of the cmd package changes a frequently.

We made commitments to ensure pkg remains backwards compatible from 2.0 onwards, so it's not okay if we make frequent changes. "SHOULD remain backward compatible" in that doc really means "SHOULD nearly always remain backwards compatible"; we only break function signatures in pkg when we have no other option.

In other words, we treat anything in pkg as stable, production-ready software that others can use to rely on for their projects, and the new*Cmd functions change in backwards-incompatible ways frequently enough to make it unfit as part of k8s.io/helm/pkg.

For a recent example, when we upgraded to Kubernetes 1.12 in #4734, Kubernetes introduced several significant backwards-incompatible changes to all of cmd. This has happened in the past several times, which is why we decided to keep these things in cmd so others won't take a dependency on functions in cmd that break every minor Helm release.

With #5365, the concerns raised above about backwards compatibility should be addressed. The internals of cmd has been refactored cleanly into pkg/action, and we should be able to address further backwards-compatibility issues addressed by upgrading to a newer version of Kubernetes without affecting the commands themselves. That paves the way for making the cobra commands available for public consumption in the form of k8s.io/pkg/cli.

TL;DR: We take backwards compatibility very seriously. We definitely want to do this, but there are too many breaking changes with the way the commands are architected today, so we're not planning on supporting the changes required to make that happen for Helm 2. Helm 3 addresses these issues (see #5365) and we'll be able to accommodate this use case better in Helm 3.

Let me know if you have further questions/comments. Thanks!

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.

2 participants