Capture context from cobra CLI and pass forward (#2551)
Signed-off-by: Sanket Sudake <sanketsudake@gmail.com>
This commit is contained in:
@@ -17,6 +17,7 @@ limitations under the License.
|
||||
package cobra
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
@@ -217,6 +218,10 @@ func WrapperChain(actions ...cmd.CommandAction) func(*cobra.Command, []string) e
|
||||
}
|
||||
}
|
||||
|
||||
func (u Cli) Context() context.Context {
|
||||
return u.c.Context()
|
||||
}
|
||||
|
||||
func (u Cli) IsSet(key string) bool {
|
||||
return u.c.Flags().Changed(key)
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ limitations under the License.
|
||||
package dummy
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
fCli "github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
|
||||
@@ -33,6 +34,10 @@ func TestFlagSet() Cli {
|
||||
return Cli{c: make(map[string]interface{})}
|
||||
}
|
||||
|
||||
func (u Cli) Context() context.Context {
|
||||
return context.TODO()
|
||||
}
|
||||
|
||||
// Set allows to set any kinds of value with given key.
|
||||
// The type of set value should be matched with the returned
|
||||
// type of GetXXX function.
|
||||
|
||||
Reference in New Issue
Block a user