Use Kubernetes Client instead of Controller APIs from CLI (#2605)

Use the Kubernetes and Fission Client from CLI instead of Controller API.
This removes port-forwarding for the controller across Fission CLI mostly.

* Use configurable client in CLI
* Move resource namespace under cmd client
* use server to get fission version
* get archive with URL

Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>
Co-authored-by: Sanket Sudake <sanketsudake@gmail.com>
This commit is contained in:
neha_gupta
2022-11-07 21:42:39 +05:30
committed by GitHub
co-authored by Sanket Sudake
parent 261bf24974
commit b71a36dc1c
86 changed files with 1115 additions and 978 deletions
+4 -4
View File
@@ -32,7 +32,7 @@ func Commands() *cobra.Command {
}
wrapper.SetFlags(uploadCmd, flag.FlagSet{
Required: []flag.Flag{flag.ArchiveName},
Optional: []flag.Flag{flag.KubeContext},
Optional: []flag.Flag{},
})
listCmd := &cobra.Command{
@@ -41,7 +41,7 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(List),
}
wrapper.SetFlags(listCmd, flag.FlagSet{
Optional: []flag.Flag{flag.KubeContext},
Optional: []flag.Flag{},
})
deleteCmd := &cobra.Command{
@@ -61,7 +61,7 @@ func Commands() *cobra.Command {
}
wrapper.SetFlags(geturlCmd, flag.FlagSet{
Required: []flag.Flag{flag.ArchiveID},
Optional: []flag.Flag{flag.KubeContext},
Optional: []flag.Flag{},
})
downloadCmd := &cobra.Command{
@@ -71,7 +71,7 @@ func Commands() *cobra.Command {
}
wrapper.SetFlags(downloadCmd, flag.FlagSet{
Required: []flag.Flag{flag.ArchiveID},
Optional: []flag.Flag{flag.KubeContext, flag.ArchiveOutput},
Optional: []flag.Flag{flag.ArchiveOutput},
})
command := &cobra.Command{
+1 -2
View File
@@ -36,10 +36,9 @@ func Delete(input cli.Input) error {
func (opts *DeleteSubCommand) do(input cli.Input) error {
kubeContext := input.String(flagkey.KubeContext)
archiveID := input.String(flagkey.ArchiveID)
storagesvcURL, err := util.GetStorageURL(input.Context(), kubeContext)
storagesvcURL, err := util.GetStorageURL(input.Context(), opts.Client())
if err != nil {
return err
}
+1 -2
View File
@@ -37,7 +37,6 @@ func Download(input cli.Input) error {
func (opts *DownloadSubCommand) do(input cli.Input) error {
kubeContext := input.String(flagkey.KubeContext)
archiveID := input.String(flagkey.ArchiveID)
archiveOutput := input.String(flagkey.ArchiveOutput)
@@ -45,7 +44,7 @@ func (opts *DownloadSubCommand) do(input cli.Input) error {
archiveOutput = strings.TrimPrefix(archiveID, "/fission/fission-functions/")
}
storageAccessURL, err := util.GetStorageURL(input.Context(), kubeContext)
storageAccessURL, err := util.GetStorageURL(input.Context(), opts.Client())
if err != nil {
return err
}
+2 -3
View File
@@ -38,10 +38,9 @@ func GetURL(input cli.Input) error {
func (opts *GetURLSubCommand) do(input cli.Input) error {
kubeContext := input.String(flagkey.KubeContext)
archiveID := input.String(flagkey.ArchiveID)
serverURL, err := util.GetStorageURL(input.Context(), kubeContext)
serverURL, err := util.GetStorageURL(input.Context(), opts.Client())
if err != nil {
return err
}
@@ -67,7 +66,7 @@ func (opts *GetURLSubCommand) do(input cli.Input) error {
storageType := resp.Header.Get("X-FISSION-STORAGETYPE")
if storageType == "local" {
storageSvc, err := opts.Client().V1().Misc().GetSvcURL("application=fission-storage")
storageSvc, err := util.GetSvcName(input.Context(), opts.Client().KubernetesClient, "fission-storage")
if err != nil {
return err
}
+1 -4
View File
@@ -21,7 +21,6 @@ import (
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
"github.com/fission/fission/pkg/fission-cli/cmd"
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
"github.com/fission/fission/pkg/fission-cli/util"
storagesvcClient "github.com/fission/fission/pkg/storagesvc/client"
)
@@ -36,9 +35,7 @@ func List(input cli.Input) error {
func (opts *ListSubCommand) do(input cli.Input) error {
kubeContext := input.String(flagkey.KubeContext)
storageAccessURL, err := util.GetStorageURL(input.Context(), kubeContext)
storageAccessURL, err := util.GetStorageURL(input.Context(), opts.Client())
if err != nil {
return err
}
+1 -2
View File
@@ -36,10 +36,9 @@ func Upload(input cli.Input) error {
func (opts *UploadSubCommand) do(input cli.Input) error {
kubeContext := input.String(flagkey.KubeContext)
archiveName := input.String(flagkey.ArchiveName)
storagesvcURL, err := util.GetStorageURL(input.Context(), kubeContext)
storagesvcURL, err := util.GetStorageURL(input.Context(), opts.Client())
if err != nil {
return err
}