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
@@ -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.