Skip to content

Allow calling helm from go #12122

@arikmaor

Description

@arikmaor

I would like to embed helm inside a cli program that I'm writing
many cli programs, specially ones written using cobra, allow me to do that like this:

package tools

import (
	k3d "github.com/k3d-io/k3d/v5/cmd"
	"github.com/spf13/cobra"
	kubectl "k8s.io/kubectl/pkg/cmd"
)

var ToolsCmd = &cobra.Command{
	Use:   "tools",
}

func init() {
	ToolsCmd.AddCommand(k3d.NewCmdK3d())
	ToolsCmd.AddCommand(kubectl.NewDefaultKubectlCommand())
	RootCommand.AddCommand(ToolsCmd)
}

When I try to do the same for helm I get the flowing error:

import "helm.sh/helm/v3/cmd/helm" is a program, not an importable package

In order to support this for helm, the main file (named helm.go in this case) needs to be separated from the rest of the code.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions