-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Wei Fu <weifu@microsoft.com>
- Loading branch information
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |