Capture context from cobra CLI and pass forward (#2551)

Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>
This commit is contained in:
Sanket Sudake
2022-09-22 13:54:05 +05:30
committed by GitHub
parent d03395949b
commit e87c84ee2c
33 changed files with 93 additions and 83 deletions
+2 -3
View File
@@ -17,7 +17,6 @@ limitations under the License.
package archive
import (
"context"
"fmt"
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
@@ -40,14 +39,14 @@ func (opts *DeleteSubCommand) do(input cli.Input) error {
kubeContext := input.String(flagkey.KubeContext)
archiveID := input.String(flagkey.ArchiveID)
storagesvcURL, err := util.GetStorageURL(kubeContext)
storagesvcURL, err := util.GetStorageURL(input.Context(), kubeContext)
if err != nil {
return err
}
client := storagesvcClient.MakeClient(storagesvcURL.String())
err = client.Delete(context.Background(), archiveID)
err = client.Delete(input.Context(), archiveID)
if err != nil {
return err
}
+2 -3
View File
@@ -17,7 +17,6 @@ limitations under the License.
package archive
import (
"context"
"fmt"
"strings"
@@ -46,13 +45,13 @@ func (opts *DownloadSubCommand) do(input cli.Input) error {
archiveOutput = strings.TrimPrefix(archiveID, "/fission/fission-functions/")
}
storageAccessURL, err := util.GetStorageURL(kubeContext)
storageAccessURL, err := util.GetStorageURL(input.Context(), kubeContext)
if err != nil {
return err
}
client := storagesvcClient.MakeClient(storageAccessURL.String())
err = client.Download(context.Background(), archiveID, archiveOutput)
err = client.Download(input.Context(), archiveID, archiveOutput)
if err != nil {
return err
}
+2 -2
View File
@@ -41,7 +41,7 @@ func (opts *GetURLSubCommand) do(input cli.Input) error {
kubeContext := input.String(flagkey.KubeContext)
archiveID := input.String(flagkey.ArchiveID)
serverURL, err := util.GetStorageURL(kubeContext)
serverURL, err := util.GetStorageURL(input.Context(), kubeContext)
if err != nil {
return err
}
@@ -61,7 +61,7 @@ func (opts *GetURLSubCommand) do(input cli.Input) error {
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
return fmt.Errorf("Error getting URL. Exited with Status: %s", resp.Status)
return fmt.Errorf("error getting URL. Exited with Status: %s", resp.Status)
}
storageType := resp.Header.Get("X-FISSION-STORAGETYPE")
+2 -3
View File
@@ -17,7 +17,6 @@ limitations under the License.
package archive
import (
"context"
"fmt"
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
@@ -39,13 +38,13 @@ func (opts *ListSubCommand) do(input cli.Input) error {
kubeContext := input.String(flagkey.KubeContext)
storageAccessURL, err := util.GetStorageURL(kubeContext)
storageAccessURL, err := util.GetStorageURL(input.Context(), kubeContext)
if err != nil {
return err
}
client := storagesvcClient.MakeClient(storageAccessURL.String())
files, err := client.List(context.Background())
files, err := client.List(input.Context())
if err != nil {
return err
}
+2 -3
View File
@@ -17,7 +17,6 @@ limitations under the License.
package archive
import (
"context"
"fmt"
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
@@ -40,13 +39,13 @@ func (opts *UploadSubCommand) do(input cli.Input) error {
kubeContext := input.String(flagkey.KubeContext)
archiveName := input.String(flagkey.ArchiveName)
storagesvcURL, err := util.GetStorageURL(kubeContext)
storagesvcURL, err := util.GetStorageURL(input.Context(), kubeContext)
if err != nil {
return err
}
client := storagesvcClient.MakeClient(storagesvcURL.String())
archiveID, err := client.Upload(context.Background(), archiveName, nil)
archiveID, err := client.Upload(input.Context(), archiveName, nil)
if err != nil {
return err
}