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 -2
View File
@@ -59,7 +59,7 @@ func (opts *LogSubCommand) do(input cli.Input) error {
return errors.Wrap(err, "error getting function")
}
server, err := util.GetApplicationUrl("application=fission-api", kubeContext)
server, err := util.GetApplicationUrl(input.Context(), "application=fission-api", kubeContext)
if err != nil {
return err
}
@@ -72,7 +72,7 @@ func (opts *LogSubCommand) do(input cli.Input) error {
requestChan := make(chan struct{})
responseChan := make(chan struct{})
ctx := context.Background()
ctx := input.Context()
go func(ctx context.Context, requestChan, responseChan chan struct{}) {
t := time.Unix(0, 0*int64(time.Millisecond))
+3 -3
View File
@@ -62,7 +62,7 @@ func (opts *TestSubCommand) do(input cli.Input) error {
}
// Portforward to the fission router
localRouterPort, err := util.SetupPortForward(util.GetFissionNamespace(), "application=fission-router", kubeContext)
localRouterPort, err := util.SetupPortForward(input.Context(), util.GetFissionNamespace(), "application=fission-router", kubeContext)
if err != nil {
return err
}
@@ -107,10 +107,10 @@ func (opts *TestSubCommand) do(input cli.Input) error {
testTimeout := input.Duration(flagkey.FnTestTimeout)
if testTimeout <= 0*time.Second {
ctx = context.Background()
ctx = input.Context()
} else {
var closeCtx context.CancelFunc
ctx, closeCtx = context.WithTimeout(context.Background(), input.Duration(flagkey.FnTestTimeout))
ctx, closeCtx = context.WithTimeout(input.Context(), input.Duration(flagkey.FnTestTimeout))
defer closeCtx()
}