Capture context from cobra CLI and pass forward (#2551)
Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>
This commit is contained in:
@@ -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))
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user