Skip to content

Commit

Permalink
helmcli: add GetCli client
Browse files Browse the repository at this point in the history
Signed-off-by: Wei Fu <weifu@microsoft.com>
  • Loading branch information
fuweid committed Jan 3, 2024
1 parent 3e22d94 commit 3fa3436
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions helmcli/get.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package helmcli

import (
"fmt"

"helm.sh/helm/v3/pkg/action"
"helm.sh/helm/v3/pkg/release"
"k8s.io/cli-runtime/pkg/genericclioptions"
)

// GetCli is a client to get helm chart from secret storage.
type GetCli struct {
namespace string

cfg *action.Configuration
}

// NewGetCli returns new GetCli instance.
func NewGetCli(kubeconfigPath string, namespace string) (*GetCli, error) {
actionCfg := new(action.Configuration)
if err := actionCfg.Init(
&genericclioptions.ConfigFlags{
KubeConfig: &kubeconfigPath,
},
namespace,
"secret",
noopLog,
); err != nil {
return nil, fmt.Errorf("failed to init action config: %w", err)
}
return &GetCli{
namespace: namespace,
cfg: actionCfg,
}, nil
}

// Get returns all the information about that given release.
func (cli *GetCli) Get(releaseName string) (*release.Release, error) {
getCli := action.NewGet(cli.cfg)
return getCli.Run(releaseName)
}

0 comments on commit 3fa3436

Please sign in to comment.