-
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.
Merge pull request #73 from Azure/mchinta/nodepoolList
Adding vc nodepool list command
- Loading branch information
Showing
3 changed files
with
82 additions
and
1 deletion.
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
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,40 @@ | ||
package helmcli | ||
|
||
import ( | ||
"fmt" | ||
|
||
"helm.sh/helm/v3/pkg/action" | ||
"helm.sh/helm/v3/pkg/release" | ||
"k8s.io/cli-runtime/pkg/genericclioptions" | ||
) | ||
|
||
// ListCli is a client to get helm charts from secret storage. | ||
type ListCli struct { | ||
namespace string | ||
|
||
cfg *action.Configuration | ||
} | ||
|
||
// NewGetCli returns new GetCli instance. | ||
func NewListCli(kubeconfigPath string, namespace string) (*ListCli, 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 &ListCli{ | ||
namespace: namespace, | ||
cfg: actionCfg, | ||
}, nil | ||
} | ||
|
||
func (cli *ListCli) List() ([]*release.Release, error) { | ||
listCli := action.NewList(cli.cfg) | ||
return listCli.Run() | ||
} |
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,21 @@ | ||
package virtualcluster | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
|
||
"helm.sh/helm/v3/pkg/release" | ||
|
||
"github.com/Azure/kperf/helmcli" | ||
) | ||
|
||
// ListNodeppol lists nodepools added by the vc nodeppool add command. | ||
func ListNodepools(_ context.Context, kubeconfigPath string) ([]*release.Release, error) { | ||
listCli, err := helmcli.NewListCli(kubeconfigPath, virtualnodeReleaseNamespace) | ||
if err != nil { | ||
return nil, fmt.Errorf("failed to create helm list client: %w", err) | ||
} | ||
|
||
return listCli.List() | ||
|
||
} |