You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Proposal: make cobra.Command functions public #5311
Currently all functions generating cobra.Command for CLI are private and I want to make them public. Motivation for such change is simple: this will allow to reuse pieces of helm functionality in other tools.
Story: I'm building a CLI for a project that mostly runs on Kubernetes. The CLI is composed from 2 pieces: commands unique for the project and commands imported from from kubectl. I would like to add there few commands from helm also - first of all helm template. Such aggregated CLI allows to use one command to interact with the project instead of several different tools each with own configuration.
IIRC Go considers the cmd package as an "internal" package, so even if we made them public, third parties won't be able to take advantage of these commands. In the past, the internals of cmd changed often due to breaking changes in k8s.io/kubernetes, 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?
So, #5365 is a major internal refactoring of most of the Helm codebase in preparation for Helm 3. Large parts of the functionality in cmd has been moved into the action package (new for Helm 3), but the commands themselves are still in cmd... For now.
After we suss out the details on that PR, my line of thinking to address this ask is to move all the new*Cmd functions over to pkg/cli. That should address this proposal for Helm 3. I don't want to do that in that PR though as we're already approaching 13k lines of code changed, and we can address this further refactoring in another PR.
Given the amount of code that would need to move over or make public from cmd/helm, I'm concerned about the amount of refactoring (and the potential for compatibility issues involved) to support this for Helm 2. Some of those thoughts can be found in #5353. Let me know if you have any comments/concerns with that approach.
Yes, actually if you'd like to take this work on that'd be great. I started going down the path in #5448 but got sidetracked with higher priority work so I was unable to finish it.
If you'd like to work on this, we'd need:
the actual work of exposing the cobra commands in a consumable package (like pkg/cli)
adding unit tests around how a user would consume this package, as well as cases around how the internal state logic is handled (i.e. the settings object)
docstrings for the new functions so they show up with go doc.
Activity
melan commentedon Feb 14, 2019
This change seems minor and unless there are reasons why not to implement it - I'd like to contribute the changes.
refactor(helm): Make all functions returning cobra.Command public
bacongobbler commentedon Feb 25, 2019
re-posting my comment in #5353 for posterity:
IIRC Go considers the
cmdpackage as an "internal" package, so even if we made them public, third parties won't be able to take advantage of these commands. In the past, the internals ofcmdchanged often due to breaking changes ink8s.io/kubernetes, 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?
bacongobbler commentedon Feb 26, 2019
So, #5365 is a major internal refactoring of most of the Helm codebase in preparation for Helm 3. Large parts of the functionality in
cmdhas been moved into theactionpackage (new for Helm 3), but the commands themselves are still incmd... For now.After we suss out the details on that PR, my line of thinking to address this ask is to move all the
new*Cmdfunctions over topkg/cli. That should address this proposal for Helm 3. I don't want to do that in that PR though as we're already approaching 13k lines of code changed, and we can address this further refactoring in another PR.Given the amount of code that would need to move over or make public from
cmd/helm, I'm concerned about the amount of refactoring (and the potential for compatibility issues involved) to support this for Helm 2. Some of those thoughts can be found in #5353. Let me know if you have any comments/concerns with that approach.melan commentedon May 29, 2019
@bacongobbler do you need help to move this proposal forward?
bacongobbler commentedon Jul 3, 2019
Yes, actually if you'd like to take this work on that'd be great. I started going down the path in #5448 but got sidetracked with higher priority work so I was unable to finish it.
If you'd like to work on this, we'd need:
pkg/cli)settingsobject)go doc.Let me know if you have any questions.
bacongobbler commentedon May 14, 2020
closing as inactive.