Skip to content

Proposal: make cobra.Command functions public #5311

Closed

Description

@melan

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.

Activity

  1. melan commented on Feb 14, 2019

    @melan
    Author

    This change seems minor and unless there are reasons why not to implement it - I'd like to contribute the changes.

  2. added a commit that references this issue on Feb 25, 2019
    8068a34
  3. bacongobbler commented on Feb 25, 2019

    @bacongobbler
    Member

    re-posting my comment in #5353 for posterity:

    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?

  4. bacongobbler commented on Feb 26, 2019

    @bacongobbler
    Member

    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.

  5. added
    v3.x
    on Mar 5, 2019
  6. self-assigned this
    on Mar 5, 2019
  7. melan commented on May 29, 2019

    @melan
    Author

    @bacongobbler do you need help to move this proposal forward?

  8. bacongobbler commented on Jul 3, 2019

    @bacongobbler
    Member

    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.

    Let me know if you have any questions.

  9. bacongobbler commented on May 14, 2020

    @bacongobbler
    Member

    closing as inactive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

proposalv3.x

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions