Replace flag text with const (#1391)

This commit is contained in:
Ta-Ching Chen
2019-11-09 22:13:35 +08:00
committed by GitHub
parent 6f5f6900b6
commit d3d8ff6c1b
73 changed files with 867 additions and 926 deletions
+3 -3
View File
@@ -36,8 +36,8 @@ func App() *cobra.Command {
Long: usage, Long: usage,
//SilenceUsage: true, //SilenceUsage: true,
PreRunE: wrapper.Wrapper( PreRunE: wrapper.Wrapper(
func(flags cli.Input) error { func(input cli.Input) error {
console.Verbosity = flags.Int(flagkey.Verbosity) console.Verbosity = input.Int(flagkey.Verbosity)
return nil return nil
}, },
), ),
@@ -51,7 +51,7 @@ func App() *cobra.Command {
}) })
wrapper.SetFlags(rootCmd, flag.FlagSet{ wrapper.SetFlags(rootCmd, flag.FlagSet{
Optional: []flag.Flag{flag.GlobalServerFlag, flag.GlobalVerbosityFlag}, Optional: []flag.Flag{flag.GlobalServer, flag.GlobalVerbosity},
}) })
groups := helptemplate.CommandGroups{} groups := helptemplate.CommandGroups{}
+4 -4
View File
@@ -339,7 +339,7 @@ func (es ExecutionStrategy) Validate() error {
if es.ExecutorType == ExecutorTypeNewdeploy { if es.ExecutorType == ExecutorTypeNewdeploy {
if es.MinScale < 0 { if es.MinScale < 0 {
result = multierror.Append(result, MakeValidationErr(ErrorInvalidValue, "ExecutionStrategy.MinScale", es.MinScale, "minimum scale must be greater or equal to 0")) result = multierror.Append(result, MakeValidationErr(ErrorInvalidValue, "ExecutionStrategy.MinScale", es.MinScale, "minimum scale must be greater than or equal to 0"))
} }
if es.MaxScale <= 0 { if es.MaxScale <= 0 {
@@ -347,7 +347,7 @@ func (es ExecutionStrategy) Validate() error {
} }
if es.MaxScale < es.MinScale { if es.MaxScale < es.MinScale {
result = multierror.Append(result, MakeValidationErr(ErrorInvalidValue, "ExecutionStrategy.MaxScale", es.MaxScale, "maximum scale must be greater or equal to minimum scale")) result = multierror.Append(result, MakeValidationErr(ErrorInvalidValue, "ExecutionStrategy.MaxScale", es.MaxScale, "maximum scale must be greater than or equal to minimum scale"))
} }
if es.TargetCPUPercent <= 0 || es.TargetCPUPercent > 100 { if es.TargetCPUPercent <= 0 || es.TargetCPUPercent > 100 {
@@ -421,11 +421,11 @@ func (spec EnvironmentSpec) Validate() error {
} }
if spec.Poolsize < 0 { if spec.Poolsize < 0 {
result = multierror.Append(result, MakeValidationErr(ErrorInvalidValue, "EnvironmentSpec.Poolsize", spec.Poolsize, "must be greater or equal to 0")) result = multierror.Append(result, MakeValidationErr(ErrorInvalidValue, "EnvironmentSpec.Poolsize", spec.Poolsize, "must be greater than or equal to 0"))
} }
if spec.TerminationGracePeriod < 0 { if spec.TerminationGracePeriod < 0 {
result = multierror.Append(result, MakeValidationErr(ErrorInvalidValue, "EnvironmentSpec.TerminationGracePeriod", spec.TerminationGracePeriod, "must be greater or equal to 0")) result = multierror.Append(result, MakeValidationErr(ErrorInvalidValue, "EnvironmentSpec.TerminationGracePeriod", spec.TerminationGracePeriod, "must be greater than or equal to 0"))
} }
return result.ErrorOrNil() return result.ErrorOrNil()
+9 -9
View File
@@ -30,8 +30,8 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(Create), RunE: wrapper.Wrapper(Create),
} }
wrapper.SetFlags(createCmd, flag.FlagSet{ wrapper.SetFlags(createCmd, flag.FlagSet{
Required: []flag.Flag{flag.CanaryNameFlag, flag.CanaryTriggerNameFlag, flag.CanaryNewFuncFlag, flag.CanaryOldFuncFlag}, Required: []flag.Flag{flag.CanaryName, flag.CanaryTriggerName, flag.CanaryNewFunc, flag.CanaryOldFunc},
Optional: []flag.Flag{flag.NamespaceFunctionFlag, flag.CanaryWeightIncrementFlag, flag.CanaryIncrementIntervalFlag, flag.CanaryFailureThresholdFlag}, Optional: []flag.Flag{flag.NamespaceFunction, flag.CanaryWeightIncrement, flag.CanaryIncrementInterval, flag.CanaryFailureThreshold},
}) })
getCmd := &cobra.Command{ getCmd := &cobra.Command{
@@ -41,8 +41,8 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(Get), RunE: wrapper.Wrapper(Get),
} }
wrapper.SetFlags(getCmd, flag.FlagSet{ wrapper.SetFlags(getCmd, flag.FlagSet{
Required: []flag.Flag{flag.CanaryNameFlag}, Required: []flag.Flag{flag.CanaryName},
Optional: []flag.Flag{flag.NamespaceCanaryFlag}, Optional: []flag.Flag{flag.NamespaceCanary},
}) })
updateCmd := &cobra.Command{ updateCmd := &cobra.Command{
@@ -52,8 +52,8 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(Update), RunE: wrapper.Wrapper(Update),
} }
wrapper.SetFlags(updateCmd, flag.FlagSet{ wrapper.SetFlags(updateCmd, flag.FlagSet{
Required: []flag.Flag{flag.CanaryNameFlag}, Required: []flag.Flag{flag.CanaryName},
Optional: []flag.Flag{flag.NamespaceCanaryFlag, flag.CanaryWeightIncrementFlag, flag.CanaryIncrementIntervalFlag, flag.CanaryFailureThresholdFlag}, Optional: []flag.Flag{flag.NamespaceCanary, flag.CanaryWeightIncrement, flag.CanaryIncrementInterval, flag.CanaryFailureThreshold},
}) })
deleteCmd := &cobra.Command{ deleteCmd := &cobra.Command{
@@ -63,8 +63,8 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(Delete), RunE: wrapper.Wrapper(Delete),
} }
wrapper.SetFlags(deleteCmd, flag.FlagSet{ wrapper.SetFlags(deleteCmd, flag.FlagSet{
Required: []flag.Flag{flag.CanaryNameFlag}, Required: []flag.Flag{flag.CanaryName},
Optional: []flag.Flag{flag.NamespaceCanaryFlag}, Optional: []flag.Flag{flag.NamespaceCanary},
}) })
listCmd := &cobra.Command{ listCmd := &cobra.Command{
@@ -75,7 +75,7 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(List), RunE: wrapper.Wrapper(List),
} }
wrapper.SetFlags(listCmd, flag.FlagSet{ wrapper.SetFlags(listCmd, flag.FlagSet{
Optional: []flag.Flag{flag.NamespaceCanaryFlag}, Optional: []flag.Flag{flag.NamespaceCanary},
}) })
command := &cobra.Command{ command := &cobra.Command{
+16 -16
View File
@@ -36,36 +36,36 @@ type CreateSubCommand struct {
canary *fv1.CanaryConfig canary *fv1.CanaryConfig
} }
func Create(flags cli.Input) error { func Create(input cli.Input) error {
c, err := util.GetServer(flags) c, err := util.GetServer(input)
if err != nil { if err != nil {
return err return err
} }
opts := CreateSubCommand{ opts := CreateSubCommand{
client: c, client: c,
} }
return opts.do(flags) return opts.do(input)
} }
func (opts *CreateSubCommand) do(flags cli.Input) error { func (opts *CreateSubCommand) do(input cli.Input) error {
err := opts.complete(flags) err := opts.complete(input)
if err != nil { if err != nil {
return err return err
} }
return opts.run(flags) return opts.run(input)
} }
func (opts *CreateSubCommand) complete(flags cli.Input) error { func (opts *CreateSubCommand) complete(input cli.Input) error {
// canary configs can be created for functions in the same namespace // canary configs can be created for functions in the same namespace
name := flags.String(flagkey.CanaryName) name := input.String(flagkey.CanaryName)
ht := flags.String(flagkey.CanaryHTTPTriggerName) ht := input.String(flagkey.CanaryHTTPTriggerName)
newFunc := flags.String(flagkey.CanaryNewFunc) newFunc := input.String(flagkey.CanaryNewFunc)
oldFunc := flags.String(flagkey.CanaryOldFunc) oldFunc := input.String(flagkey.CanaryOldFunc)
fnNs := flags.String(flagkey.NamespaceFunction) fnNs := input.String(flagkey.NamespaceFunction)
incrementStep := flags.Int(flagkey.CanaryWeightIncrement) incrementStep := input.Int(flagkey.CanaryWeightIncrement)
failureThreshold := flags.Int(flagkey.CanaryFailureThreshold) failureThreshold := input.Int(flagkey.CanaryFailureThreshold)
incrementInterval := flags.String(flagkey.CanaryIncrementInterval) incrementInterval := input.String(flagkey.CanaryIncrementInterval)
// check for time parsing // check for time parsing
_, err := time.ParseDuration(incrementInterval) _, err := time.ParseDuration(incrementInterval)
@@ -128,7 +128,7 @@ func (opts *CreateSubCommand) complete(flags cli.Input) error {
return nil return nil
} }
func (opts *CreateSubCommand) run(flags cli.Input) error { func (opts *CreateSubCommand) run(input cli.Input) error {
_, err := opts.client.CanaryConfigCreate(opts.canary) _, err := opts.client.CanaryConfigCreate(opts.canary)
if err != nil { if err != nil {
return errors.Wrap(err, "error creating canary config") return errors.Wrap(err, "error creating canary config")
+3 -3
View File
@@ -53,12 +53,12 @@ func (opts *ListSubCommand) do(input cli.Input) error {
return opts.run(input) return opts.run(input)
} }
func (opts *ListSubCommand) complete(flags cli.Input) error { func (opts *ListSubCommand) complete(input cli.Input) error {
opts.namespace = flags.String(flagkey.NamespaceCanary) opts.namespace = input.String(flagkey.NamespaceCanary)
return nil return nil
} }
func (opts *ListSubCommand) run(flags cli.Input) error { func (opts *ListSubCommand) run(input cli.Input) error {
canaryCfgs, err := opts.client.CanaryConfigList(opts.namespace) canaryCfgs, err := opts.client.CanaryConfigList(opts.namespace)
if err != nil { if err != nil {
return errors.Wrap(err, "error listing canary config") return errors.Wrap(err, "error listing canary config")
+1 -1
View File
@@ -21,5 +21,5 @@ import (
) )
type ( type (
CommandAction func(flags cli.Input) error CommandAction func(input cli.Input) error
) )
+14 -14
View File
@@ -30,11 +30,11 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(Create), RunE: wrapper.Wrapper(Create),
} }
wrapper.SetFlags(createCmd, flag.FlagSet{ wrapper.SetFlags(createCmd, flag.FlagSet{
Required: []flag.Flag{flag.EnvNameFlag, flag.EnvImageFlag}, Required: []flag.Flag{flag.EnvName, flag.EnvImage},
Optional: []flag.Flag{flag.NamespaceEnvironmentFlag, flag.EnvPoolsizeFlag, Optional: []flag.Flag{flag.NamespaceEnvironment, flag.EnvPoolsize,
flag.EnvBuilderImageFlag, flag.EnvBuildCmdFlag, flag.EnvKeepArchiveFlag, flag.EnvBuilderImage, flag.EnvBuildCmd, flag.EnvKeepArchive,
flag.RunTimeMinCPUFlag, flag.RunTimeMaxCPUFlag, flag.RunTimeMinMemoryFlag, flag.RunTimeMaxMemoryFlag, flag.RunTimeMinCPU, flag.RunTimeMaxCPU, flag.RunTimeMinMemory, flag.RunTimeMaxMemory,
flag.EnvVersionFlag, flag.EnvExternalNetworkFlag, flag.EnvTerminationGracePeriodFlag, flag.SpecSaveFlag}, flag.EnvVersion, flag.EnvExternalNetwork, flag.EnvTerminationGracePeriod, flag.SpecSave},
}) })
getCmd := &cobra.Command{ getCmd := &cobra.Command{
@@ -43,8 +43,8 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(Get), RunE: wrapper.Wrapper(Get),
} }
wrapper.SetFlags(getCmd, flag.FlagSet{ wrapper.SetFlags(getCmd, flag.FlagSet{
Required: []flag.Flag{flag.EnvNameFlag}, Required: []flag.Flag{flag.EnvName},
Optional: []flag.Flag{flag.NamespaceEnvironmentFlag}, Optional: []flag.Flag{flag.NamespaceEnvironment},
}) })
updateCmd := &cobra.Command{ updateCmd := &cobra.Command{
@@ -53,10 +53,10 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(Update), RunE: wrapper.Wrapper(Update),
} }
wrapper.SetFlags(updateCmd, flag.FlagSet{ wrapper.SetFlags(updateCmd, flag.FlagSet{
Required: []flag.Flag{flag.EnvNameFlag}, Required: []flag.Flag{flag.EnvName},
Optional: []flag.Flag{flag.EnvImageFlag, flag.NamespaceEnvironmentFlag, flag.EnvPoolsizeFlag, Optional: []flag.Flag{flag.EnvImage, flag.NamespaceEnvironment, flag.EnvPoolsize,
flag.EnvBuilderImageFlag, flag.EnvBuildCmdFlag, flag.EnvKeepArchiveFlag, flag.EnvBuilderImage, flag.EnvBuildCmd, flag.EnvKeepArchive,
flag.EnvExternalNetworkFlag, flag.EnvTerminationGracePeriodFlag, flag.SpecSaveFlag}, flag.EnvExternalNetwork, flag.EnvTerminationGracePeriod, flag.SpecSave},
}) })
deleteCmd := &cobra.Command{ deleteCmd := &cobra.Command{
@@ -65,8 +65,8 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(Delete), RunE: wrapper.Wrapper(Delete),
} }
wrapper.SetFlags(deleteCmd, flag.FlagSet{ wrapper.SetFlags(deleteCmd, flag.FlagSet{
Required: []flag.Flag{flag.EnvNameFlag}, Required: []flag.Flag{flag.EnvName},
Optional: []flag.Flag{flag.NamespaceEnvironmentFlag}, Optional: []flag.Flag{flag.NamespaceEnvironment},
}) })
listCmd := &cobra.Command{ listCmd := &cobra.Command{
@@ -76,7 +76,7 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(List), RunE: wrapper.Wrapper(List),
} }
wrapper.SetFlags(listCmd, flag.FlagSet{ wrapper.SetFlags(listCmd, flag.FlagSet{
Optional: []flag.Flag{flag.NamespaceEnvironmentFlag}, Optional: []flag.Flag{flag.NamespaceEnvironment},
}) })
command := &cobra.Command{ command := &cobra.Command{
+28 -28
View File
@@ -30,13 +30,13 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(Create), RunE: wrapper.Wrapper(Create),
} }
wrapper.SetFlags(createCmd, flag.FlagSet{ wrapper.SetFlags(createCmd, flag.FlagSet{
Required: []flag.Flag{flag.FnNameFlag}, Required: []flag.Flag{flag.FnName},
Optional: []flag.Flag{flag.NamespaceFunctionFlag, flag.NamespaceEnvironmentFlag, flag.SpecSaveFlag, Optional: []flag.Flag{flag.NamespaceFunction, flag.NamespaceEnvironment, flag.SpecSave,
flag.FnEnvNameFlag, flag.FnCodeFlag, flag.PkgSrcArchiveFlag, flag.PkgDeployArchiveFlag, flag.FnKeepURLFlag, flag.FnEnvName, flag.FnCode, flag.PkgSrcArchive, flag.PkgDeployArchive, flag.FnKeepURL,
flag.FnEntryPointFlag, flag.FnBuildCmdFlag, flag.FnPkgNameFlag, flag.HtUrlFlag, flag.HtMethodFlag, flag.FnEntryPoint, flag.FnBuildCmd, flag.FnPkgName, flag.HtUrl, flag.HtMethod,
flag.RunTimeMinCPUFlag, flag.RunTimeMaxCPUFlag, flag.RunTimeMinMemoryFlag, flag.RunTimeMaxMemoryFlag, flag.RunTimeMinCPU, flag.RunTimeMaxCPU, flag.RunTimeMinMemory, flag.RunTimeMaxMemory,
flag.ReplicasMinFlag, flag.ReplicasMaxFlag, flag.FnExecutorTypeFlag, flag.RunTimeTargetCPUFlag, flag.ReplicasMin, flag.ReplicasMax, flag.FnExecutorType, flag.RunTimeTargetCPU,
flag.FnCfgMapFlag, flag.FnSecretFlag, flag.FnSpecializationTimeoutFlag, flag.FnExecutionTimeoutFlag}, flag.FnCfgMap, flag.FnSecret, flag.FnSpecializationTimeout, flag.FnExecutionTimeout},
}) })
getCmd := &cobra.Command{ getCmd := &cobra.Command{
@@ -46,8 +46,8 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(Get), RunE: wrapper.Wrapper(Get),
} }
wrapper.SetFlags(getCmd, flag.FlagSet{ wrapper.SetFlags(getCmd, flag.FlagSet{
Required: []flag.Flag{flag.FnNameFlag}, Required: []flag.Flag{flag.FnName},
Optional: []flag.Flag{flag.NamespaceFunctionFlag}, Optional: []flag.Flag{flag.NamespaceFunction},
}) })
getmetaCmd := &cobra.Command{ getmetaCmd := &cobra.Command{
@@ -57,8 +57,8 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(GetMeta), RunE: wrapper.Wrapper(GetMeta),
} }
wrapper.SetFlags(getmetaCmd, flag.FlagSet{ wrapper.SetFlags(getmetaCmd, flag.FlagSet{
Required: []flag.Flag{flag.FnNameFlag}, Required: []flag.Flag{flag.FnName},
Optional: []flag.Flag{flag.NamespaceFunctionFlag}, Optional: []flag.Flag{flag.NamespaceFunction},
}) })
updateCmd := &cobra.Command{ updateCmd := &cobra.Command{
@@ -68,14 +68,14 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(Update), RunE: wrapper.Wrapper(Update),
} }
wrapper.SetFlags(updateCmd, flag.FlagSet{ wrapper.SetFlags(updateCmd, flag.FlagSet{
Required: []flag.Flag{flag.FnNameFlag}, Required: []flag.Flag{flag.FnName},
Optional: []flag.Flag{flag.NamespaceFunctionFlag, flag.NamespaceEnvironmentFlag, flag.SpecSaveFlag, Optional: []flag.Flag{flag.NamespaceFunction, flag.NamespaceEnvironment, flag.SpecSave,
flag.FnCodeFlag, flag.PkgSrcArchiveFlag, flag.PkgDeployArchiveFlag, flag.FnCode, flag.PkgSrcArchive, flag.PkgDeployArchive,
flag.FnKeepURLFlag, flag.FnEntryPointFlag, flag.FnBuildCmdFlag, flag.FnPkgNameFlag, flag.HtUrlFlag, flag.FnKeepURL, flag.FnEntryPoint, flag.FnBuildCmd, flag.FnPkgName, flag.HtUrl,
flag.HtMethodFlag, flag.RunTimeMinCPUFlag, flag.RunTimeMaxCPUFlag, flag.RunTimeMinMemoryFlag, flag.HtMethod, flag.RunTimeMinCPU, flag.RunTimeMaxCPU, flag.RunTimeMinMemory,
flag.RunTimeMaxMemoryFlag, flag.ReplicasMinFlag, flag.ReplicasMaxFlag, flag.FnExecutorTypeFlag, flag.RunTimeMaxMemory, flag.ReplicasMin, flag.ReplicasMax, flag.FnExecutorType,
flag.RunTimeTargetCPUFlag, flag.FnCfgMapFlag, flag.FnSecretFlag, flag.FnSpecializationTimeoutFlag, flag.RunTimeTargetCPU, flag.FnCfgMap, flag.FnSecret, flag.FnSpecializationTimeout,
flag.FnExecutionTimeoutFlag, flag.PkgForceFlag}, flag.FnExecutionTimeout, flag.PkgForce},
}) })
deleteCmd := &cobra.Command{ deleteCmd := &cobra.Command{
@@ -85,8 +85,8 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(Delete), RunE: wrapper.Wrapper(Delete),
} }
wrapper.SetFlags(deleteCmd, flag.FlagSet{ wrapper.SetFlags(deleteCmd, flag.FlagSet{
Required: []flag.Flag{flag.FnNameFlag}, Required: []flag.Flag{flag.FnName},
Optional: []flag.Flag{flag.NamespaceFunctionFlag}, Optional: []flag.Flag{flag.NamespaceFunction},
}) })
listCmd := &cobra.Command{ listCmd := &cobra.Command{
@@ -96,7 +96,7 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(List), RunE: wrapper.Wrapper(List),
} }
wrapper.SetFlags(listCmd, flag.FlagSet{ wrapper.SetFlags(listCmd, flag.FlagSet{
Optional: []flag.Flag{flag.NamespaceFunctionFlag}, Optional: []flag.Flag{flag.NamespaceFunction},
}) })
logsCmd := &cobra.Command{ logsCmd := &cobra.Command{
@@ -106,9 +106,9 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(Log), RunE: wrapper.Wrapper(Log),
} }
wrapper.SetFlags(logsCmd, flag.FlagSet{ wrapper.SetFlags(logsCmd, flag.FlagSet{
Required: []flag.Flag{flag.FnNameFlag}, Required: []flag.Flag{flag.FnName},
Optional: []flag.Flag{flag.NamespaceFunctionFlag, flag.FnLogPodFlag, flag.FnLogFollowFlag, Optional: []flag.Flag{flag.NamespaceFunction, flag.FnLogPod, flag.FnLogFollow,
flag.FnLogDetailFlag, flag.FnLogDBTypeFlag, flag.FnLogReverseQueryFlag, flag.FnLogCountFlag}, flag.FnLogDetail, flag.FnLogDBType, flag.FnLogReverseQuery, flag.FnLogCount},
}) })
testCmd := &cobra.Command{ testCmd := &cobra.Command{
@@ -118,9 +118,9 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(Test), RunE: wrapper.Wrapper(Test),
} }
wrapper.SetFlags(testCmd, flag.FlagSet{ wrapper.SetFlags(testCmd, flag.FlagSet{
Required: []flag.Flag{flag.FnNameFlag}, Required: []flag.Flag{flag.FnName},
Optional: []flag.Flag{flag.NamespaceFunctionFlag, flag.HtMethodFlag, flag.FnTestBodyFlag, Optional: []flag.Flag{flag.NamespaceFunction, flag.HtMethod, flag.FnTestBody,
flag.FnTestHeaderFlag, flag.FnTestQueryFlag, flag.FnTestTimeoutFlag}, flag.FnTestHeader, flag.FnTestQuery, flag.FnTestTimeout},
}) })
command := &cobra.Command{ command := &cobra.Command{
+25 -27
View File
@@ -83,12 +83,10 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
specDir := util.GetSpecDir(input) specDir := util.GetSpecDir(input)
// check for unique function names within a namespace // check for unique function names within a namespace
metadata, err := util.GetMetadata(flagkey.FnName, flagkey.NamespaceFunction, input) fn, err := opts.client.FunctionGet(&metav1.ObjectMeta{
if err != nil { Name: input.String(flagkey.FnName),
return err Namespace: input.String(flagkey.NamespaceFunction),
} })
fn, err := opts.client.FunctionGet(metadata)
if err != nil && !ferror.IsNotFound(err) { if err != nil && !ferror.IsNotFound(err) {
return err return err
} else if fn != nil { } else if fn != nil {
@@ -174,7 +172,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
keepURL := input.Bool(flagkey.PkgKeepURL) keepURL := input.Bool(flagkey.PkgKeepURL)
// create new package in the same namespace as the function. // create new package in the same namespace as the function.
pkgMetadata, err = _package.CreatePackage(input, opts.client, fnNamespace, envName, envNamespace, pkgMetadata, err = _package.CreatePackage(input, opts.client, fnName, fnNamespace, envName, envNamespace,
srcArchiveFiles, deployArchiveFiles, buildcmd, specDir, opts.specFile, noZip, keepURL) srcArchiveFiles, deployArchiveFiles, buildcmd, specDir, opts.specFile, noZip, keepURL)
if err != nil { if err != nil {
return errors.Wrap(err, "error creating package") return errors.Wrap(err, "error creating package")
@@ -263,9 +261,9 @@ func (opts *CreateSubCommand) complete(input cli.Input) error {
// run write the resource to a spec file or create a fission CRD with remote fission server. // run write the resource to a spec file or create a fission CRD with remote fission server.
// It also prints warning/error if necessary. // It also prints warning/error if necessary.
func (opts *CreateSubCommand) run(flags cli.Input) error { func (opts *CreateSubCommand) run(input cli.Input) error {
// if we're writing a spec, don't create the function // if we're writing a spec, don't create the function
if flags.Bool(flagkey.SpecSave) { if input.Bool(flagkey.SpecSave) {
err := spec.SpecSave(*opts.function, opts.specFile) err := spec.SpecSave(*opts.function, opts.specFile)
if err != nil { if err != nil {
return errors.Wrap(err, "error creating function spec") return errors.Wrap(err, "error creating function spec")
@@ -281,7 +279,7 @@ func (opts *CreateSubCommand) run(flags cli.Input) error {
fmt.Printf("function '%v' created\n", opts.function.Metadata.Name) fmt.Printf("function '%v' created\n", opts.function.Metadata.Name)
// Allow the user to specify an HTTP trigger while creating a function. // Allow the user to specify an HTTP trigger while creating a function.
triggerUrl := flags.String(flagkey.HtUrl) triggerUrl := input.String(flagkey.HtUrl)
if len(triggerUrl) == 0 { if len(triggerUrl) == 0 {
return nil return nil
} }
@@ -289,7 +287,7 @@ func (opts *CreateSubCommand) run(flags cli.Input) error {
triggerUrl = fmt.Sprintf("/%s", triggerUrl) triggerUrl = fmt.Sprintf("/%s", triggerUrl)
} }
method, err := httptrigger.GetMethod(flags.String(flagkey.HtMethod)) method, err := httptrigger.GetMethod(input.String(flagkey.HtMethod))
if err != nil { if err != nil {
return errors.Wrap(err, "error getting HTTP trigger method") return errors.Wrap(err, "error getting HTTP trigger method")
} }
@@ -318,11 +316,11 @@ func (opts *CreateSubCommand) run(flags cli.Input) error {
return nil return nil
} }
func getInvokeStrategy(flags cli.Input, existingInvokeStrategy *fv1.InvokeStrategy) (strategy *fv1.InvokeStrategy, err error) { func getInvokeStrategy(input cli.Input, existingInvokeStrategy *fv1.InvokeStrategy) (strategy *fv1.InvokeStrategy, err error) {
var fnExecutor, newFnExecutor fv1.ExecutorType var fnExecutor, newFnExecutor fv1.ExecutorType
switch flags.String(flagkey.FnExecutorType) { switch input.String(flagkey.FnExecutorType) {
case "": case "":
fallthrough fallthrough
case types.ExecutorTypePoolmgr: case types.ExecutorTypePoolmgr:
@@ -337,23 +335,23 @@ func getInvokeStrategy(flags cli.Input, existingInvokeStrategy *fv1.InvokeStrate
fnExecutor = existingInvokeStrategy.ExecutionStrategy.ExecutorType fnExecutor = existingInvokeStrategy.ExecutionStrategy.ExecutorType
// override the executor type if user specified a new executor type // override the executor type if user specified a new executor type
if flags.IsSet(flagkey.FnExecutorType) { if input.IsSet(flagkey.FnExecutorType) {
fnExecutor = newFnExecutor fnExecutor = newFnExecutor
} }
} else { } else {
fnExecutor = newFnExecutor fnExecutor = newFnExecutor
} }
if flags.IsSet(flagkey.FnSpecializationTimeout) && fnExecutor != types.ExecutorTypeNewdeploy { if input.IsSet(flagkey.FnSpecializationTimeout) && fnExecutor != types.ExecutorTypeNewdeploy {
return nil, errors.Errorf("%v flag is only applicable for newdeploy type of executor", flagkey.FnSpecializationTimeout) return nil, errors.Errorf("%v flag is only applicable for newdeploy type of executor", flagkey.FnSpecializationTimeout)
} }
if fnExecutor == types.ExecutorTypePoolmgr { if fnExecutor == types.ExecutorTypePoolmgr {
if flags.IsSet(flagkey.RuntimeTargetcpu) || flags.IsSet(flagkey.ReplicasMinscale) || flags.IsSet(flagkey.ReplicasMaxscale) { if input.IsSet(flagkey.RuntimeTargetcpu) || input.IsSet(flagkey.ReplicasMinscale) || input.IsSet(flagkey.ReplicasMaxscale) {
return nil, errors.New("to set target CPU or min/max scale for function, please specify \"--executortype newdeploy\"") return nil, errors.New("to set target CPU or min/max scale for function, please specify \"--executortype newdeploy\"")
} }
if flags.IsSet(flagkey.RuntimeMincpu) || flags.IsSet(flagkey.RuntimeMaxcpu) || flags.IsSet(flagkey.RuntimeMinmemory) || flags.IsSet(flagkey.RuntimeMaxmemory) { if input.IsSet(flagkey.RuntimeMincpu) || input.IsSet(flagkey.RuntimeMaxcpu) || input.IsSet(flagkey.RuntimeMinmemory) || input.IsSet(flagkey.RuntimeMaxmemory) {
console.Warn("To limit CPU/Memory for function with executor type \"poolmgr\", please specify resources limits when creating environment") console.Warn("To limit CPU/Memory for function with executor type \"poolmgr\", please specify resources limits when creating environment")
} }
strategy = &fv1.InvokeStrategy{ strategy = &fv1.InvokeStrategy{
@@ -376,26 +374,26 @@ func getInvokeStrategy(flags cli.Input, existingInvokeStrategy *fv1.InvokeStrate
specializationTimeout = existingInvokeStrategy.ExecutionStrategy.SpecializationTimeout specializationTimeout = existingInvokeStrategy.ExecutionStrategy.SpecializationTimeout
} }
if flags.IsSet(flagkey.RuntimeTargetcpu) { if input.IsSet(flagkey.RuntimeTargetcpu) {
targetCPU, err = getTargetCPU(flags) targetCPU, err = getTargetCPU(input)
if err != nil { if err != nil {
return nil, err return nil, err
} }
} }
if flags.IsSet(flagkey.ReplicasMinscale) { if input.IsSet(flagkey.ReplicasMinscale) {
minScale = flags.Int(flagkey.ReplicasMinscale) minScale = input.Int(flagkey.ReplicasMinscale)
} }
if flags.IsSet(flagkey.ReplicasMaxscale) { if input.IsSet(flagkey.ReplicasMaxscale) {
maxScale = flags.Int(flagkey.ReplicasMaxscale) maxScale = input.Int(flagkey.ReplicasMaxscale)
if maxScale <= 0 { if maxScale <= 0 {
return nil, errors.Errorf("%v must be greater than 0", flagkey.ReplicasMaxscale) return nil, errors.Errorf("%v must be greater than 0", flagkey.ReplicasMaxscale)
} }
} }
if flags.IsSet(flagkey.FnSpecializationTimeout) { if input.IsSet(flagkey.FnSpecializationTimeout) {
specializationTimeout = flags.Int(flagkey.FnSpecializationTimeout) specializationTimeout = input.Int(flagkey.FnSpecializationTimeout)
if specializationTimeout < fv1.DefaultSpecializationTimeOut { if specializationTimeout < fv1.DefaultSpecializationTimeOut {
return nil, errors.Errorf("%v must be greater than or equal to 120 seconds", flagkey.FnSpecializationTimeout) return nil, errors.Errorf("%v must be greater than or equal to 120 seconds", flagkey.FnSpecializationTimeout)
} }
@@ -422,8 +420,8 @@ func getInvokeStrategy(flags cli.Input, existingInvokeStrategy *fv1.InvokeStrate
return strategy, nil return strategy, nil
} }
func getTargetCPU(flags cli.Input) (int, error) { func getTargetCPU(input cli.Input) (int, error) {
targetCPU := flags.Int(flagkey.RuntimeTargetcpu) targetCPU := input.Int(flagkey.RuntimeTargetcpu)
if targetCPU <= 0 || targetCPU > 100 { if targetCPU <= 0 || targetCPU > 100 {
return 0, errors.Errorf("%v must be a value between 1 - 100", flagkey.RuntimeTargetcpu) return 0, errors.Errorf("%v must be a value between 1 - 100", flagkey.RuntimeTargetcpu)
} }
@@ -18,13 +18,13 @@ package function
import ( import (
"fmt" "fmt"
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
"testing" "testing"
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1" fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
"github.com/fission/fission/pkg/fission-cli/cliwrapper/driver/dummy" "github.com/fission/fission/pkg/fission-cli/cliwrapper/driver/dummy"
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
) )
func TestGetInvokeStrategy(t *testing.T) { func TestGetInvokeStrategy(t *testing.T) {
-3
View File
@@ -160,9 +160,6 @@ func doHTTPRequest(ctx context.Context, method, url, body string, headers []stri
func printPodLogs(input cli.Input) error { func printPodLogs(input cli.Input) error {
fnName := input.String(flagkey.FnName) fnName := input.String(flagkey.FnName)
if len(fnName) == 0 {
return errors.New("need --name argument.")
}
u, err := util.GetApplicationUrl("application=fission-api") u, err := util.GetApplicationUrl("application=fission-api")
if err != nil { if err != nil {
+25 -27
View File
@@ -18,7 +18,6 @@ package function
import ( import (
"fmt" "fmt"
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
"github.com/pkg/errors" "github.com/pkg/errors"
k8serrors "k8s.io/apimachinery/pkg/api/errors" k8serrors "k8s.io/apimachinery/pkg/api/errors"
@@ -29,6 +28,7 @@ import (
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli" "github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
_package "github.com/fission/fission/pkg/fission-cli/cmd/package" _package "github.com/fission/fission/pkg/fission-cli/cmd/package"
"github.com/fission/fission/pkg/fission-cli/console" "github.com/fission/fission/pkg/fission-cli/console"
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
"github.com/fission/fission/pkg/fission-cli/util" "github.com/fission/fission/pkg/fission-cli/util"
"github.com/fission/fission/pkg/types" "github.com/fission/fission/pkg/types"
) )
@@ -61,18 +61,16 @@ func (opts *UpdateSubCommand) complete(input cli.Input) error {
fnName := input.String(flagkey.FnName) fnName := input.String(flagkey.FnName)
fnNamespace := input.String(flagkey.NamespaceFunction) fnNamespace := input.String(flagkey.NamespaceFunction)
m, err := util.GetMetadata("name", "fnNamespace", input) function, err := opts.client.FunctionGet(&metav1.ObjectMeta{
if err != nil { Name: input.String(flagkey.FnName),
return err Namespace: input.String(flagkey.NamespaceFunction),
} })
function, err := opts.client.FunctionGet(m)
if err != nil { if err != nil {
return errors.Wrap(err, fmt.Sprintf("read function '%v'", fnName)) return errors.Wrap(err, fmt.Sprintf("read function '%v'", fnName))
} }
envName := input.String("env") envName := input.String(flagkey.FnEnvironmentName)
envNamespace := input.String("envNamespace") envNamespace := input.String(flagkey.NamespaceEnvironment)
// if the new env specified is the same as the old one, no need to update package // if the new env specified is the same as the old one, no need to update package
// same is true for all update parameters, but, for now, we dont check all of them - because, its ok to // same is true for all update parameters, but, for now, we dont check all of them - because, its ok to
// re-write the object with same old values, we just end up getting a new resource version for the object. // re-write the object with same old values, we just end up getting a new resource version for the object.
@@ -86,27 +84,27 @@ func (opts *UpdateSubCommand) complete(input cli.Input) error {
var deployArchiveFiles []string var deployArchiveFiles []string
codeFlag := false codeFlag := false
code := input.String("code") code := input.String(flagkey.FnCode)
if len(code) == 0 { if len(code) == 0 {
deployArchiveFiles = input.StringSlice("deploy") deployArchiveFiles = input.StringSlice(flagkey.PkgDeployArchive)
} else { } else {
deployArchiveFiles = append(deployArchiveFiles, input.String("code")) deployArchiveFiles = append(deployArchiveFiles, input.String(flagkey.FnCode))
codeFlag = true codeFlag = true
} }
srcArchiveFiles := input.StringSlice("src") srcArchiveFiles := input.StringSlice(flagkey.PkgSrcArchive)
pkgName := input.String("pkg") pkgName := input.String(flagkey.FnPackageName)
entrypoint := input.String("entrypoint") entrypoint := input.String(flagkey.FnEntrypoint)
buildcmd := input.String("buildcmd") buildcmd := input.String(flagkey.PkgBuildCmd)
force := input.Bool("force") force := input.Bool(flagkey.PkgForce)
secretNames := input.StringSlice("secret") secretNames := input.StringSlice(flagkey.FnSecret)
cfgMapNames := input.StringSlice("configmap") cfgMapNames := input.StringSlice(flagkey.FnCfgMap)
specializationTimeout := input.Int("specializationtimeout") specializationTimeout := input.Int(flagkey.FnSpecializationTimeout)
if len(srcArchiveFiles) > 0 && len(deployArchiveFiles) > 0 { if len(srcArchiveFiles) > 0 && len(deployArchiveFiles) > 0 {
return errors.New("Need either of --src or --deploy and not both arguments.") return errors.Errorf("need either of --%v or --%v and not both arguments", flagkey.PkgSrcArchive, flagkey.PkgDeployArchive)
} }
var secrets []fv1.SecretReference var secrets []fv1.SecretReference
@@ -171,10 +169,10 @@ func (opts *UpdateSubCommand) complete(input cli.Input) error {
function.Spec.Package.FunctionName = entrypoint function.Spec.Package.FunctionName = entrypoint
} }
if input.IsSet("fntimeout") { if input.IsSet(flagkey.FnExecutionTimeout) {
fnTimeout := input.Int("fntimeout") fnTimeout := input.Int(flagkey.FnExecutionTimeout)
if fnTimeout <= 0 { if fnTimeout <= 0 {
return errors.New("fntimeout must be greater than 0") return errors.Errorf("--%v must be greater than 0", flagkey.FnExecutionTimeout)
} }
function.Spec.FunctionTimeout = fnTimeout function.Spec.FunctionTimeout = fnTimeout
} }
@@ -189,13 +187,13 @@ func (opts *UpdateSubCommand) complete(input cli.Input) error {
} }
function.Spec.InvokeStrategy = *strategy function.Spec.InvokeStrategy = *strategy
if input.IsSet("specializationtimeout") { if input.IsSet(flagkey.FnSpecializationTimeout) {
if strategy.ExecutionStrategy.ExecutorType != types.ExecutorTypeNewdeploy { if strategy.ExecutionStrategy.ExecutorType != types.ExecutorTypeNewdeploy {
return errors.New("specializationtimeout flag is only applicable for newdeploy type of executor") return errors.Errorf("--%v flag is only applicable for newdeploy type of executor", flagkey.FnSpecializationTimeout)
} }
if specializationTimeout < fv1.DefaultSpecializationTimeOut { if specializationTimeout < fv1.DefaultSpecializationTimeOut {
return errors.New("specializationtimeout must be greater than or equal to 120 seconds") return errors.Errorf("--%v must be greater than or equal to 120 seconds", flagkey.FnSpecializationTimeout)
} else { } else {
function.Spec.InvokeStrategy.ExecutionStrategy.SpecializationTimeout = specializationTimeout function.Spec.InvokeStrategy.ExecutionStrategy.SpecializationTimeout = specializationTimeout
} }
+11 -12
View File
@@ -30,10 +30,10 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(Create), RunE: wrapper.Wrapper(Create),
} }
wrapper.SetFlags(createCmd, flag.FlagSet{ wrapper.SetFlags(createCmd, flag.FlagSet{
Required: []flag.Flag{flag.HtUrlFlag, flag.HtFnNameFlag}, Required: []flag.Flag{flag.HtUrl, flag.HtFnName},
Optional: []flag.Flag{flag.HtNameFlag, flag.HtMethodFlag, flag.HtIngressRuleFlag, Optional: []flag.Flag{flag.HtName, flag.HtMethod, flag.HtIngressRule,
flag.HtIngressAnnotationFlag, flag.HtIngressTLSFlag, flag.HtIngressFlag, flag.HtIngressAnnotation, flag.HtIngressTLS, flag.HtIngress,
flag.HtFnWeightFlag, flag.HtHostFlag, flag.NamespaceFunctionFlag, flag.SpecSaveFlag}, flag.HtFnWeight, flag.HtHost, flag.NamespaceFunction, flag.SpecSave},
}) })
getCmd := &cobra.Command{ getCmd := &cobra.Command{
@@ -43,7 +43,7 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(Get), RunE: wrapper.Wrapper(Get),
} }
wrapper.SetFlags(getCmd, flag.FlagSet{ wrapper.SetFlags(getCmd, flag.FlagSet{
Required: []flag.Flag{flag.HtNameFlag}, Required: []flag.Flag{flag.HtName},
}) })
updateCmd := &cobra.Command{ updateCmd := &cobra.Command{
@@ -53,10 +53,10 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(Update), RunE: wrapper.Wrapper(Update),
} }
wrapper.SetFlags(updateCmd, flag.FlagSet{ wrapper.SetFlags(updateCmd, flag.FlagSet{
Required: []flag.Flag{flag.HtNameFlag}, Required: []flag.Flag{flag.HtName},
Optional: []flag.Flag{flag.NamespaceTriggerFlag, flag.HtFnNameFlag, flag.HtUrlFlag, Optional: []flag.Flag{flag.NamespaceTrigger, flag.HtFnName, flag.HtUrl,
flag.HtMethodFlag, flag.HtIngressRuleFlag, flag.HtIngressAnnotationFlag, flag.HtMethod, flag.HtIngressRule, flag.HtIngressAnnotation,
flag.HtIngressTLSFlag, flag.HtIngressFlag, flag.HtFnWeightFlag, flag.HtHostFlag}, flag.HtIngressTLS, flag.HtIngress, flag.HtFnWeight, flag.HtHost},
}) })
deleteCmd := &cobra.Command{ deleteCmd := &cobra.Command{
@@ -66,8 +66,7 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(Delete), RunE: wrapper.Wrapper(Delete),
} }
wrapper.SetFlags(deleteCmd, flag.FlagSet{ wrapper.SetFlags(deleteCmd, flag.FlagSet{
Required: []flag.Flag{flag.HtNameFlag}, Optional: []flag.Flag{flag.HtName, flag.HtFnFilter, flag.NamespaceTrigger},
Optional: []flag.Flag{flag.NamespaceTriggerFlag, flag.HtFnFilterFlag},
}) })
listCmd := &cobra.Command{ listCmd := &cobra.Command{
@@ -77,7 +76,7 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(List), RunE: wrapper.Wrapper(List),
} }
wrapper.SetFlags(listCmd, flag.FlagSet{ wrapper.SetFlags(listCmd, flag.FlagSet{
Optional: []flag.Flag{flag.NamespaceTriggerFlag, flag.HtFnFilterFlag}, Optional: []flag.Flag{flag.NamespaceTrigger, flag.HtFnFilter},
}) })
command := &cobra.Command{ command := &cobra.Command{
+38 -41
View File
@@ -31,6 +31,7 @@ import (
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli" "github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
"github.com/fission/fission/pkg/fission-cli/cmd/spec" "github.com/fission/fission/pkg/fission-cli/cmd/spec"
"github.com/fission/fission/pkg/fission-cli/console" "github.com/fission/fission/pkg/fission-cli/console"
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
"github.com/fission/fission/pkg/fission-cli/util" "github.com/fission/fission/pkg/fission-cli/util"
) )
@@ -39,28 +40,28 @@ type CreateSubCommand struct {
trigger *fv1.HTTPTrigger trigger *fv1.HTTPTrigger
} }
func Create(flags cli.Input) error { func Create(input cli.Input) error {
c, err := util.GetServer(flags) c, err := util.GetServer(input)
if err != nil { if err != nil {
return err return err
} }
opts := CreateSubCommand{ opts := CreateSubCommand{
client: c, client: c,
} }
return opts.do(flags) return opts.do(input)
} }
func (opts *CreateSubCommand) do(flags cli.Input) error { func (opts *CreateSubCommand) do(input cli.Input) error {
err := opts.complete(flags) err := opts.complete(input)
if err != nil { if err != nil {
return err return err
} }
return opts.run(flags) return opts.run(input)
} }
func (opts *CreateSubCommand) complete(flags cli.Input) error { func (opts *CreateSubCommand) complete(input cli.Input) error {
functionList := flags.StringSlice("function") functionList := input.StringSlice(flagkey.HtFnName)
functionWeightsList := flags.IntSlice("weight") functionWeightsList := input.IntSlice(flagkey.HtFnWeight)
if len(functionList) == 0 { if len(functionList) == 0 {
return errors.New("need a function name to create a trigger, use --function") return errors.New("need a function name to create a trigger, use --function")
@@ -71,8 +72,13 @@ func (opts *CreateSubCommand) complete(flags cli.Input) error {
return err return err
} }
triggerName := flags.String("name") triggerName := input.String(flagkey.HtName)
fnNamespace := flags.String("fnNamespace") // just name triggers by uuid.
if triggerName == "" {
console.Warn(fmt.Sprintf("--%v will be soon marked as required flag, see 'help' for details", flagkey.HtName))
triggerName = uuid.NewV4().String()
}
fnNamespace := input.String(flagkey.NamespaceFunction)
m := &metav1.ObjectMeta{ m := &metav1.ObjectMeta{
Name: triggerName, Name: triggerName,
@@ -87,44 +93,35 @@ func (opts *CreateSubCommand) complete(flags cli.Input) error {
return errors.New("duplicate trigger exists, choose a different name or leave it empty for fission to auto-generate it") return errors.New("duplicate trigger exists, choose a different name or leave it empty for fission to auto-generate it")
} }
triggerUrl := flags.String("url") triggerUrl := input.String(flagkey.HtUrl)
if len(triggerUrl) == 0 { if triggerUrl == "/" {
return errors.New("need a trigger URL, use --url") return errors.New("url with only root path is not allowed")
} } else if !strings.HasPrefix(triggerUrl, "/") {
if !strings.HasPrefix(triggerUrl, "/") {
triggerUrl = fmt.Sprintf("/%s", triggerUrl) triggerUrl = fmt.Sprintf("/%s", triggerUrl)
} }
method, err := GetMethod(flags.String("method")) method, err := GetMethod(input.String(flagkey.HtMethod))
if err != nil { if err != nil {
return err return err
} }
// For Specs, the spec validate checks for function reference // For Specs, the spec validate checks for function reference
if !flags.Bool("spec") { if !input.Bool(flagkey.SpecSave) {
err = util.CheckFunctionExistence(opts.client, functionList, fnNamespace) err = util.CheckFunctionExistence(opts.client, functionList, fnNamespace)
if err != nil { if err != nil {
console.Warn(err.Error()) console.Warn(err.Error())
} }
} }
createIngress := flags.Bool("createingress") createIngress := input.Bool(flagkey.HtIngress)
ingressConfig, err := GetIngressConfig( ingressConfig, err := GetIngressConfig(
flags.StringSlice("ingressannotation"), flags.String("ingressrule"), input.StringSlice(flagkey.HtIngressAnnotation), input.String(flagkey.HtIngressRule),
flags.String("ingresstls"), triggerUrl, nil) input.String(flagkey.HtIngressTLS), triggerUrl, nil)
if err != nil { if err != nil {
return errors.Wrap(err, "error parsing ingress configuration") return errors.Wrap(err, "error parsing ingress configuration")
} }
host := flags.String("host") host := input.String(flagkey.HtHost)
if flags.IsSet("host") {
console.Warn(fmt.Sprintf("--host is now marked as deprecated, see 'help' for details"))
}
// just name triggers by uuid.
if triggerName == "" {
triggerName = uuid.NewV4().String()
}
opts.trigger = &fv1.HTTPTrigger{ opts.trigger = &fv1.HTTPTrigger{
Metadata: metav1.ObjectMeta{ Metadata: metav1.ObjectMeta{
@@ -144,9 +141,9 @@ func (opts *CreateSubCommand) complete(flags cli.Input) error {
return nil return nil
} }
func (opts *CreateSubCommand) run(flags cli.Input) error { func (opts *CreateSubCommand) run(input cli.Input) error {
// if we're writing a spec, don't call the API // if we're writing a spec, don't call the API
if flags.Bool("spec") { if input.Bool(flagkey.SpecSave) {
specFile := fmt.Sprintf("route-%v.yaml", opts.trigger.Metadata.Name) specFile := fmt.Sprintf("route-%v.yaml", opts.trigger.Metadata.Name)
err := spec.SpecSave(*opts.trigger, specFile) err := spec.SpecSave(*opts.trigger, specFile)
if err != nil { if err != nil {
@@ -168,23 +165,23 @@ func (opts *CreateSubCommand) run(flags cli.Input) error {
// GetMethod returns one of HTTP method // GetMethod returns one of HTTP method
func GetMethod(method string) (string, error) { func GetMethod(method string) (string, error) {
switch strings.ToUpper(method) { switch strings.ToUpper(method) {
case "GET": case http.MethodGet:
return http.MethodGet, nil return http.MethodGet, nil
case "HEAD": case http.MethodHead:
return http.MethodHead, nil return http.MethodHead, nil
case "POST": case http.MethodPost:
return http.MethodPost, nil return http.MethodPost, nil
case "PUT": case http.MethodPut:
return http.MethodPut, nil return http.MethodPut, nil
case "PATCH": case http.MethodPatch:
return http.MethodPatch, nil return http.MethodPatch, nil
case "DELETE": case http.MethodDelete:
return http.MethodDelete, nil return http.MethodDelete, nil
case "CONNECT": case http.MethodConnect:
return http.MethodConnect, nil return http.MethodConnect, nil
case "OPTIONS": case http.MethodOptions:
return http.MethodOptions, nil return http.MethodOptions, nil
case "TRACE": case http.MethodTrace:
return http.MethodTrace, nil return http.MethodTrace, nil
default: default:
return "", fmt.Errorf("invalid or unsupported HTTP Method %v", method) return "", fmt.Errorf("invalid or unsupported HTTP Method %v", method)
+14 -13
View File
@@ -25,6 +25,7 @@ import (
"github.com/fission/fission/pkg/controller/client" "github.com/fission/fission/pkg/controller/client"
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli" "github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
"github.com/fission/fission/pkg/fission-cli/util" "github.com/fission/fission/pkg/fission-cli/util"
"github.com/fission/fission/pkg/utils" "github.com/fission/fission/pkg/utils"
) )
@@ -36,38 +37,38 @@ type DeleteSubCommand struct {
namespace string namespace string
} }
func Delete(flags cli.Input) error { func Delete(input cli.Input) error {
c, err := util.GetServer(flags) c, err := util.GetServer(input)
if err != nil { if err != nil {
return err return err
} }
opts := DeleteSubCommand{ opts := DeleteSubCommand{
client: c, client: c,
} }
return opts.do(flags) return opts.do(input)
} }
func (opts *DeleteSubCommand) do(flags cli.Input) error { func (opts *DeleteSubCommand) do(input cli.Input) error {
err := opts.complete(flags) err := opts.complete(input)
if err != nil { if err != nil {
return err return err
} }
return opts.run(flags) return opts.run(input)
} }
func (opts *DeleteSubCommand) complete(flags cli.Input) error { func (opts *DeleteSubCommand) complete(input cli.Input) error {
opts.triggerName = flags.String("name") opts.triggerName = input.String(flagkey.HtName)
opts.functionName = flags.String("function") opts.functionName = input.String(flagkey.HtFnName)
if len(opts.triggerName) == 0 && len(opts.functionName) == 0 { if len(opts.triggerName) == 0 && len(opts.functionName) == 0 {
return errors.New("need --name or --function") return errors.Errorf("need --%v or --%v", flagkey.HtName, flagkey.HtFnName)
} else if len(opts.triggerName) > 0 && len(opts.functionName) > 0 { } else if len(opts.triggerName) > 0 && len(opts.functionName) > 0 {
return errors.New("need either of --name or --function and not both arguments") return errors.Errorf("need either of --%v or --%v and not both arguments", flagkey.HtName, flagkey.HtFnName)
} }
opts.namespace = flags.String("triggerNamespace") opts.namespace = input.String(flagkey.NamespaceTrigger)
return nil return nil
} }
func (opts *DeleteSubCommand) run(flags cli.Input) error { func (opts *DeleteSubCommand) run(input cli.Input) error {
triggers, err := opts.client.HTTPTriggerList(opts.namespace) triggers, err := opts.client.HTTPTriggerList(opts.namespace)
if err != nil { if err != nil {
return errors.Wrap(err, "error getting HTTP trigger list") return errors.Wrap(err, "error getting HTTP trigger list")
+10 -25
View File
@@ -28,48 +28,33 @@ import (
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1" fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
"github.com/fission/fission/pkg/controller/client" "github.com/fission/fission/pkg/controller/client"
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli" "github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
"github.com/fission/fission/pkg/fission-cli/util" "github.com/fission/fission/pkg/fission-cli/util"
) )
type GetSubCommand struct { type GetSubCommand struct {
client *client.Client client *client.Client
trigger string
namespace string
} }
func Get(flags cli.Input) error { func Get(input cli.Input) error {
c, err := util.GetServer(flags) c, err := util.GetServer(input)
if err != nil { if err != nil {
return err return err
} }
opts := GetSubCommand{ opts := GetSubCommand{
client: c, client: c,
} }
return opts.do(flags) return opts.do(input)
} }
func (opts *GetSubCommand) do(flags cli.Input) error { func (opts *GetSubCommand) do(input cli.Input) error {
err := opts.complete(flags) return opts.run(input)
if err != nil {
return err
}
return opts.run(flags)
} }
func (opts *GetSubCommand) complete(flags cli.Input) error { func (opts *GetSubCommand) run(input cli.Input) error {
opts.trigger = flags.String("name")
opts.namespace = flags.String("fnNamespace")
if len(opts.trigger) <= 0 {
return errors.New("need a trigger name, use --name")
}
return nil
}
func (opts *GetSubCommand) run(flags cli.Input) error {
m := &metav1.ObjectMeta{ m := &metav1.ObjectMeta{
Name: opts.trigger, Name: input.String(flagkey.HtName),
Namespace: opts.namespace, Namespace: input.String(flagkey.NamespaceFunction),
} }
ht, err := opts.client.HTTPTriggerGet(m) ht, err := opts.client.HTTPTriggerGet(m)
if err != nil { if err != nil {
+13 -22
View File
@@ -22,51 +22,42 @@ import (
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1" fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
"github.com/fission/fission/pkg/controller/client" "github.com/fission/fission/pkg/controller/client"
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli" "github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
"github.com/fission/fission/pkg/fission-cli/util" "github.com/fission/fission/pkg/fission-cli/util"
) )
type ListSubCommand struct { type ListSubCommand struct {
client *client.Client client *client.Client
triggerNamespace string
filterFunctionName string
} }
func List(flags cli.Input) error { func List(input cli.Input) error {
c, err := util.GetServer(flags) c, err := util.GetServer(input)
if err != nil { if err != nil {
return err return err
} }
opts := ListSubCommand{ opts := ListSubCommand{
client: c, client: c,
} }
return opts.do(flags) return opts.do(input)
} }
func (opts *ListSubCommand) do(flags cli.Input) error { func (opts *ListSubCommand) do(input cli.Input) error {
err := opts.complete(flags) return opts.run(input)
if err != nil {
return err
}
return opts.run(flags)
} }
func (opts *ListSubCommand) complete(flags cli.Input) error { func (opts *ListSubCommand) run(input cli.Input) error {
opts.triggerNamespace = flags.String("triggerNamespace") hts, err := opts.client.HTTPTriggerList(input.String(flagkey.NamespaceTrigger))
opts.filterFunctionName = flags.String("function")
return nil
}
func (opts *ListSubCommand) run(flags cli.Input) error {
hts, err := opts.client.HTTPTriggerList(opts.triggerNamespace)
if err != nil { if err != nil {
return errors.Wrap(err, "error listing HTTP triggers") return errors.Wrap(err, "error listing HTTP triggers")
} }
filterFunctionName := input.String(flagkey.HtFnName)
var triggers []fv1.HTTPTrigger var triggers []fv1.HTTPTrigger
for _, ht := range hts { for _, ht := range hts {
// TODO: list canary http triggers as well. // TODO: list canary http triggers as well.
if len(opts.filterFunctionName) == 0 || if len(filterFunctionName) == 0 ||
(len(opts.filterFunctionName) > 0 && opts.filterFunctionName == ht.Spec.FunctionReference.Name) { (len(filterFunctionName) > 0 && filterFunctionName == ht.Spec.FunctionReference.Name) {
triggers = append(triggers, ht) triggers = append(triggers, ht)
} }
+2 -1
View File
@@ -24,7 +24,8 @@ import (
) )
// GetIngressConfig returns an IngressConfig based on user inputs; return error if any. // GetIngressConfig returns an IngressConfig based on user inputs; return error if any.
func GetIngressConfig(annotations []string, rule string, tls string, fallbackRelativeURL string, oldIngressConfig *fv1.IngressConfig) (*fv1.IngressConfig, error) { func GetIngressConfig(annotations []string, rule string, tls string,
fallbackRelativeURL string, oldIngressConfig *fv1.IngressConfig) (*fv1.IngressConfig, error) {
removeAnns, anns, err := getIngressAnnotations(annotations) removeAnns, anns, err := getIngressAnnotations(annotations)
if err != nil { if err != nil {
+23 -26
View File
@@ -26,6 +26,7 @@ import (
"github.com/fission/fission/pkg/controller/client" "github.com/fission/fission/pkg/controller/client"
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli" "github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
"github.com/fission/fission/pkg/fission-cli/console" "github.com/fission/fission/pkg/fission-cli/console"
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
"github.com/fission/fission/pkg/fission-cli/util" "github.com/fission/fission/pkg/fission-cli/util"
) )
@@ -34,31 +35,28 @@ type UpdateSubCommand struct {
trigger *fv1.HTTPTrigger trigger *fv1.HTTPTrigger
} }
func Update(flags cli.Input) error { func Update(input cli.Input) error {
c, err := util.GetServer(flags) c, err := util.GetServer(input)
if err != nil { if err != nil {
return err return err
} }
opts := UpdateSubCommand{ opts := UpdateSubCommand{
client: c, client: c,
} }
return opts.do(flags) return opts.do(input)
} }
func (opts *UpdateSubCommand) do(flags cli.Input) error { func (opts *UpdateSubCommand) do(input cli.Input) error {
err := opts.complete(flags) err := opts.complete(input)
if err != nil { if err != nil {
return err return err
} }
return opts.run(flags) return opts.run(input)
} }
func (opts *UpdateSubCommand) complete(flags cli.Input) error { func (opts *UpdateSubCommand) complete(input cli.Input) error {
htName := flags.String("name") htName := input.String(flagkey.HtName)
if len(htName) == 0 { triggerNamespace := input.String(flagkey.NamespaceTrigger)
return errors.New("need name of trigger, use --name")
}
triggerNamespace := flags.String("triggerNamespace")
ht, err := opts.client.HTTPTriggerGet(&metav1.ObjectMeta{ ht, err := opts.client.HTTPTriggerGet(&metav1.ObjectMeta{
Name: htName, Name: htName,
@@ -68,17 +66,17 @@ func (opts *UpdateSubCommand) complete(flags cli.Input) error {
return errors.Wrap(err, "error getting HTTP trigger") return errors.Wrap(err, "error getting HTTP trigger")
} }
if flags.IsSet("function") { if input.IsSet(flagkey.HtFnName) {
// get the functions and their weights if specified // get the functions and their weights if specified
functionList := flags.StringSlice("function") functionList := input.StringSlice(flagkey.HtFnName)
err := util.CheckFunctionExistence(opts.client, functionList, triggerNamespace) err := util.CheckFunctionExistence(opts.client, functionList, triggerNamespace)
if err != nil { if err != nil {
console.Warn(err.Error()) console.Warn(err.Error())
} }
var functionWeightsList []int var functionWeightsList []int
if flags.IsSet("weight") { if input.IsSet(flagkey.HtFnWeight) {
functionWeightsList = flags.IntSlice("weight") functionWeightsList = input.IntSlice(flagkey.HtFnWeight)
} }
// set function reference // set function reference
@@ -90,21 +88,20 @@ func (opts *UpdateSubCommand) complete(flags cli.Input) error {
ht.Spec.FunctionReference = *functionRef ht.Spec.FunctionReference = *functionRef
} }
if flags.IsSet("createingress") { if input.IsSet(flagkey.HtIngress) {
ht.Spec.CreateIngress = flags.Bool("createingress") ht.Spec.CreateIngress = input.Bool(flagkey.HtIngress)
} }
if flags.IsSet("host") { if input.IsSet(flagkey.HtHost) {
ht.Spec.Host = flags.String("host") ht.Spec.Host = input.String(flagkey.HtHost)
console.Warn(fmt.Sprintf("--host is now marked as deprecated, see 'help' for details"))
} }
if flags.IsSet("ingressrule") || flags.IsSet("ingressannotation") || flags.IsSet("ingresstls") { if input.IsSet(flagkey.HtIngressRule) || input.IsSet(flagkey.HtIngressAnnotation) || input.IsSet(flagkey.HtIngressTLS) {
ingress, err := GetIngressConfig( ingress, err := GetIngressConfig(
flags.StringSlice("ingressannotation"), flags.String("ingressrule"), input.StringSlice(flagkey.HtIngressAnnotation), input.String(flagkey.HtIngressRule),
flags.String("ingresstls"), ht.Spec.RelativeURL, &ht.Spec.IngressConfig) input.String(flagkey.HtIngressTLS), ht.Spec.RelativeURL, &ht.Spec.IngressConfig)
if err != nil { if err != nil {
return errors.Wrap(err, "parse ingress configuration") return errors.Wrap(err, "error parsing ingress configuration")
} }
ht.Spec.IngressConfig = *ingress ht.Spec.IngressConfig = *ingress
} }
@@ -114,7 +111,7 @@ func (opts *UpdateSubCommand) complete(flags cli.Input) error {
return nil return nil
} }
func (opts *UpdateSubCommand) run(flags cli.Input) error { func (opts *UpdateSubCommand) run(input cli.Input) error {
_, err := opts.client.HTTPTriggerUpdate(opts.trigger) _, err := opts.client.HTTPTriggerUpdate(opts.trigger)
if err != nil { if err != nil {
return errors.Wrap(err, "error updating the HTTP trigger") return errors.Wrap(err, "error updating the HTTP trigger")
+7 -5
View File
@@ -30,8 +30,10 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(Create), RunE: wrapper.Wrapper(Create),
} }
wrapper.SetFlags(createCmd, flag.FlagSet{ wrapper.SetFlags(createCmd, flag.FlagSet{
Required: []flag.Flag{flag.KwFnNameFlag, flag.KwObjTypeFlag}, Required: []flag.Flag{flag.KwFnName},
Optional: []flag.Flag{flag.NamespaceFunctionFlag, flag.KwLabelsFlag, flag.SpecSaveFlag}, Optional: []flag.Flag{flag.KwName, flag.KwObjType, flag.NamespaceFunction, flag.SpecSave},
// TODO: add label selector flag
// flag.KwLabelsFlag
}) })
deleteCmd := &cobra.Command{ deleteCmd := &cobra.Command{
@@ -41,8 +43,8 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(Delete), RunE: wrapper.Wrapper(Delete),
} }
wrapper.SetFlags(deleteCmd, flag.FlagSet{ wrapper.SetFlags(deleteCmd, flag.FlagSet{
Required: []flag.Flag{flag.KwFnNameFlag}, Required: []flag.Flag{flag.KwFnName},
Optional: []flag.Flag{flag.NamespaceTriggerFlag}, Optional: []flag.Flag{flag.NamespaceTrigger},
}) })
listCmd := &cobra.Command{ listCmd := &cobra.Command{
@@ -52,7 +54,7 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(List), RunE: wrapper.Wrapper(List),
} }
wrapper.SetFlags(listCmd, flag.FlagSet{ wrapper.SetFlags(listCmd, flag.FlagSet{
Optional: []flag.Flag{flag.NamespaceTriggerFlag}, Optional: []flag.Flag{flag.NamespaceTrigger},
}) })
command := &cobra.Command{ command := &cobra.Command{
+20 -38
View File
@@ -27,6 +27,8 @@ import (
"github.com/fission/fission/pkg/controller/client" "github.com/fission/fission/pkg/controller/client"
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli" "github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
"github.com/fission/fission/pkg/fission-cli/cmd/spec" "github.com/fission/fission/pkg/fission-cli/cmd/spec"
"github.com/fission/fission/pkg/fission-cli/console"
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
"github.com/fission/fission/pkg/fission-cli/util" "github.com/fission/fission/pkg/fission-cli/util"
) )
@@ -35,55 +37,35 @@ type CreateSubCommand struct {
watcher *fv1.KubernetesWatchTrigger watcher *fv1.KubernetesWatchTrigger
} }
func Create(flags cli.Input) error { func Create(input cli.Input) error {
c, err := util.GetServer(flags) c, err := util.GetServer(input)
if err != nil { if err != nil {
return err return err
} }
opts := CreateSubCommand{ opts := CreateSubCommand{
client: c, client: c,
} }
return opts.do(flags) return opts.do(input)
} }
func (opts *CreateSubCommand) do(flags cli.Input) error { func (opts *CreateSubCommand) do(input cli.Input) error {
err := opts.complete(flags) err := opts.complete(input)
if err != nil { if err != nil {
return err return err
} }
return opts.run(flags) return opts.run(input)
} }
func (opts *CreateSubCommand) complete(flags cli.Input) error { func (opts *CreateSubCommand) complete(input cli.Input) error {
fnName := flags.String("function") watchName := input.String(flagkey.KwName)
if len(fnName) == 0 { if len(watchName) == 0 {
return errors.New("Need a function name to create a watch, use --function") console.Warn(fmt.Sprintf("--%v will be soon marked as required flag, see 'help' for details", flagkey.MqtName))
watchName = uuid.NewV4().String()
} }
fnNamespace := flags.String("fnNamespace") fnName := input.String(flagkey.KwFnName)
fnNamespace := input.String(flagkey.NamespaceFunction)
namespace := flags.String("ns") namespace := input.String(flagkey.KwNamespace)
if len(namespace) == 0 { objType := input.String(flagkey.KwObjType)
fmt.Println("Watch 'default' namespace. Use --ns <namespace> to override.")
namespace = "default"
}
objType := flags.String("type")
if len(objType) == 0 {
fmt.Println("Object type unspecified, will watch pods. Use --type <type> to override.")
objType = "pod"
}
labels := flags.String("labels")
// empty 'labels' selects everything
if len(labels) == 0 {
fmt.Printf("Watching all objects of type '%v', use --labels to refine selection.\n", objType)
} else {
// TODO
fmt.Printf("Label selector not implemented, watching all objects")
}
// automatically name watches
watchName := uuid.NewV4().String()
opts.watcher = &fv1.KubernetesWatchTrigger{ opts.watcher = &fv1.KubernetesWatchTrigger{
Metadata: metav1.ObjectMeta{ Metadata: metav1.ObjectMeta{
@@ -104,9 +86,9 @@ func (opts *CreateSubCommand) complete(flags cli.Input) error {
return nil return nil
} }
func (opts *CreateSubCommand) run(flags cli.Input) error { func (opts *CreateSubCommand) run(input cli.Input) error {
// if we're writing a spec, don't call the API // if we're writing a spec, don't call the API
if flags.Bool("spec") { if input.Bool(flagkey.SpecSave) {
specFile := fmt.Sprintf("kubewatch-%v.yaml", opts.watcher.Metadata.Name) specFile := fmt.Sprintf("kubewatch-%v.yaml", opts.watcher.Metadata.Name)
err := spec.SpecSave(*opts.watcher, specFile) err := spec.SpecSave(*opts.watcher, specFile)
if err != nil { if err != nil {
@@ -120,6 +102,6 @@ func (opts *CreateSubCommand) run(flags cli.Input) error {
return errors.Wrap(err, "error creating kubewatch") return errors.Wrap(err, "error creating kubewatch")
} }
fmt.Printf("kubewatch '%v' created\n", opts.watcher.Metadata.Name) fmt.Printf("trigger '%v' created\n", opts.watcher.Metadata.Name)
return nil return nil
} }
+12 -14
View File
@@ -24,6 +24,7 @@ import (
"github.com/fission/fission/pkg/controller/client" "github.com/fission/fission/pkg/controller/client"
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli" "github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
"github.com/fission/fission/pkg/fission-cli/util" "github.com/fission/fission/pkg/fission-cli/util"
) )
@@ -33,35 +34,32 @@ type DeleteSubCommand struct {
namespace string namespace string
} }
func Delete(flags cli.Input) error { func Delete(input cli.Input) error {
c, err := util.GetServer(flags) c, err := util.GetServer(input)
if err != nil { if err != nil {
return err return err
} }
opts := DeleteSubCommand{ opts := DeleteSubCommand{
client: c, client: c,
} }
return opts.do(flags) return opts.do(input)
} }
func (opts *DeleteSubCommand) do(flags cli.Input) error { func (opts *DeleteSubCommand) do(input cli.Input) error {
err := opts.complete(flags) err := opts.complete(input)
if err != nil { if err != nil {
return err return err
} }
return opts.run(flags) return opts.run(input)
} }
func (opts *DeleteSubCommand) complete(flags cli.Input) error { func (opts *DeleteSubCommand) complete(input cli.Input) error {
opts.name = flags.String("name") opts.name = input.String(flagkey.KwName)
if len(opts.name) == 0 { opts.namespace = input.String(flagkey.NamespaceTrigger)
return errors.New("need name of watch to delete, use --name")
}
opts.namespace = flags.String("triggerns")
return nil return nil
} }
func (opts *DeleteSubCommand) run(flags cli.Input) error { func (opts *DeleteSubCommand) run(input cli.Input) error {
err := opts.client.WatchDelete(&metav1.ObjectMeta{ err := opts.client.WatchDelete(&metav1.ObjectMeta{
Name: opts.name, Name: opts.name,
Namespace: opts.namespace, Namespace: opts.namespace,
@@ -70,6 +68,6 @@ func (opts *DeleteSubCommand) run(flags cli.Input) error {
return errors.Wrap(err, "error deleting kubewatch") return errors.Wrap(err, "error deleting kubewatch")
} }
fmt.Printf("watch '%v' deleted\n", opts.name) fmt.Printf("trigger '%v' deleted\n", opts.name)
return nil return nil
} }
+10 -9
View File
@@ -25,6 +25,7 @@ import (
"github.com/fission/fission/pkg/controller/client" "github.com/fission/fission/pkg/controller/client"
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli" "github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
"github.com/fission/fission/pkg/fission-cli/util" "github.com/fission/fission/pkg/fission-cli/util"
) )
@@ -33,31 +34,31 @@ type ListSubCommand struct {
namespace string namespace string
} }
func List(flags cli.Input) error { func List(input cli.Input) error {
c, err := util.GetServer(flags) c, err := util.GetServer(input)
if err != nil { if err != nil {
return err return err
} }
opts := ListSubCommand{ opts := ListSubCommand{
client: c, client: c,
} }
return opts.do(flags) return opts.do(input)
} }
func (opts *ListSubCommand) do(flags cli.Input) error { func (opts *ListSubCommand) do(input cli.Input) error {
err := opts.complete(flags) err := opts.complete(input)
if err != nil { if err != nil {
return err return err
} }
return opts.run(flags) return opts.run(input)
} }
func (opts *ListSubCommand) complete(flags cli.Input) error { func (opts *ListSubCommand) complete(input cli.Input) error {
opts.namespace = flags.String("triggerns") opts.namespace = input.String(flagkey.NamespaceTrigger)
return nil return nil
} }
func (opts *ListSubCommand) run(flags cli.Input) error { func (opts *ListSubCommand) run(input cli.Input) error {
ws, err := opts.client.WatchList(opts.namespace) ws, err := opts.client.WatchList(opts.namespace)
if err != nil { if err != nil {
return errors.Wrap(err, "error listing kubewatches") return errors.Wrap(err, "error listing kubewatches")
+10 -10
View File
@@ -30,10 +30,10 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(Create), RunE: wrapper.Wrapper(Create),
} }
wrapper.SetFlags(createCmd, flag.FlagSet{ wrapper.SetFlags(createCmd, flag.FlagSet{
Required: []flag.Flag{flag.MqtFnNameFlag, flag.MqtTopicFlag}, Required: []flag.Flag{flag.MqtFnName, flag.MqtTopic},
Optional: []flag.Flag{flag.MqtNameFlag, flag.NamespaceFunctionFlag, flag.MqtMQTypeFlag, Optional: []flag.Flag{flag.MqtName, flag.NamespaceFunction, flag.MqtMQType,
flag.MqtRespTopicFlag, flag.MqtErrorTopicFlag, flag.MqtMaxRetriesFlag, flag.MqtMsgContentTypeFlag, flag.MqtRespTopic, flag.MqtErrorTopic, flag.MqtMaxRetries, flag.MqtMsgContentType,
flag.SpecSaveFlag}, flag.SpecSave},
}) })
updateCmd := &cobra.Command{ updateCmd := &cobra.Command{
@@ -43,9 +43,9 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(Update), RunE: wrapper.Wrapper(Update),
} }
wrapper.SetFlags(updateCmd, flag.FlagSet{ wrapper.SetFlags(updateCmd, flag.FlagSet{
Required: []flag.Flag{flag.MqtNameFlag}, Required: []flag.Flag{flag.MqtName},
Optional: []flag.Flag{flag.NamespaceTriggerFlag, flag.MqtTopicFlag, flag.MqtRespTopicFlag, Optional: []flag.Flag{flag.NamespaceTrigger, flag.MqtTopic, flag.MqtRespTopic,
flag.MqtErrorTopicFlag, flag.MqtMaxRetriesFlag, flag.MqtFnNameFlag, flag.MqtMsgContentTypeFlag}, flag.MqtErrorTopic, flag.MqtMaxRetries, flag.MqtFnName, flag.MqtMsgContentType},
}) })
deleteCmd := &cobra.Command{ deleteCmd := &cobra.Command{
@@ -55,8 +55,8 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(Delete), RunE: wrapper.Wrapper(Delete),
} }
wrapper.SetFlags(deleteCmd, flag.FlagSet{ wrapper.SetFlags(deleteCmd, flag.FlagSet{
Required: []flag.Flag{flag.MqtNameFlag}, Required: []flag.Flag{flag.MqtName},
Optional: []flag.Flag{flag.NamespaceTriggerFlag}, Optional: []flag.Flag{flag.NamespaceTrigger},
}) })
listCmd := &cobra.Command{ listCmd := &cobra.Command{
@@ -66,7 +66,7 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(List), RunE: wrapper.Wrapper(List),
} }
wrapper.SetFlags(listCmd, flag.FlagSet{ wrapper.SetFlags(listCmd, flag.FlagSet{
Optional: []flag.Flag{flag.NamespaceTriggerFlag}, Optional: []flag.Flag{flag.NamespaceTrigger},
}) })
command := &cobra.Command{ command := &cobra.Command{
+26 -28
View File
@@ -27,6 +27,8 @@ import (
"github.com/fission/fission/pkg/controller/client" "github.com/fission/fission/pkg/controller/client"
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli" "github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
"github.com/fission/fission/pkg/fission-cli/cmd/spec" "github.com/fission/fission/pkg/fission-cli/cmd/spec"
"github.com/fission/fission/pkg/fission-cli/console"
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
"github.com/fission/fission/pkg/fission-cli/util" "github.com/fission/fission/pkg/fission-cli/util"
"github.com/fission/fission/pkg/types" "github.com/fission/fission/pkg/types"
) )
@@ -36,38 +38,36 @@ type CreateSubCommand struct {
trigger *fv1.MessageQueueTrigger trigger *fv1.MessageQueueTrigger
} }
func Create(flags cli.Input) error { func Create(input cli.Input) error {
c, err := util.GetServer(flags) c, err := util.GetServer(input)
if err != nil { if err != nil {
return err return err
} }
opts := CreateSubCommand{ opts := CreateSubCommand{
client: c, client: c,
} }
return opts.do(flags) return opts.do(input)
} }
func (opts *CreateSubCommand) do(flags cli.Input) error { func (opts *CreateSubCommand) do(input cli.Input) error {
err := opts.complete(flags) err := opts.complete(input)
if err != nil { if err != nil {
return err return err
} }
return opts.run(flags) return opts.run(input)
} }
func (opts *CreateSubCommand) complete(flags cli.Input) error { func (opts *CreateSubCommand) complete(input cli.Input) error {
mqtName := flags.String("name") mqtName := input.String(flagkey.MqtName)
if len(mqtName) == 0 { if len(mqtName) == 0 {
console.Warn(fmt.Sprintf("--%v will be soon marked as required flag, see 'help' for details", flagkey.MqtName))
mqtName = uuid.NewV4().String() mqtName = uuid.NewV4().String()
} }
fnName := flags.String("function") fnName := input.String(flagkey.MqtFnName)
if len(fnName) == 0 { fnNamespace := input.String(flagkey.NamespaceFunction)
return errors.New("Need a function name to create a trigger, use --function")
}
fnNamespace := flags.String("fnNamespace")
var mqType fv1.MessageQueueType var mqType fv1.MessageQueueType
switch flags.String("mqtype") { switch input.String(flagkey.MqtMQType) {
case "": case "":
mqType = types.MessageQueueTypeNats mqType = types.MessageQueueTypeNats
case types.MessageQueueTypeNats: case types.MessageQueueTypeNats:
@@ -80,28 +80,26 @@ func (opts *CreateSubCommand) complete(flags cli.Input) error {
return errors.New("Unknown message queue type, currently only \"nats-streaming, azure-storage-queue, kafka \" is supported") return errors.New("Unknown message queue type, currently only \"nats-streaming, azure-storage-queue, kafka \" is supported")
} }
// TODO: check topic availability topic := input.String(flagkey.MqtTopic)
topic := flags.String("topic")
if len(topic) == 0 { if len(topic) == 0 {
return errors.New("Topic cannot be empty") return errors.New("topic cannot be empty")
} }
respTopic := flags.String("resptopic")
respTopic := input.String(flagkey.MqtRespTopic)
if topic == respTopic { if topic == respTopic {
// TODO maybe this should just be a warning, perhaps // TODO maybe this should just be a warning, perhaps
// allow it behind a --force flag // allow it behind a --force flag
return errors.New("Listen topic should not equal to response topic") return errors.New("listen topic should not equal to response topic")
} }
errorTopic := flags.String("errortopic") errorTopic := input.String(flagkey.MqtErrorTopic)
maxRetries := input.Int(flagkey.MqtMaxRetries)
maxRetries := flags.Int("maxretries")
if maxRetries < 0 { if maxRetries < 0 {
return errors.New("Maximum number of retries must be a natural number, default is 0") return errors.New("Maximum number of retries must be greater than or equal to 0")
} }
contentType := flags.String("contenttype") contentType := input.String(flagkey.MqtMsgContentType)
if len(contentType) == 0 { if len(contentType) == 0 {
contentType = "application/json" contentType = "application/json"
} }
@@ -133,9 +131,9 @@ func (opts *CreateSubCommand) complete(flags cli.Input) error {
return nil return nil
} }
func (opts *CreateSubCommand) run(flags cli.Input) error { func (opts *CreateSubCommand) run(input cli.Input) error {
// if we're writing a spec, don't call the API // if we're writing a spec, don't call the API
if flags.Bool("spec") { if input.Bool(flagkey.SpecSave) {
specFile := fmt.Sprintf("mqtrigger-%v.yaml", opts.trigger.Metadata.Name) specFile := fmt.Sprintf("mqtrigger-%v.yaml", opts.trigger.Metadata.Name)
err := spec.SpecSave(*opts.trigger, specFile) err := spec.SpecSave(*opts.trigger, specFile)
if err != nil { if err != nil {
@@ -149,14 +147,14 @@ func (opts *CreateSubCommand) run(flags cli.Input) error {
return errors.Wrap(err, "create message queue trigger") return errors.Wrap(err, "create message queue trigger")
} }
fmt.Printf("message queue trigger '%s' created\n", opts.trigger.Metadata.Name) fmt.Printf("trigger '%s' created\n", opts.trigger.Metadata.Name)
return nil return nil
} }
func checkMQTopicAvailability(mqType fv1.MessageQueueType, topics ...string) error { func checkMQTopicAvailability(mqType fv1.MessageQueueType, topics ...string) error {
for _, t := range topics { for _, t := range topics {
if len(t) > 0 && !fv1.IsTopicValid(mqType, t) { if len(t) > 0 && !fv1.IsTopicValid(mqType, t) {
return errors.Errorf("Invalid topic for %s: %s", mqType, t) return errors.Errorf("invalid topic for %s: %s", mqType, t)
} }
} }
return nil return nil
+14 -14
View File
@@ -24,6 +24,7 @@ import (
"github.com/fission/fission/pkg/controller/client" "github.com/fission/fission/pkg/controller/client"
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli" "github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
"github.com/fission/fission/pkg/fission-cli/util" "github.com/fission/fission/pkg/fission-cli/util"
) )
@@ -32,40 +33,39 @@ type DeleteSubCommand struct {
metadata *metav1.ObjectMeta metadata *metav1.ObjectMeta
} }
func Delete(flags cli.Input) error { func Delete(input cli.Input) error {
c, err := util.GetServer(flags) c, err := util.GetServer(input)
if err != nil { if err != nil {
return err return err
} }
opts := DeleteSubCommand{ opts := DeleteSubCommand{
client: c, client: c,
} }
return opts.do(flags) return opts.do(input)
} }
func (opts *DeleteSubCommand) do(flags cli.Input) error { func (opts *DeleteSubCommand) do(input cli.Input) error {
err := opts.complete(flags) err := opts.complete(input)
if err != nil { if err != nil {
return err return err
} }
return opts.run(flags) return opts.run(input)
} }
func (opts *DeleteSubCommand) complete(flags cli.Input) error { func (opts *DeleteSubCommand) complete(input cli.Input) error {
m, err := util.GetMetadata("name", "triggerns", flags) opts.metadata = &metav1.ObjectMeta{
if err != nil { Name: input.String(flagkey.MqtName),
return err Namespace: input.String(flagkey.NamespaceTrigger),
} }
opts.metadata = m
return nil return nil
} }
func (opts *DeleteSubCommand) run(flags cli.Input) error { func (opts *DeleteSubCommand) run(input cli.Input) error {
err := opts.client.WatchDelete(opts.metadata) err := opts.client.MessageQueueTriggerDelete(opts.metadata)
if err != nil { if err != nil {
return errors.Wrap(err, "error deleting message queue trigger") return errors.Wrap(err, "error deleting message queue trigger")
} }
fmt.Printf("message queue trigger '%v' deleted\n", opts.metadata.Name) fmt.Printf("trigger '%v' deleted\n", opts.metadata.Name)
return nil return nil
} }
+11 -10
View File
@@ -25,6 +25,7 @@ import (
"github.com/fission/fission/pkg/controller/client" "github.com/fission/fission/pkg/controller/client"
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli" "github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
"github.com/fission/fission/pkg/fission-cli/util" "github.com/fission/fission/pkg/fission-cli/util"
) )
@@ -33,32 +34,32 @@ type ListSubCommand struct {
namespace string namespace string
} }
func List(flags cli.Input) error { func List(input cli.Input) error {
c, err := util.GetServer(flags) c, err := util.GetServer(input)
if err != nil { if err != nil {
return err return err
} }
opts := ListSubCommand{ opts := ListSubCommand{
client: c, client: c,
} }
return opts.do(flags) return opts.do(input)
} }
func (opts *ListSubCommand) do(flags cli.Input) error { func (opts *ListSubCommand) do(input cli.Input) error {
err := opts.complete(flags) err := opts.complete(input)
if err != nil { if err != nil {
return err return err
} }
return opts.run(flags) return opts.run(input)
} }
func (opts *ListSubCommand) complete(flags cli.Input) error { func (opts *ListSubCommand) complete(input cli.Input) error {
opts.namespace = flags.String("triggerns") opts.namespace = input.String(flagkey.NamespaceTrigger)
return nil return nil
} }
func (opts *ListSubCommand) run(flags cli.Input) error { func (opts *ListSubCommand) run(input cli.Input) error {
mqts, err := opts.client.MessageQueueTriggerList(flags.String("mqtype"), opts.namespace) mqts, err := opts.client.MessageQueueTriggerList(input.String(flagkey.MqtMQType), opts.namespace)
if err != nil { if err != nil {
return errors.Wrap(err, "error listing message queue triggers") return errors.Wrap(err, "error listing message queue triggers")
} }
+21 -21
View File
@@ -20,10 +20,12 @@ import (
"fmt" "fmt"
"github.com/pkg/errors" "github.com/pkg/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1" fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
"github.com/fission/fission/pkg/controller/client" "github.com/fission/fission/pkg/controller/client"
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli" "github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
"github.com/fission/fission/pkg/fission-cli/util" "github.com/fission/fission/pkg/fission-cli/util"
) )
@@ -32,42 +34,40 @@ type UpdateSubCommand struct {
trigger *fv1.MessageQueueTrigger trigger *fv1.MessageQueueTrigger
} }
func Update(flags cli.Input) error { func Update(input cli.Input) error {
c, err := util.GetServer(flags) c, err := util.GetServer(input)
if err != nil { if err != nil {
return err return err
} }
opts := UpdateSubCommand{ opts := UpdateSubCommand{
client: c, client: c,
} }
return opts.do(flags) return opts.do(input)
} }
func (opts *UpdateSubCommand) do(flags cli.Input) error { func (opts *UpdateSubCommand) do(input cli.Input) error {
err := opts.complete(flags) err := opts.complete(input)
if err != nil { if err != nil {
return err return err
} }
return opts.run(flags) return opts.run(input)
} }
func (opts *UpdateSubCommand) complete(flags cli.Input) error { func (opts *UpdateSubCommand) complete(input cli.Input) error {
m, err := util.GetMetadata("name", "triggerns", flags) mqt, err := opts.client.MessageQueueTriggerGet(&metav1.ObjectMeta{
if err != nil { Name: input.String(flagkey.MqtName),
return err Namespace: input.String(flagkey.NamespaceTrigger),
} })
mqt, err := opts.client.MessageQueueTriggerGet(m)
if err != nil { if err != nil {
return errors.Wrap(err, "error getting message queue trigger") return errors.Wrap(err, "error getting message queue trigger")
} }
topic := flags.String("topic") topic := input.String(flagkey.MqtTopic)
respTopic := flags.String("resptopic") respTopic := input.String(flagkey.MqtRespTopic)
errorTopic := flags.String("errortopic") errorTopic := input.String(flagkey.MqtErrorTopic)
maxRetries := flags.Int("maxretries") maxRetries := input.Int(flagkey.MqtMaxRetries)
fnName := flags.String("function") fnName := input.String(flagkey.MqtFnName)
contentType := flags.String("contenttype") contentType := input.String(flagkey.MqtMsgContentType)
// TODO : Find out if we can make a call to checkIfFunctionExists, in the same ns more importantly. // TODO : Find out if we can make a call to checkIfFunctionExists, in the same ns more importantly.
@@ -103,14 +103,14 @@ func (opts *UpdateSubCommand) complete(flags cli.Input) error {
} }
if !updated { if !updated {
return errors.New("Nothing to update. Use --topic, --resptopic, --errortopic, --maxretries or --function.") return errors.New("Nothing changed, see 'help' for more details")
} }
opts.trigger = mqt opts.trigger = mqt
return nil return nil
} }
func (opts *UpdateSubCommand) run(flags cli.Input) error { func (opts *UpdateSubCommand) run(input cli.Input) error {
_, err := opts.client.MessageQueueTriggerUpdate(opts.trigger) _, err := opts.client.MessageQueueTriggerUpdate(opts.trigger)
if err != nil { if err != nil {
return errors.Wrap(err, "error updating message queue trigger") return errors.Wrap(err, "error updating message queue trigger")
+17 -16
View File
@@ -30,9 +30,9 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(Create), RunE: wrapper.Wrapper(Create),
} }
wrapper.SetFlags(createCmd, flag.FlagSet{ wrapper.SetFlags(createCmd, flag.FlagSet{
Required: []flag.Flag{flag.PkgEnvironmentFlag}, Required: []flag.Flag{flag.PkgEnvironment},
Optional: []flag.Flag{flag.NamespacePackageFlag, flag.NamespaceEnvironmentFlag, Optional: []flag.Flag{flag.PkgName, flag.NamespacePackage, flag.NamespaceEnvironment,
flag.PkgSrcArchiveFlag, flag.PkgDeployArchiveFlag, flag.PkgKeepURLFlag, flag.PkgBuildCmdFlag}, flag.PkgSrcArchive, flag.PkgDeployArchive, flag.PkgKeepURL, flag.PkgBuildCmd},
}) })
getSrcCmd := &cobra.Command{ getSrcCmd := &cobra.Command{
@@ -41,8 +41,8 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(GetSrc), RunE: wrapper.Wrapper(GetSrc),
} }
wrapper.SetFlags(getSrcCmd, flag.FlagSet{ wrapper.SetFlags(getSrcCmd, flag.FlagSet{
Required: []flag.Flag{flag.PkgNameFlag}, Required: []flag.Flag{flag.PkgName},
Optional: []flag.Flag{flag.NamespacePackageFlag, flag.PkgOutputFlag}, Optional: []flag.Flag{flag.NamespacePackage, flag.PkgOutput},
}) })
getDeployCmd := &cobra.Command{ getDeployCmd := &cobra.Command{
@@ -51,8 +51,8 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(GetDeploy), RunE: wrapper.Wrapper(GetDeploy),
} }
wrapper.SetFlags(getDeployCmd, flag.FlagSet{ wrapper.SetFlags(getDeployCmd, flag.FlagSet{
Required: []flag.Flag{flag.PkgNameFlag}, Required: []flag.Flag{flag.PkgName},
Optional: []flag.Flag{flag.NamespacePackageFlag, flag.PkgOutputFlag}, Optional: []flag.Flag{flag.NamespacePackage, flag.PkgOutput},
}) })
updateCmd := &cobra.Command{ updateCmd := &cobra.Command{
@@ -61,10 +61,10 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(Update), RunE: wrapper.Wrapper(Update),
} }
wrapper.SetFlags(updateCmd, flag.FlagSet{ wrapper.SetFlags(updateCmd, flag.FlagSet{
Required: []flag.Flag{flag.PkgNameFlag}, Required: []flag.Flag{flag.PkgName},
Optional: []flag.Flag{flag.NamespacePackageFlag, flag.PkgEnvironmentFlag, flag.NamespaceEnvironmentFlag, Optional: []flag.Flag{flag.NamespacePackage, flag.PkgEnvironment, flag.NamespaceEnvironment,
flag.PkgSrcArchiveFlag, flag.PkgDeployArchiveFlag, flag.PkgKeepURLFlag, flag.PkgSrcArchive, flag.PkgDeployArchive, flag.PkgKeepURL,
flag.PkgBuildCmdFlag, flag.PkgForceFlag}, flag.PkgBuildCmd, flag.PkgForce},
}) })
deleteCmd := &cobra.Command{ deleteCmd := &cobra.Command{
@@ -73,8 +73,7 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(Delete), RunE: wrapper.Wrapper(Delete),
} }
wrapper.SetFlags(deleteCmd, flag.FlagSet{ wrapper.SetFlags(deleteCmd, flag.FlagSet{
Required: []flag.Flag{flag.PkgNameFlag}, Optional: []flag.Flag{flag.PkgName, flag.NamespacePackage, flag.PkgForce, flag.PkgOrphan},
Optional: []flag.Flag{flag.NamespacePackageFlag, flag.PkgForceFlag, flag.PkgOrphanFlag},
}) })
listCmd := &cobra.Command{ listCmd := &cobra.Command{
@@ -83,7 +82,7 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(List), RunE: wrapper.Wrapper(List),
} }
wrapper.SetFlags(listCmd, flag.FlagSet{ wrapper.SetFlags(listCmd, flag.FlagSet{
Optional: []flag.Flag{flag.PkgOrphanFlag, flag.PkgStatusFlag, flag.NamespacePackageFlag}, Optional: []flag.Flag{flag.PkgOrphan, flag.PkgStatus, flag.NamespacePackage},
}) })
infoCmd := &cobra.Command{ infoCmd := &cobra.Command{
@@ -92,7 +91,8 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(List), RunE: wrapper.Wrapper(List),
} }
wrapper.SetFlags(infoCmd, flag.FlagSet{ wrapper.SetFlags(infoCmd, flag.FlagSet{
Optional: []flag.Flag{flag.PkgNameFlag, flag.NamespacePackageFlag}, Required: []flag.Flag{flag.PkgName},
Optional: []flag.Flag{flag.NamespacePackage},
}) })
rebuildCmd := &cobra.Command{ rebuildCmd := &cobra.Command{
@@ -101,7 +101,8 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(List), RunE: wrapper.Wrapper(List),
} }
wrapper.SetFlags(rebuildCmd, flag.FlagSet{ wrapper.SetFlags(rebuildCmd, flag.FlagSet{
Optional: []flag.Flag{flag.PkgNameFlag, flag.NamespacePackageFlag}, Required: []flag.Flag{flag.PkgName},
Optional: []flag.Flag{flag.NamespacePackage},
}) })
command := &cobra.Command{ command := &cobra.Command{
+28 -23
View File
@@ -31,6 +31,8 @@ import (
"github.com/fission/fission/pkg/controller/client" "github.com/fission/fission/pkg/controller/client"
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli" "github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
"github.com/fission/fission/pkg/fission-cli/cmd/spec" "github.com/fission/fission/pkg/fission-cli/cmd/spec"
"github.com/fission/fission/pkg/fission-cli/console"
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
"github.com/fission/fission/pkg/fission-cli/util" "github.com/fission/fission/pkg/fission-cli/util"
) )
@@ -38,49 +40,49 @@ type CreateSubCommand struct {
client *client.Client client *client.Client
} }
func Create(flags cli.Input) error { func Create(input cli.Input) error {
c, err := util.GetServer(flags) c, err := util.GetServer(input)
if err != nil { if err != nil {
return err return err
} }
opts := CreateSubCommand{ opts := CreateSubCommand{
client: c, client: c,
} }
return opts.do(flags) return opts.do(input)
} }
func (opts *CreateSubCommand) do(flags cli.Input) error { func (opts *CreateSubCommand) do(input cli.Input) error {
err := opts.complete(flags) err := opts.run(input)
if err != nil { if err != nil {
return err return err
} }
//return opts.run(flags)
return nil return nil
} }
func (opts *CreateSubCommand) complete(flags cli.Input) error { func (opts *CreateSubCommand) run(input cli.Input) error {
pkgNamespace := flags.String("pkgNamespace") pkgName := input.String(flagkey.PkgName)
envName := flags.String("env") if len(pkgName) == 0 {
if len(envName) == 0 { console.Warn(fmt.Sprintf("--%v will be soon marked as required flag, see 'help' for details", flagkey.HtName))
return errors.New("Need --env argument.")
} }
envNamespace := flags.String("envNamespace") pkgNamespace := input.String(flagkey.NamespacePackage)
srcArchiveFiles := flags.StringSlice("src") envName := input.String(flagkey.PkgEnvironment)
deployArchiveFiles := flags.StringSlice("deploy") envNamespace := input.String(flagkey.NamespaceEnvironment)
buildcmd := flags.String("buildcmd") srcArchiveFiles := input.StringSlice(flagkey.PkgSrcArchive)
keepURL := flags.Bool("keepurl") deployArchiveFiles := input.StringSlice(flagkey.PkgDeployArchive)
buildcmd := input.String(flagkey.PkgBuildCmd)
keepURL := input.Bool(flagkey.PkgKeepURL)
if len(srcArchiveFiles) == 0 && len(deployArchiveFiles) == 0 { if len(srcArchiveFiles) == 0 && len(deployArchiveFiles) == 0 {
return errors.New("Need --src to specify source archive, or use --deploy to specify deployment archive.") return errors.Errorf("need --%v or --%v flag", flagkey.PkgSrcArchive, flagkey.PkgDeployArchive)
} }
_, err := CreatePackage(flags, opts.client, pkgNamespace, envName, envNamespace, _, err := CreatePackage(input, opts.client, pkgName, pkgNamespace, envName, envNamespace,
srcArchiveFiles, deployArchiveFiles, buildcmd, "", "", false, keepURL) srcArchiveFiles, deployArchiveFiles, buildcmd, "", "", false, keepURL)
return err return err
} }
func CreatePackage(flags cli.Input, client *client.Client, pkgNamespace string, envName string, envNamespace string, func CreatePackage(input cli.Input, client *client.Client, pkgName string, pkgNamespace string, envName string, envNamespace string,
srcArchiveFiles []string, deployArchiveFiles []string, buildcmd string, specDir string, specFile string, noZip bool, keepURL bool) (*metav1.ObjectMeta, error) { srcArchiveFiles []string, deployArchiveFiles []string, buildcmd string, specDir string, specFile string, noZip bool, keepURL bool) (*metav1.ObjectMeta, error) {
pkgSpec := fv1.PackageSpec{ pkgSpec := fv1.PackageSpec{
@@ -91,7 +93,6 @@ func CreatePackage(flags cli.Input, client *client.Client, pkgNamespace string,
} }
var pkgStatus fv1.BuildStatus = fv1.BuildStatusSucceeded var pkgStatus fv1.BuildStatus = fv1.BuildStatusSucceeded
var pkgName string
if len(deployArchiveFiles) > 0 { if len(deployArchiveFiles) > 0 {
if len(specFile) > 0 { // we should do this in all cases, i think if len(specFile) > 0 { // we should do this in all cases, i think
pkgStatus = fv1.BuildStatusNone pkgStatus = fv1.BuildStatusNone
@@ -101,7 +102,9 @@ func CreatePackage(flags cli.Input, client *client.Client, pkgNamespace string,
return nil, err return nil, err
} }
pkgSpec.Deployment = *deployment pkgSpec.Deployment = *deployment
pkgName = util.KubifyName(fmt.Sprintf("%v-%v", path.Base(deployArchiveFiles[0]), uniuri.NewLen(4))) if len(pkgName) == 0 {
pkgName = util.KubifyName(fmt.Sprintf("%v-%v", path.Base(deployArchiveFiles[0]), uniuri.NewLen(4)))
}
} }
if len(srcArchiveFiles) > 0 { if len(srcArchiveFiles) > 0 {
source, err := CreateArchive(client, srcArchiveFiles, false, keepURL, specDir, specFile) source, err := CreateArchive(client, srcArchiveFiles, false, keepURL, specDir, specFile)
@@ -110,7 +113,9 @@ func CreatePackage(flags cli.Input, client *client.Client, pkgNamespace string,
} }
pkgSpec.Source = *source pkgSpec.Source = *source
pkgStatus = fv1.BuildStatusPending // set package build status to pending pkgStatus = fv1.BuildStatusPending // set package build status to pending
pkgName = util.KubifyName(fmt.Sprintf("%v-%v", path.Base(srcArchiveFiles[0]), uniuri.NewLen(4))) if len(pkgName) == 0 {
pkgName = util.KubifyName(fmt.Sprintf("%v-%v", path.Base(srcArchiveFiles[0]), uniuri.NewLen(4)))
}
} }
if len(buildcmd) > 0 { if len(buildcmd) > 0 {
@@ -134,7 +139,7 @@ func CreatePackage(flags cli.Input, client *client.Client, pkgNamespace string,
if len(specFile) > 0 { if len(specFile) > 0 {
// if a package sith the same spec exists, don't create a new spec file // if a package sith the same spec exists, don't create a new spec file
fr, err := spec.ReadSpecs(util.GetSpecDir(flags)) fr, err := spec.ReadSpecs(util.GetSpecDir(input))
if err != nil { if err != nil {
return nil, errors.Wrap(err, "error reading specs") return nil, errors.Wrap(err, "error reading specs")
} }
+18 -17
View File
@@ -24,6 +24,7 @@ import (
"github.com/fission/fission/pkg/controller/client" "github.com/fission/fission/pkg/controller/client"
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli" "github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
"github.com/fission/fission/pkg/fission-cli/util" "github.com/fission/fission/pkg/fission-cli/util"
) )
@@ -35,42 +36,39 @@ type DeleteSubCommand struct {
force bool force bool
} }
func Delete(flags cli.Input) error { func Delete(input cli.Input) error {
c, err := util.GetServer(flags) c, err := util.GetServer(input)
if err != nil { if err != nil {
return err return err
} }
opts := DeleteSubCommand{ opts := DeleteSubCommand{
client: c, client: c,
} }
return opts.do(flags) return opts.do(input)
} }
func (opts *DeleteSubCommand) do(flags cli.Input) error { func (opts *DeleteSubCommand) do(input cli.Input) error {
err := opts.complete(flags) err := opts.complete(input)
if err != nil { if err != nil {
return err return err
} }
return opts.run(flags) return opts.run(input)
} }
func (opts *DeleteSubCommand) complete(flags cli.Input) error { func (opts *DeleteSubCommand) complete(input cli.Input) error {
opts.name = flags.String("name") opts.name = input.String(flagkey.PkgName)
opts.namespace = flags.String("pkgNamespace") opts.namespace = input.String(flagkey.NamespacePackage)
opts.deleteOrphans = flags.Bool("orphan") opts.deleteOrphans = input.Bool(flagkey.PkgOrphan)
opts.force = flags.Bool("f") opts.force = input.Bool(flagkey.PkgForce)
if len(opts.name) == 0 && !opts.deleteOrphans { if len(opts.name) == 0 && !opts.deleteOrphans {
return errors.New("need --name argument or --orphan flag") return errors.Errorf("need --%v or --%v flag", flagkey.PkgName, flagkey.PkgOrphan)
}
if len(opts.name) != 0 && opts.deleteOrphans {
return errors.New("need either --name argument or --orphan flag")
} }
return nil return nil
} }
func (opts *DeleteSubCommand) run(flags cli.Input) error { func (opts *DeleteSubCommand) run(input cli.Input) error {
if len(opts.name) != 0 { if len(opts.name) != 0 {
_, err := opts.client.PackageGet(&metav1.ObjectMeta{ _, err := opts.client.PackageGet(&metav1.ObjectMeta{
Namespace: opts.namespace, Namespace: opts.namespace,
@@ -93,7 +91,10 @@ func (opts *DeleteSubCommand) run(flags cli.Input) error {
return err return err
} }
fmt.Printf("Package '%v' deleted\n", opts.name) fmt.Printf("Package '%v' deleted\n", opts.name)
} else { }
// TODO improve list speed when --orphan
if opts.deleteOrphans {
err := deleteOrphanPkgs(opts.client, opts.namespace) err := deleteOrphanPkgs(opts.client, opts.namespace)
if err != nil { if err != nil {
return errors.Wrap(err, "deleting orphan packages") return errors.Wrap(err, "deleting orphan packages")
+15 -18
View File
@@ -18,7 +18,6 @@ package _package
import ( import (
"bytes" "bytes"
"errors"
"io" "io"
"os" "os"
@@ -28,6 +27,7 @@ import (
"github.com/fission/fission/pkg/controller/client" "github.com/fission/fission/pkg/controller/client"
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli" "github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
pkgutil "github.com/fission/fission/pkg/fission-cli/cmd/package/util" pkgutil "github.com/fission/fission/pkg/fission-cli/cmd/package/util"
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
"github.com/fission/fission/pkg/fission-cli/util" "github.com/fission/fission/pkg/fission-cli/util"
) )
@@ -44,8 +44,8 @@ type GetSubCommand struct {
archiveType int archiveType int
} }
func GetSrc(flags cli.Input) error { func GetSrc(input cli.Input) error {
c, err := util.GetServer(flags) c, err := util.GetServer(input)
if err != nil { if err != nil {
return err return err
} }
@@ -53,11 +53,11 @@ func GetSrc(flags cli.Input) error {
client: c, client: c,
archiveType: sourceArchive, archiveType: sourceArchive,
} }
return opts.do(flags) return opts.do(input)
} }
func GetDeploy(flags cli.Input) error { func GetDeploy(input cli.Input) error {
c, err := util.GetServer(flags) c, err := util.GetServer(input)
if err != nil { if err != nil {
return err return err
} }
@@ -65,28 +65,25 @@ func GetDeploy(flags cli.Input) error {
client: c, client: c,
archiveType: deployArchive, archiveType: deployArchive,
} }
return opts.do(flags) return opts.do(input)
} }
func (opts *GetSubCommand) do(flags cli.Input) error { func (opts *GetSubCommand) do(input cli.Input) error {
err := opts.complete(flags) err := opts.complete(input)
if err != nil { if err != nil {
return err return err
} }
return opts.run(flags) return opts.run(input)
} }
func (opts *GetSubCommand) complete(flags cli.Input) error { func (opts *GetSubCommand) complete(input cli.Input) error {
opts.name = flags.String("name") opts.name = input.String(flagkey.PkgName)
if len(opts.name) == 0 { opts.namespace = input.String(flagkey.NamespacePackage)
return errors.New("need name of package, use --name") opts.output = input.String(flagkey.PkgOutput)
}
opts.namespace = flags.String("pkgNamespace")
opts.output = flags.String("output")
return nil return nil
} }
func (opts *GetSubCommand) run(flags cli.Input) error { func (opts *GetSubCommand) run(input cli.Input) error {
pkg, err := opts.client.PackageGet(&metav1.ObjectMeta{ pkg, err := opts.client.PackageGet(&metav1.ObjectMeta{
Namespace: opts.namespace, Namespace: opts.namespace,
Name: opts.name, Name: opts.name,
+11 -13
View File
@@ -26,6 +26,7 @@ import (
"github.com/fission/fission/pkg/controller/client" "github.com/fission/fission/pkg/controller/client"
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli" "github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
"github.com/fission/fission/pkg/fission-cli/util" "github.com/fission/fission/pkg/fission-cli/util"
) )
@@ -35,35 +36,32 @@ type InfoSubCommand struct {
namespace string namespace string
} }
func Info(flags cli.Input) error { func Info(input cli.Input) error {
c, err := util.GetServer(flags) c, err := util.GetServer(input)
if err != nil { if err != nil {
return err return err
} }
opts := InfoSubCommand{ opts := InfoSubCommand{
client: c, client: c,
} }
return opts.do(flags) return opts.do(input)
} }
func (opts *InfoSubCommand) do(flags cli.Input) error { func (opts *InfoSubCommand) do(input cli.Input) error {
err := opts.complete(flags) err := opts.complete(input)
if err != nil { if err != nil {
return err return err
} }
return opts.run(flags) return opts.run(input)
} }
func (opts *InfoSubCommand) complete(flags cli.Input) error { func (opts *InfoSubCommand) complete(input cli.Input) error {
opts.name = flags.String("name") opts.name = input.String(flagkey.PkgName)
if len(opts.name) == 0 { opts.namespace = input.String("pkgNamespace")
return errors.New("Need name of package, use --name")
}
opts.namespace = flags.String("pkgNamespace")
return nil return nil
} }
func (opts *InfoSubCommand) run(flags cli.Input) error { func (opts *InfoSubCommand) run(input cli.Input) error {
pkg, err := opts.client.PackageGet(&metav1.ObjectMeta{ pkg, err := opts.client.PackageGet(&metav1.ObjectMeta{
Namespace: opts.namespace, Namespace: opts.namespace,
Name: opts.name, Name: opts.name,
+13 -11
View File
@@ -27,6 +27,7 @@ import (
"github.com/fission/fission/pkg/controller/client" "github.com/fission/fission/pkg/controller/client"
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli" "github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
"github.com/fission/fission/pkg/fission-cli/util" "github.com/fission/fission/pkg/fission-cli/util"
) )
@@ -37,34 +38,34 @@ type ListSubCommand struct {
pkgNamespace string pkgNamespace string
} }
func List(flags cli.Input) error { func List(input cli.Input) error {
c, err := util.GetServer(flags) c, err := util.GetServer(input)
if err != nil { if err != nil {
return err return err
} }
opts := ListSubCommand{ opts := ListSubCommand{
client: c, client: c,
} }
return opts.do(flags) return opts.do(input)
} }
func (opts *ListSubCommand) do(flags cli.Input) error { func (opts *ListSubCommand) do(input cli.Input) error {
err := opts.complete(flags) err := opts.complete(input)
if err != nil { if err != nil {
return err return err
} }
return opts.run(flags) return opts.run(input)
} }
func (opts *ListSubCommand) complete(flags cli.Input) error { func (opts *ListSubCommand) complete(input cli.Input) error {
// option for the user to list all orphan packages (not referenced by any function) // option for the user to list all orphan packages (not referenced by any function)
opts.listOrphans = flags.Bool("orphan") opts.listOrphans = input.Bool(flagkey.PkgOrphan)
opts.status = flags.String("status") opts.status = input.String(flagkey.PkgStatus)
opts.pkgNamespace = flags.String("pkgNamespace") opts.pkgNamespace = input.String(flagkey.NamespacePackage)
return nil return nil
} }
func (opts *ListSubCommand) run(flags cli.Input) error { func (opts *ListSubCommand) run(input cli.Input) error {
pkgList, err := opts.client.PackageList(opts.pkgNamespace) pkgList, err := opts.client.PackageList(opts.pkgNamespace)
if err != nil { if err != nil {
return err return err
@@ -80,6 +81,7 @@ func (opts *ListSubCommand) run(flags cli.Input) error {
for _, pkg := range pkgList { for _, pkg := range pkgList {
show := true show := true
// TODO improve list speed when --orphan
if opts.listOrphans { if opts.listOrphans {
fnList, err := GetFunctionsByPackage(opts.client, pkg.Metadata.Name, pkg.Metadata.Namespace) fnList, err := GetFunctionsByPackage(opts.client, pkg.Metadata.Name, pkg.Metadata.Namespace)
if err != nil { if err != nil {
+11 -13
View File
@@ -25,6 +25,7 @@ import (
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1" fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
"github.com/fission/fission/pkg/controller/client" "github.com/fission/fission/pkg/controller/client"
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli" "github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
"github.com/fission/fission/pkg/fission-cli/util" "github.com/fission/fission/pkg/fission-cli/util"
) )
@@ -34,35 +35,32 @@ type RebuildSubCommand struct {
namespace string namespace string
} }
func Rebuild(flags cli.Input) error { func Rebuild(input cli.Input) error {
c, err := util.GetServer(flags) c, err := util.GetServer(input)
if err != nil { if err != nil {
return err return err
} }
opts := RebuildSubCommand{ opts := RebuildSubCommand{
client: c, client: c,
} }
return opts.do(flags) return opts.do(input)
} }
func (opts *RebuildSubCommand) do(flags cli.Input) error { func (opts *RebuildSubCommand) do(input cli.Input) error {
err := opts.complete(flags) err := opts.complete(input)
if err != nil { if err != nil {
return err return err
} }
return opts.run(flags) return opts.run(input)
} }
func (opts *RebuildSubCommand) complete(flags cli.Input) error { func (opts *RebuildSubCommand) complete(input cli.Input) error {
opts.name = flags.String("name") opts.name = input.String(flagkey.PkgName)
if len(opts.name) == 0 { opts.namespace = input.String(flagkey.NamespacePackage)
return errors.New("Need name of package, use --name")
}
opts.namespace = flags.String("pkgNamespace")
return nil return nil
} }
func (opts *RebuildSubCommand) run(flags cli.Input) error { func (opts *RebuildSubCommand) run(input cli.Input) error {
pkg, err := opts.client.PackageGet(&metav1.ObjectMeta{ pkg, err := opts.client.PackageGet(&metav1.ObjectMeta{
Name: opts.name, Name: opts.name,
Namespace: opts.namespace, Namespace: opts.namespace,
+18 -29
View File
@@ -26,6 +26,7 @@ import (
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1" fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
"github.com/fission/fission/pkg/controller/client" "github.com/fission/fission/pkg/controller/client"
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli" "github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
"github.com/fission/fission/pkg/fission-cli/util" "github.com/fission/fission/pkg/fission-cli/util"
) )
@@ -42,51 +43,39 @@ type UpdateSubCommand struct {
keepURL bool keepURL bool
} }
func Update(flags cli.Input) error { func Update(input cli.Input) error {
c, err := util.GetServer(flags) c, err := util.GetServer(input)
if err != nil { if err != nil {
return err return err
} }
opts := UpdateSubCommand{ opts := UpdateSubCommand{
client: c, client: c,
} }
return opts.do(flags) return opts.do(input)
} }
func (opts *UpdateSubCommand) do(flags cli.Input) error { func (opts *UpdateSubCommand) do(input cli.Input) error {
err := opts.complete(flags) err := opts.complete(input)
if err != nil { if err != nil {
return err return err
} }
return opts.run(flags) return opts.run(input)
} }
func (opts *UpdateSubCommand) complete(flags cli.Input) error { func (opts *UpdateSubCommand) complete(input cli.Input) error {
opts.pkgName = flags.String("name") opts.pkgName = input.String(flagkey.PkgName)
if len(opts.pkgName) == 0 { opts.pkgNamespace = input.String(flagkey.NamespacePackage)
return errors.New("Need --name argument.") opts.force = input.Bool(flagkey.PkgForce)
} opts.envName = input.String(flagkey.PkgEnvironment)
opts.pkgNamespace = flags.String("pkgNamespace") opts.envNamespace = input.String(flagkey.NamespaceEnvironment)
opts.force = flags.Bool("f") opts.srcArchiveFiles = input.StringSlice(flagkey.PkgSrcArchive)
opts.envName = flags.String("env") opts.deployArchiveFiles = input.StringSlice(flagkey.PkgDeployArchive)
opts.envNamespace = flags.String("envNamespace") opts.buildcmd = input.String(flagkey.PkgBuildCmd)
opts.srcArchiveFiles = flags.StringSlice("src") opts.keepURL = input.Bool(flagkey.PkgKeepURL)
opts.deployArchiveFiles = flags.StringSlice("deploy")
opts.buildcmd = flags.String("buildcmd")
opts.keepURL = flags.Bool("keepurl")
if len(opts.srcArchiveFiles) > 0 && len(opts.deployArchiveFiles) > 0 {
return errors.New("Need either of --src or --deploy and not both arguments.")
}
if len(opts.srcArchiveFiles) == 0 && len(opts.deployArchiveFiles) == 0 &&
len(opts.envName) == 0 && len(opts.buildcmd) == 0 {
return errors.New("Need --env or --src or --deploy or --buildcmd argument.")
}
return nil return nil
} }
func (opts *UpdateSubCommand) run(flags cli.Input) error { func (opts *UpdateSubCommand) run(input cli.Input) error {
pkg, err := opts.client.PackageGet(&metav1.ObjectMeta{ pkg, err := opts.client.PackageGet(&metav1.ObjectMeta{
Namespace: opts.pkgNamespace, Namespace: opts.pkgNamespace,
Name: opts.pkgName, Name: opts.pkgName,
+4 -4
View File
@@ -31,18 +31,18 @@ type ListSubCommand struct {
client *client.Client client *client.Client
} }
func List(flags cli.Input) error { func List(input cli.Input) error {
c, err := util.GetServer(flags) c, err := util.GetServer(input)
if err != nil { if err != nil {
return err return err
} }
opts := &ListSubCommand{ opts := &ListSubCommand{
client: c, client: c,
} }
return opts.do(flags) return opts.do(input)
} }
func (opts *ListSubCommand) do(flags cli.Input) error { func (opts *ListSubCommand) do(input cli.Input) error {
w := tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', 0) w := tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', 0)
fmt.Fprintln(w, "NAME\tVERSION\tPATH") fmt.Fprintln(w, "NAME\tVERSION\tPATH")
for _, p := range plugin.FindAll() { for _, p := range plugin.FindAll() {
+7 -7
View File
@@ -30,7 +30,7 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(Create), RunE: wrapper.Wrapper(Create),
} }
wrapper.SetFlags(createCmd, flag.FlagSet{ wrapper.SetFlags(createCmd, flag.FlagSet{
Optional: []flag.Flag{flag.RecorderNameFlag, flag.RecorderFnFlag, flag.RecorderTriggersFlag, flag.SpecSaveFlag}, Optional: []flag.Flag{flag.RecorderName, flag.RecorderFn, flag.RecorderTriggers, flag.SpecSave},
}) })
getCmd := &cobra.Command{ getCmd := &cobra.Command{
@@ -39,7 +39,7 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(Get), RunE: wrapper.Wrapper(Get),
} }
wrapper.SetFlags(getCmd, flag.FlagSet{ wrapper.SetFlags(getCmd, flag.FlagSet{
Required: []flag.Flag{flag.RecorderNameFlag}, Required: []flag.Flag{flag.RecorderName},
}) })
updateCmd := &cobra.Command{ updateCmd := &cobra.Command{
@@ -48,8 +48,8 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(Update), RunE: wrapper.Wrapper(Update),
} }
wrapper.SetFlags(getCmd, flag.FlagSet{ wrapper.SetFlags(getCmd, flag.FlagSet{
Required: []flag.Flag{flag.RecorderNameFlag}, Required: []flag.Flag{flag.RecorderName},
Optional: []flag.Flag{flag.RecorderFnFlag, flag.RecorderTriggersFlag, flag.RecorderEnabledFlag, flag.RecorderDisabledFlag}, Optional: []flag.Flag{flag.RecorderFn, flag.RecorderTriggers, flag.RecorderEnabled, flag.RecorderDisabled},
}) })
deleteCmd := &cobra.Command{ deleteCmd := &cobra.Command{
@@ -58,8 +58,8 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(Delete), RunE: wrapper.Wrapper(Delete),
} }
wrapper.SetFlags(deleteCmd, flag.FlagSet{ wrapper.SetFlags(deleteCmd, flag.FlagSet{
Required: []flag.Flag{flag.RecorderNameFlag}, Required: []flag.Flag{flag.RecorderName},
Optional: []flag.Flag{flag.NamespaceRecorderFlag}, Optional: []flag.Flag{flag.NamespaceRecorder},
}) })
listCmd := &cobra.Command{ listCmd := &cobra.Command{
@@ -68,7 +68,7 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(List), RunE: wrapper.Wrapper(List),
} }
wrapper.SetFlags(deleteCmd, flag.FlagSet{ wrapper.SetFlags(deleteCmd, flag.FlagSet{
Optional: []flag.Flag{flag.NamespaceRecorderFlag}, Optional: []flag.Flag{flag.NamespaceRecorder},
}) })
command := &cobra.Command{ command := &cobra.Command{
+12 -12
View File
@@ -36,32 +36,32 @@ type CreateSubCommand struct {
recorder *fv1.Recorder recorder *fv1.Recorder
} }
func Create(flags cli.Input) error { func Create(input cli.Input) error {
c, err := util.GetServer(flags) c, err := util.GetServer(input)
if err != nil { if err != nil {
return err return err
} }
opts := CreateSubCommand{ opts := CreateSubCommand{
client: c, client: c,
} }
return opts.do(flags) return opts.do(input)
} }
func (opts *CreateSubCommand) do(flags cli.Input) error { func (opts *CreateSubCommand) do(input cli.Input) error {
err := opts.complete(flags) err := opts.complete(input)
if err != nil { if err != nil {
return err return err
} }
return opts.run(flags) return opts.run(input)
} }
func (opts *CreateSubCommand) complete(flags cli.Input) error { func (opts *CreateSubCommand) complete(input cli.Input) error {
recName := flags.String("name") recName := input.String("name")
if len(recName) == 0 { if len(recName) == 0 {
recName = uuid.NewV4().String() recName = uuid.NewV4().String()
} }
fnName := flags.String("function") fnName := input.String("function")
triggersOriginal := flags.StringSlice("trigger") triggersOriginal := input.StringSlice("trigger")
// Function XOR triggers can be given // Function XOR triggers can be given
if len(fnName) == 0 && len(triggersOriginal) == 0 { if len(fnName) == 0 && len(triggersOriginal) == 0 {
@@ -104,9 +104,9 @@ func (opts *CreateSubCommand) complete(flags cli.Input) error {
return nil return nil
} }
func (opts *CreateSubCommand) run(flags cli.Input) error { func (opts *CreateSubCommand) run(input cli.Input) error {
// If we're writing a spec, don't call the API // If we're writing a spec, don't call the API
if flags.Bool("spec") { if input.Bool("spec") {
specFile := fmt.Sprintf("recorder-%v.yaml", opts.recorder.Metadata.Name) specFile := fmt.Sprintf("recorder-%v.yaml", opts.recorder.Metadata.Name)
err := spec.SpecSave(*opts.recorder, specFile) err := spec.SpecSave(*opts.recorder, specFile)
if err != nil { if err != nil {
+11 -12
View File
@@ -32,35 +32,34 @@ type DeleteSubCommand struct {
metadata *metav1.ObjectMeta metadata *metav1.ObjectMeta
} }
func Delete(flags cli.Input) error { func Delete(input cli.Input) error {
c, err := util.GetServer(flags) c, err := util.GetServer(input)
if err != nil { if err != nil {
return err return err
} }
opts := DeleteSubCommand{ opts := DeleteSubCommand{
client: c, client: c,
} }
return opts.do(flags) return opts.do(input)
} }
func (opts *DeleteSubCommand) do(flags cli.Input) error { func (opts *DeleteSubCommand) do(input cli.Input) error {
err := opts.complete(flags) err := opts.complete(input)
if err != nil { if err != nil {
return err return err
} }
return opts.run(flags) return opts.run(input)
} }
func (opts *DeleteSubCommand) complete(flags cli.Input) error { func (opts *DeleteSubCommand) complete(input cli.Input) error {
m, err := util.GetMetadata("name", "recorderns", flags) opts.metadata = &metav1.ObjectMeta{
if err != nil { Name: input.String("name"),
return err Namespace: input.String("recorderns"),
} }
opts.metadata = m
return nil return nil
} }
func (opts *DeleteSubCommand) run(flags cli.Input) error { func (opts *DeleteSubCommand) run(input cli.Input) error {
err := opts.client.RecorderDelete(opts.metadata) err := opts.client.RecorderDelete(opts.metadata)
if err != nil { if err != nil {
return errors.Wrap(err, "error deleting recorder") return errors.Wrap(err, "error deleting recorder")
+9 -9
View File
@@ -34,27 +34,27 @@ type GetSubCommand struct {
name string name string
} }
func Get(flags cli.Input) error { func Get(input cli.Input) error {
c, err := util.GetServer(flags) c, err := util.GetServer(input)
if err != nil { if err != nil {
return err return err
} }
opts := GetSubCommand{ opts := GetSubCommand{
client: c, client: c,
} }
return opts.do(flags) return opts.do(input)
} }
func (opts *GetSubCommand) do(flags cli.Input) error { func (opts *GetSubCommand) do(input cli.Input) error {
err := opts.complete(flags) err := opts.complete(input)
if err != nil { if err != nil {
return err return err
} }
return opts.run(flags) return opts.run(input)
} }
func (opts *GetSubCommand) complete(flags cli.Input) error { func (opts *GetSubCommand) complete(input cli.Input) error {
opts.name = flags.String("name") opts.name = input.String("name")
if len(opts.name) <= 0 { if len(opts.name) <= 0 {
return errors.New("need a recorder name, use --name") return errors.New("need a recorder name, use --name")
@@ -62,7 +62,7 @@ func (opts *GetSubCommand) complete(flags cli.Input) error {
return nil return nil
} }
func (opts *GetSubCommand) run(flags cli.Input) error { func (opts *GetSubCommand) run(input cli.Input) error {
recorder, err := opts.client.RecorderGet(&metav1.ObjectMeta{ recorder, err := opts.client.RecorderGet(&metav1.ObjectMeta{
Name: opts.name, Name: opts.name,
Namespace: "default", Namespace: "default",
+6 -6
View File
@@ -32,22 +32,22 @@ type ListSubCommand struct {
client *client.Client client *client.Client
} }
func List(flags cli.Input) error { func List(input cli.Input) error {
c, err := util.GetServer(flags) c, err := util.GetServer(input)
if err != nil { if err != nil {
return err return err
} }
opts := ListSubCommand{ opts := ListSubCommand{
client: c, client: c,
} }
return opts.do(flags) return opts.do(input)
} }
func (opts *ListSubCommand) do(flags cli.Input) error { func (opts *ListSubCommand) do(input cli.Input) error {
return opts.run(flags) return opts.run(input)
} }
func (opts *ListSubCommand) run(flags cli.Input) error { func (opts *ListSubCommand) run(input cli.Input) error {
recorders, err := opts.client.RecorderList("default") recorders, err := opts.client.RecorderList("default")
if err != nil { if err != nil {
return errors.Wrap(err, "error listing recorders") return errors.Wrap(err, "error listing recorders")
+13 -13
View File
@@ -34,33 +34,33 @@ type UpdateSubCommand struct {
recorder *fv1.Recorder recorder *fv1.Recorder
} }
func Update(flags cli.Input) error { func Update(input cli.Input) error {
c, err := util.GetServer(flags) c, err := util.GetServer(input)
if err != nil { if err != nil {
return err return err
} }
opts := UpdateSubCommand{ opts := UpdateSubCommand{
client: c, client: c,
} }
return opts.do(flags) return opts.do(input)
} }
func (opts *UpdateSubCommand) do(flags cli.Input) error { func (opts *UpdateSubCommand) do(input cli.Input) error {
err := opts.complete(flags) err := opts.complete(input)
if err != nil { if err != nil {
return err return err
} }
return opts.run(flags) return opts.run(input)
} }
func (opts *UpdateSubCommand) complete(flags cli.Input) error { func (opts *UpdateSubCommand) complete(input cli.Input) error {
recName := flags.String("name") recName := input.String("name")
enable := flags.Bool("enable") enable := input.Bool("enable")
disable := flags.Bool("disable") disable := input.Bool("disable")
//retPolicy := flags.String("retention") //retPolicy := flags.String("retention")
//evictPolicy := flags.String("eviction") //evictPolicy := flags.String("eviction")
triggers := flags.StringSlice("trigger") triggers := input.StringSlice("trigger")
function := flags.String("function") function := input.String("function")
if enable && disable { if enable && disable {
return errors.New("Cannot enable and disable a recorder simultaneously.") return errors.New("Cannot enable and disable a recorder simultaneously.")
@@ -134,7 +134,7 @@ func (opts *UpdateSubCommand) complete(flags cli.Input) error {
return nil return nil
} }
func (opts *UpdateSubCommand) run(flags cli.Input) error { func (opts *UpdateSubCommand) run(input cli.Input) error {
_, err := opts.client.RecorderUpdate(opts.recorder) _, err := opts.client.RecorderUpdate(opts.recorder)
if err != nil { if err != nil {
return errors.Wrap(err, "error updating recorder") return errors.Wrap(err, "error updating recorder")
+3 -3
View File
@@ -30,9 +30,9 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(View), RunE: wrapper.Wrapper(View),
} }
wrapper.SetFlags(viewCmd, flag.FlagSet{ wrapper.SetFlags(viewCmd, flag.FlagSet{
Optional: []flag.Flag{flag.RecordsFilterTimeToFlag, flag.RecordsFilterTimeFromFlag, Optional: []flag.Flag{flag.RecordsFilterTimeTo, flag.RecordsFilterTimeFrom,
flag.RecordsFilterFunctionFlag, flag.RecordsFilterTriggerFlag, flag.RecordsVerbosityFlag, flag.RecordsFilterFunction, flag.RecordsFilterTrigger, flag.RecordsVerbosity,
flag.RecordsVvFlag}, flag.RecordsVv},
}) })
command := &cobra.Command{ command := &cobra.Command{
+13 -13
View File
@@ -33,37 +33,37 @@ type ViewSubCommand struct {
client *client.Client client *client.Client
} }
func View(flags cli.Input) error { func View(flaginput cli.Input) error {
c, err := util.GetServer(flags) c, err := util.GetServer(flaginput)
if err != nil { if err != nil {
return err return err
} }
opts := ViewSubCommand{ opts := ViewSubCommand{
client: c, client: c,
} }
return opts.do(flags) return opts.do(flaginput)
} }
func (opts *ViewSubCommand) do(flags cli.Input) error { func (opts *ViewSubCommand) do(input cli.Input) error {
return opts.run(flags) return opts.run(input)
} }
func (opts *ViewSubCommand) run(flags cli.Input) error { func (opts *ViewSubCommand) run(input cli.Input) error {
var verbosity int var verbosity int
if flags.Bool("v") && flags.Bool("vv") { if input.Bool("v") && input.Bool("vv") {
return errors.New("conflicting verbosity levels, use either --v or --vv") return errors.New("conflicting verbosity levels, use either --v or --vv")
} }
if flags.Bool("v") { if input.Bool("v") {
verbosity = 1 verbosity = 1
} }
if flags.Bool("vv") { if input.Bool("vv") {
verbosity = 2 verbosity = 2
} }
function := flags.String("function") function := input.String("function")
trigger := flags.String("trigger") trigger := input.String("trigger")
from := flags.String("from") from := input.String("from")
to := flags.String("to") to := input.String("to")
//Refuse multiple filters for now //Refuse multiple filters for now
if multipleFiltersSpecified(function, trigger, from+to) { if multipleFiltersSpecified(function, trigger, from+to) {
+1 -1
View File
@@ -30,7 +30,7 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(Replay), RunE: wrapper.Wrapper(Replay),
} }
wrapper.SetFlags(replayCmd, flag.FlagSet{ wrapper.SetFlags(replayCmd, flag.FlagSet{
Required: []flag.Flag{flag.RecordsReqIDFlag}, Required: []flag.Flag{flag.RecordsReqID},
}) })
command := &cobra.Command{ command := &cobra.Command{
+7 -7
View File
@@ -32,23 +32,23 @@ type ReplaySubCommand struct {
client *client.Client client *client.Client
} }
func Replay(flags cli.Input) error { func Replay(input cli.Input) error {
c, err := util.GetServer(flags) c, err := util.GetServer(input)
if err != nil { if err != nil {
return err return err
} }
opts := ReplaySubCommand{ opts := ReplaySubCommand{
client: c, client: c,
} }
return opts.do(flags) return opts.do(input)
} }
func (opts *ReplaySubCommand) do(flags cli.Input) error { func (opts *ReplaySubCommand) do(input cli.Input) error {
return opts.run(flags) return opts.run(input)
} }
func (opts *ReplaySubCommand) run(flags cli.Input) error { func (opts *ReplaySubCommand) run(input cli.Input) error {
reqUID := flags.String("reqUID") reqUID := input.String("reqUID")
if len(reqUID) == 0 { if len(reqUID) == 0 {
return errors.New("Need a reqUID, use --reqUID flag to specify") return errors.New("Need a reqUID, use --reqUID flag to specify")
} }
+12 -12
View File
@@ -34,10 +34,10 @@ import (
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1" fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
"github.com/fission/fission/pkg/controller/client" "github.com/fission/fission/pkg/controller/client"
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli" "github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
pkgutil "github.com/fission/fission/pkg/fission-cli/cmd/package/util" pkgutil "github.com/fission/fission/pkg/fission-cli/cmd/package/util"
spectypes "github.com/fission/fission/pkg/fission-cli/cmd/spec/types" spectypes "github.com/fission/fission/pkg/fission-cli/cmd/spec/types"
"github.com/fission/fission/pkg/fission-cli/console" "github.com/fission/fission/pkg/fission-cli/console"
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
"github.com/fission/fission/pkg/fission-cli/util" "github.com/fission/fission/pkg/fission-cli/util"
"github.com/fission/fission/pkg/types" "github.com/fission/fission/pkg/types"
"github.com/fission/fission/pkg/utils" "github.com/fission/fission/pkg/utils"
@@ -56,27 +56,27 @@ type ApplySubCommand struct {
// Apply is *not* transactional -- if the user hits Ctrl-C, or their laptop dies // Apply is *not* transactional -- if the user hits Ctrl-C, or their laptop dies
// etc, while doing an apply, they will get a partially applied deployment. However, // etc, while doing an apply, they will get a partially applied deployment. However,
// they can retry their apply command once they're back online. // they can retry their apply command once they're back online.
func Apply(flags cli.Input) error { func Apply(input cli.Input) error {
c, err := util.GetServer(flags) c, err := util.GetServer(input)
if err != nil { if err != nil {
return err return err
} }
opts := ApplySubCommand{ opts := ApplySubCommand{
client: c, client: c,
} }
return opts.do(flags) return opts.do(input)
} }
func (opts *ApplySubCommand) do(flags cli.Input) error { func (opts *ApplySubCommand) do(input cli.Input) error {
return opts.run(flags) return opts.run(input)
} }
func (opts *ApplySubCommand) run(flags cli.Input) error { func (opts *ApplySubCommand) run(input cli.Input) error {
specDir := util.GetSpecDir(flags) specDir := util.GetSpecDir(input)
deleteResources := flags.Bool("delete") deleteResources := input.Bool(flagkey.SpecDelete)
watchResources := flags.Bool("watch") watchResources := input.Bool(flagkey.SpecWatch)
waitForBuild := flags.Bool("wait") waitForBuild := input.Bool(flagkey.SpecWait)
var watcher *fsnotify.Watcher var watcher *fsnotify.Watcher
var pbw *packageBuildWatcher var pbw *packageBuildWatcher
@@ -123,7 +123,7 @@ func (opts *ApplySubCommand) run(flags cli.Input) error {
} }
// validate // validate
err = fr.Validate(flags) err = fr.Validate(input)
if err != nil { if err != nil {
return errors.Wrap(err, "error validating specs") return errors.Wrap(err, "error validating specs")
} }
+4 -4
View File
@@ -30,7 +30,7 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(Init), RunE: wrapper.Wrapper(Init),
} }
wrapper.SetFlags(initCmd, flag.FlagSet{ wrapper.SetFlags(initCmd, flag.FlagSet{
Optional: []flag.Flag{flag.SpecDirFlag, flag.SpecNameFlag, flag.SpecDeployIDFlag}, Optional: []flag.Flag{flag.SpecDir, flag.SpecName, flag.SpecDeployID},
}) })
validateCmd := &cobra.Command{ validateCmd := &cobra.Command{
@@ -39,7 +39,7 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(Validate), RunE: wrapper.Wrapper(Validate),
} }
wrapper.SetFlags(validateCmd, flag.FlagSet{ wrapper.SetFlags(validateCmd, flag.FlagSet{
Optional: []flag.Flag{flag.SpecDirFlag}, Optional: []flag.Flag{flag.SpecDir},
}) })
applyCmd := &cobra.Command{ applyCmd := &cobra.Command{
@@ -48,7 +48,7 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(Apply), RunE: wrapper.Wrapper(Apply),
} }
wrapper.SetFlags(applyCmd, flag.FlagSet{ wrapper.SetFlags(applyCmd, flag.FlagSet{
Optional: []flag.Flag{flag.SpecDirFlag, flag.SpecDeployIDFlag, flag.SpecWaitFlag}, Optional: []flag.Flag{flag.SpecDir, flag.SpecDeployID, flag.SpecWait},
}) })
destroyCmd := &cobra.Command{ destroyCmd := &cobra.Command{
@@ -57,7 +57,7 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(Destroy), RunE: wrapper.Wrapper(Destroy),
} }
wrapper.SetFlags(destroyCmd, flag.FlagSet{ wrapper.SetFlags(destroyCmd, flag.FlagSet{
Optional: []flag.Flag{flag.SpecDirFlag}, Optional: []flag.Flag{flag.SpecDir},
}) })
command := &cobra.Command{ command := &cobra.Command{
+7 -7
View File
@@ -29,24 +29,24 @@ type DestroySubCommand struct {
} }
// Destroy destroys everything in the spec. // Destroy destroys everything in the spec.
func Destroy(flags cli.Input) error { func Destroy(input cli.Input) error {
c, err := util.GetServer(flags) c, err := util.GetServer(input)
if err != nil { if err != nil {
return err return err
} }
opts := &DestroySubCommand{ opts := &DestroySubCommand{
client: c, client: c,
} }
return opts.do(flags) return opts.do(input)
} }
func (opts *DestroySubCommand) do(flags cli.Input) error { func (opts *DestroySubCommand) do(input cli.Input) error {
return opts.run(flags) return opts.run(input)
} }
func (opts *DestroySubCommand) run(flags cli.Input) error { func (opts *DestroySubCommand) run(input cli.Input) error {
// get specdir // get specdir
specDir := util.GetSpecDir(flags) specDir := util.GetSpecDir(input)
// read everything // read everything
fr, err := ReadSpecs(specDir) fr, err := ReadSpecs(specDir)
+13 -12
View File
@@ -29,6 +29,7 @@ import (
"github.com/fission/fission/pkg/controller/client" "github.com/fission/fission/pkg/controller/client"
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli" "github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
spectypes "github.com/fission/fission/pkg/fission-cli/cmd/spec/types" spectypes "github.com/fission/fission/pkg/fission-cli/cmd/spec/types"
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
"github.com/fission/fission/pkg/fission-cli/util" "github.com/fission/fission/pkg/fission-cli/util"
) )
@@ -37,30 +38,30 @@ type InitSubCommand struct {
deployConfig *spectypes.DeploymentConfig deployConfig *spectypes.DeploymentConfig
} }
func Init(flags cli.Input) error { func Init(input cli.Input) error {
c, err := util.GetServer(flags) c, err := util.GetServer(input)
if err != nil { if err != nil {
return err return err
} }
opts := InitSubCommand{ opts := InitSubCommand{
client: c, client: c,
} }
return opts.do(flags) return opts.do(input)
} }
func (opts *InitSubCommand) do(flags cli.Input) error { func (opts *InitSubCommand) do(input cli.Input) error {
err := opts.complete(flags) err := opts.complete(input)
if err != nil { if err != nil {
return err return err
} }
return opts.run(flags) return opts.run(input)
} }
func (opts *InitSubCommand) complete(flags cli.Input) error { func (opts *InitSubCommand) complete(input cli.Input) error {
// Figure out spec directory // Figure out spec directory
specDir := util.GetSpecDir(flags) specDir := util.GetSpecDir(input)
name := flags.String("name") name := input.String(flagkey.SpecName)
if len(name) == 0 { if len(name) == 0 {
// come up with a name using the current dir // come up with a name using the current dir
dir, err := filepath.Abs(".") dir, err := filepath.Abs(".")
@@ -71,7 +72,7 @@ func (opts *InitSubCommand) complete(flags cli.Input) error {
name = util.KubifyName(basename) name = util.KubifyName(basename)
} }
deployID := flags.String("deployid") deployID := input.String(flagkey.SpecDeployID)
if len(deployID) == 0 { if len(deployID) == 0 {
deployID = uuid.NewV4().String() deployID = uuid.NewV4().String()
} }
@@ -101,8 +102,8 @@ func (opts *InitSubCommand) complete(flags cli.Input) error {
// run just initializes an empty spec directory and adds some // run just initializes an empty spec directory and adds some
// sample YAMLs in there that might be useful. // sample YAMLs in there that might be useful.
func (opts *InitSubCommand) run(flags cli.Input) error { func (opts *InitSubCommand) run(input cli.Input) error {
specDir := util.GetSpecDir(flags) specDir := util.GetSpecDir(input)
// Add a bit of documentation to the spec dir here // Add a bit of documentation to the spec dir here
err := ioutil.WriteFile(filepath.Join(specDir, "README"), []byte(SPEC_README), 0644) err := ioutil.WriteFile(filepath.Join(specDir, "README"), []byte(SPEC_README), 0644)
+2 -2
View File
@@ -246,7 +246,7 @@ func (fr *FissionResources) validateFunctionReference(functions map[string]bool,
return nil return nil
} }
func (fr *FissionResources) Validate(flags cli.Input) error { func (fr *FissionResources) Validate(input cli.Input) error {
result := utils.MultiErrorWithFormat() result := utils.MultiErrorWithFormat()
// check references: both dangling refs + garbage // check references: both dangling refs + garbage
@@ -348,7 +348,7 @@ func (fr *FissionResources) Validate(flags cli.Input) error {
packages[MapKey(pkgMeta)] = true packages[MapKey(pkgMeta)] = true
} }
client, err := util.GetServer(flags) client, err := util.GetServer(input)
if err != nil { if err != nil {
return err return err
} }
+8 -8
View File
@@ -38,32 +38,32 @@ type ValidateSubCommand struct {
// Validate parses a set of specs and checks for references to // Validate parses a set of specs and checks for references to
// resources that don't exist. // resources that don't exist.
func Validate(flags cli.Input) error { func Validate(input cli.Input) error {
c, err := util.GetServer(flags) c, err := util.GetServer(input)
if err != nil { if err != nil {
return err return err
} }
opts := &ValidateSubCommand{ opts := &ValidateSubCommand{
client: c, client: c,
} }
return opts.do(flags) return opts.do(input)
} }
func (opts *ValidateSubCommand) do(flags cli.Input) error { func (opts *ValidateSubCommand) do(input cli.Input) error {
return opts.run(flags) return opts.run(input)
} }
func (opts *ValidateSubCommand) run(flags cli.Input) error { func (opts *ValidateSubCommand) run(input cli.Input) error {
// this will error on parse errors and on duplicates // this will error on parse errors and on duplicates
specDir := util.GetSpecDir(flags) specDir := util.GetSpecDir(input)
fr, err := ReadSpecs(specDir) fr, err := ReadSpecs(specDir)
if err != nil { if err != nil {
return errors.Wrap(err, "error reading specs") return errors.Wrap(err, "error reading specs")
} }
// this does the rest of the checks, like dangling refs // this does the rest of the checks, like dangling refs
err = fr.Validate(flags) err = fr.Validate(input)
if err != nil { if err != nil {
return errors.Wrap(err, "error validating specs") return errors.Wrap(err, "error validating specs")
} }
+1 -1
View File
@@ -30,7 +30,7 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(Dump), RunE: wrapper.Wrapper(Dump),
} }
wrapper.SetFlags(dumpCmd, flag.FlagSet{ wrapper.SetFlags(dumpCmd, flag.FlagSet{
Optional: []flag.Flag{flag.SupportNoZipFlag, flag.SupportOutputFlag}, Optional: []flag.Flag{flag.SupportNoZip, flag.SupportOutput},
}) })
command := &cobra.Command{ command := &cobra.Command{
+7 -6
View File
@@ -28,6 +28,7 @@ import (
"github.com/fission/fission/pkg/controller/client" "github.com/fission/fission/pkg/controller/client"
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli" "github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
"github.com/fission/fission/pkg/fission-cli/cmd/support/resources" "github.com/fission/fission/pkg/fission-cli/cmd/support/resources"
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
"github.com/fission/fission/pkg/fission-cli/util" "github.com/fission/fission/pkg/fission-cli/util"
"github.com/fission/fission/pkg/utils" "github.com/fission/fission/pkg/utils"
) )
@@ -41,22 +42,22 @@ type DumpSubCommand struct {
client *client.Client client *client.Client
} }
func Dump(flags cli.Input) error { func Dump(input cli.Input) error {
c, err := util.GetServer(flags) c, err := util.GetServer(input)
if err != nil { if err != nil {
return err return err
} }
opts := &DumpSubCommand{ opts := &DumpSubCommand{
client: c, client: c,
} }
return opts.do(flags) return opts.do(input)
} }
func (opts *DumpSubCommand) do(flags cli.Input) error { func (opts *DumpSubCommand) do(input cli.Input) error {
fmt.Println("Start dumping process...") fmt.Println("Start dumping process...")
nozip := flags.Bool("nozip") nozip := input.Bool(flagkey.SupportNoZip)
outputDir := flags.String("output") outputDir := input.String(flagkey.SupportOutput)
// check whether the dump directory exists. // check whether the dump directory exists.
_, err := os.Stat(outputDir) _, err := os.Stat(outputDir)
+7 -7
View File
@@ -30,7 +30,7 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(Create), RunE: wrapper.Wrapper(Create),
} }
wrapper.SetFlags(createCmd, flag.FlagSet{ wrapper.SetFlags(createCmd, flag.FlagSet{
Optional: []flag.Flag{flag.TtNameFlag, flag.TtFnNameFlag, flag.NamespaceFunctionFlag, flag.TtCronFlag, flag.SpecSaveFlag}, Optional: []flag.Flag{flag.TtName, flag.TtFnName, flag.NamespaceFunction, flag.TtCron, flag.SpecSave},
}) })
updateCmd := &cobra.Command{ updateCmd := &cobra.Command{
@@ -40,8 +40,8 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(Update), RunE: wrapper.Wrapper(Update),
} }
wrapper.SetFlags(updateCmd, flag.FlagSet{ wrapper.SetFlags(updateCmd, flag.FlagSet{
Required: []flag.Flag{flag.TtNameFlag}, Required: []flag.Flag{flag.TtName},
Optional: []flag.Flag{flag.TtFnNameFlag, flag.NamespaceFunctionFlag, flag.TtCronFlag}, Optional: []flag.Flag{flag.TtFnName, flag.NamespaceFunction, flag.TtCron},
}) })
deleteCmd := &cobra.Command{ deleteCmd := &cobra.Command{
@@ -51,8 +51,8 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(Delete), RunE: wrapper.Wrapper(Delete),
} }
wrapper.SetFlags(deleteCmd, flag.FlagSet{ wrapper.SetFlags(deleteCmd, flag.FlagSet{
Required: []flag.Flag{flag.TtNameFlag}, Required: []flag.Flag{flag.TtName},
Optional: []flag.Flag{flag.NamespaceTriggerFlag}, Optional: []flag.Flag{flag.NamespaceTrigger},
}) })
listCmd := &cobra.Command{ listCmd := &cobra.Command{
@@ -62,7 +62,7 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(List), RunE: wrapper.Wrapper(List),
} }
wrapper.SetFlags(listCmd, flag.FlagSet{ wrapper.SetFlags(listCmd, flag.FlagSet{
Optional: []flag.Flag{flag.NamespaceTriggerFlag}, Optional: []flag.Flag{flag.NamespaceTrigger},
}) })
showCmd := &cobra.Command{ showCmd := &cobra.Command{
@@ -72,7 +72,7 @@ func Commands() *cobra.Command {
RunE: wrapper.Wrapper(Show), RunE: wrapper.Wrapper(Show),
} }
wrapper.SetFlags(showCmd, flag.FlagSet{ wrapper.SetFlags(showCmd, flag.FlagSet{
Optional: []flag.Flag{flag.TtCronFlag, flag.TtRoundFlag}, Optional: []flag.Flag{flag.TtCron, flag.TtRound},
}) })
command := &cobra.Command{ command := &cobra.Command{
+14 -13
View File
@@ -29,6 +29,7 @@ import (
"github.com/fission/fission/pkg/controller/client" "github.com/fission/fission/pkg/controller/client"
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli" "github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
"github.com/fission/fission/pkg/fission-cli/cmd/spec" "github.com/fission/fission/pkg/fission-cli/cmd/spec"
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
"github.com/fission/fission/pkg/fission-cli/util" "github.com/fission/fission/pkg/fission-cli/util"
) )
@@ -37,39 +38,39 @@ type CreateSubCommand struct {
trigger *fv1.TimeTrigger trigger *fv1.TimeTrigger
} }
func Create(flags cli.Input) error { func Create(input cli.Input) error {
c, err := util.GetServer(flags) c, err := util.GetServer(input)
if err != nil { if err != nil {
return err return err
} }
opts := CreateSubCommand{ opts := CreateSubCommand{
client: c, client: c,
} }
return opts.do(flags) return opts.do(input)
} }
func (opts *CreateSubCommand) do(flags cli.Input) error { func (opts *CreateSubCommand) do(input cli.Input) error {
err := opts.complete(flags) err := opts.complete(input)
if err != nil { if err != nil {
return err return err
} }
return opts.run(flags) return opts.run(input)
} }
func (opts *CreateSubCommand) complete(flags cli.Input) error { func (opts *CreateSubCommand) complete(input cli.Input) error {
name := flags.String("name") name := input.String(flagkey.TtName)
if len(name) == 0 { if len(name) == 0 {
name = uuid.NewV4().String() name = uuid.NewV4().String()
} }
fnName := flags.String("function") fnName := input.String(flagkey.TtFnName)
if len(fnName) == 0 { if len(fnName) == 0 {
return errors.New("Need a function name to create a trigger, use --function") return errors.New("Need a function name to create a trigger, use --function")
} }
fnNamespace := flags.String("fnNamespace") fnNamespace := input.String(flagkey.NamespaceFunction)
cronSpec := flags.String("cron") cronSpec := input.String(flagkey.TtCron)
if len(cronSpec) == 0 { if len(cronSpec) == 0 {
return errors.New("Need a cron spec like '0 30 * * * *', '@every 1h30m', or '@hourly'; use --cron") return errors.New("Need a cron spec like '0 30 * * * *', '@every 1h30m', or '@hourly'; use --cron")
} }
@@ -91,9 +92,9 @@ func (opts *CreateSubCommand) complete(flags cli.Input) error {
return nil return nil
} }
func (opts *CreateSubCommand) run(flags cli.Input) error { func (opts *CreateSubCommand) run(input cli.Input) error {
// if we're writing a spec, don't call the API // if we're writing a spec, don't call the API
if flags.Bool("spec") { if input.Bool(flagkey.SpecSave) {
specFile := fmt.Sprintf("timetrigger-%v.yaml", opts.trigger.Metadata.Name) specFile := fmt.Sprintf("timetrigger-%v.yaml", opts.trigger.Metadata.Name)
err := spec.SpecSave(*opts.trigger, specFile) err := spec.SpecSave(*opts.trigger, specFile)
if err != nil { if err != nil {
+10 -8
View File
@@ -20,9 +20,11 @@ import (
"fmt" "fmt"
"github.com/pkg/errors" "github.com/pkg/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/fission/fission/pkg/controller/client" "github.com/fission/fission/pkg/controller/client"
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli" "github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
"github.com/fission/fission/pkg/fission-cli/util" "github.com/fission/fission/pkg/fission-cli/util"
) )
@@ -30,24 +32,24 @@ type DeleteSubCommand struct {
client *client.Client client *client.Client
} }
func Delete(flags cli.Input) error { func Delete(input cli.Input) error {
c, err := util.GetServer(flags) c, err := util.GetServer(input)
if err != nil { if err != nil {
return err return err
} }
opts := DeleteSubCommand{ opts := DeleteSubCommand{
client: c, client: c,
} }
return opts.do(flags) return opts.do(input)
} }
func (opts *DeleteSubCommand) do(flags cli.Input) error { func (opts *DeleteSubCommand) do(input cli.Input) error {
m, err := util.GetMetadata("name", "triggerns", flags) m := &metav1.ObjectMeta{
if err != nil { Name: input.String(flagkey.TtName),
return err Namespace: input.String(flagkey.NamespaceTrigger),
} }
err = opts.client.TimeTriggerDelete(m) err := opts.client.TimeTriggerDelete(m)
if err != nil { if err != nil {
return errors.Wrap(err, "error deleting trigger") return errors.Wrap(err, "error deleting trigger")
} }
+6 -5
View File
@@ -23,6 +23,7 @@ import (
"github.com/fission/fission/pkg/controller/client" "github.com/fission/fission/pkg/controller/client"
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli" "github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
"github.com/fission/fission/pkg/fission-cli/util" "github.com/fission/fission/pkg/fission-cli/util"
"github.com/pkg/errors" "github.com/pkg/errors"
) )
@@ -31,19 +32,19 @@ type ListSubCommand struct {
client *client.Client client *client.Client
} }
func List(flags cli.Input) error { func List(input cli.Input) error {
c, err := util.GetServer(flags) c, err := util.GetServer(input)
if err != nil { if err != nil {
return err return err
} }
opts := ListSubCommand{ opts := ListSubCommand{
client: c, client: c,
} }
return opts.do(flags) return opts.do(input)
} }
func (opts *ListSubCommand) do(flags cli.Input) error { func (opts *ListSubCommand) do(input cli.Input) error {
ttNs := flags.String("triggerns") ttNs := input.String(flagkey.NamespaceTrigger)
tts, err := opts.client.TimeTriggerList(ttNs) tts, err := opts.client.TimeTriggerList(ttNs)
if err != nil { if err != nil {
return errors.Wrap(err, "list Time triggers") return errors.Wrap(err, "list Time triggers")
+9 -8
View File
@@ -21,6 +21,7 @@ import (
"github.com/fission/fission/pkg/controller/client" "github.com/fission/fission/pkg/controller/client"
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli" "github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
"github.com/fission/fission/pkg/fission-cli/util" "github.com/fission/fission/pkg/fission-cli/util"
) )
@@ -28,24 +29,24 @@ type ShowSubCommand struct {
client *client.Client client *client.Client
} }
func Show(flags cli.Input) error { func Show(input cli.Input) error {
c, err := util.GetServer(flags) c, err := util.GetServer(input)
if err != nil { if err != nil {
return err return err
} }
opts := ShowSubCommand{ opts := ShowSubCommand{
client: c, client: c,
} }
return opts.do(flags) return opts.do(input)
} }
func (opts *ShowSubCommand) do(flags cli.Input) error { func (opts *ShowSubCommand) do(input cli.Input) error {
return opts.run(flags) return opts.run(input)
} }
func (opts *ShowSubCommand) run(flags cli.Input) error { func (opts *ShowSubCommand) run(flaginput cli.Input) error {
round := flags.Int("round") round := flaginput.Int(flagkey.TtName)
cronSpec := flags.String("cron") cronSpec := flaginput.String(flagkey.TtCron)
if len(cronSpec) == 0 { if len(cronSpec) == 0 {
return errors.New("need a cron spec like '0 30 * * * *', '@every 1h30m', or '@hourly'; use --cron") return errors.New("need a cron spec like '0 30 * * * *', '@every 1h30m', or '@hourly'; use --cron")
} }
+17 -17
View File
@@ -20,10 +20,12 @@ import (
"fmt" "fmt"
"github.com/pkg/errors" "github.com/pkg/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
fv1 "github.com/fission/fission/pkg/apis/fission.io/v1" fv1 "github.com/fission/fission/pkg/apis/fission.io/v1"
"github.com/fission/fission/pkg/controller/client" "github.com/fission/fission/pkg/controller/client"
"github.com/fission/fission/pkg/fission-cli/cliwrapper/cli" "github.com/fission/fission/pkg/fission-cli/cliwrapper/cli"
flagkey "github.com/fission/fission/pkg/fission-cli/flag/key"
"github.com/fission/fission/pkg/fission-cli/util" "github.com/fission/fission/pkg/fission-cli/util"
) )
@@ -32,38 +34,36 @@ type UpdateSubCommand struct {
trigger *fv1.TimeTrigger trigger *fv1.TimeTrigger
} }
func Update(flags cli.Input) error { func Update(input cli.Input) error {
c, err := util.GetServer(flags) c, err := util.GetServer(input)
if err != nil { if err != nil {
return err return err
} }
opts := UpdateSubCommand{ opts := UpdateSubCommand{
client: c, client: c,
} }
return opts.do(flags) return opts.do(input)
} }
func (opts *UpdateSubCommand) do(flags cli.Input) error { func (opts *UpdateSubCommand) do(input cli.Input) error {
err := opts.complete(flags) err := opts.complete(input)
if err != nil { if err != nil {
return err return err
} }
return opts.run(flags) return opts.run(input)
} }
func (opts *UpdateSubCommand) complete(flags cli.Input) error { func (opts *UpdateSubCommand) complete(input cli.Input) error {
m, err := util.GetMetadata("name", "triggerns", flags) tt, err := opts.client.TimeTriggerGet(&metav1.ObjectMeta{
if err != nil { Name: input.String(flagkey.TtName),
return err Namespace: input.String(flagkey.NamespaceTrigger),
} })
tt, err := opts.client.TimeTriggerGet(m)
if err != nil { if err != nil {
return errors.Wrap(err, "error getting time trigger") return errors.Wrap(err, "error getting time trigger")
} }
updated := false updated := false
newCron := flags.String("cron") newCron := input.String("cron")
if len(newCron) != 0 { if len(newCron) != 0 {
tt.Spec.Cron = newCron tt.Spec.Cron = newCron
updated = true updated = true
@@ -72,7 +72,7 @@ func (opts *UpdateSubCommand) complete(flags cli.Input) error {
// TODO : During update, function has to be in the same ns as the trigger object // TODO : During update, function has to be in the same ns as the trigger object
// but since we are not checking this for other triggers too, not sure if we need a check here. // but since we are not checking this for other triggers too, not sure if we need a check here.
fnName := flags.String("function") fnName := input.String("function")
if len(fnName) > 0 { if len(fnName) > 0 {
tt.Spec.FunctionReference.Name = fnName tt.Spec.FunctionReference.Name = fnName
updated = true updated = true
@@ -87,13 +87,13 @@ func (opts *UpdateSubCommand) complete(flags cli.Input) error {
return nil return nil
} }
func (opts *UpdateSubCommand) run(flags cli.Input) error { func (opts *UpdateSubCommand) run(input cli.Input) error {
_, err := opts.client.TimeTriggerUpdate(opts.trigger) _, err := opts.client.TimeTriggerUpdate(opts.trigger)
if err != nil { if err != nil {
return errors.Wrap(err, "error updating Time trigger") return errors.Wrap(err, "error updating Time trigger")
} }
fmt.Printf("Time trigger '%v' updated\n", opts.trigger.Metadata.Name) fmt.Printf("trigger '%v' updated\n", opts.trigger.Metadata.Name)
t, err := getAPITimeInfo(opts.client) t, err := getAPITimeInfo(opts.client)
if err != nil { if err != nil {
+4 -4
View File
@@ -31,18 +31,18 @@ type VersionSubCommand struct {
client *client.Client client *client.Client
} }
func Version(flags cli.Input) error { func Version(input cli.Input) error {
c, err := util.GetServer(flags) c, err := util.GetServer(input)
if err != nil { if err != nil {
return err return err
} }
opts := &VersionSubCommand{ opts := &VersionSubCommand{
client: c, client: c,
} }
return opts.do(flags) return opts.do(input)
} }
func (opts *VersionSubCommand) do(flags cli.Input) error { func (opts *VersionSubCommand) do(input cli.Input) error {
ver := util.GetVersion(opts.client) ver := util.GetVersion(opts.client)
bs, err := yaml.Marshal(ver) bs, err := yaml.Marshal(ver)
if err != nil { if err != nil {
+114 -114
View File
@@ -67,133 +67,133 @@ const (
) )
var ( var (
GlobalVerbosityFlag = Flag{Type: Int, Name: flagkey.Verbosity, Short: "v", Usage: "CLI verbosity (0 is quiet, 1 is the default, 2 is verbose)", DefaultValue: 1} GlobalVerbosity = Flag{Type: Int, Name: flagkey.Verbosity, Short: "v", Usage: "CLI verbosity (0 is quiet, 1 is the default, 2 is verbose)", DefaultValue: 1}
GlobalServerFlag = Flag{Type: String, Name: flagkey.Server, Usage: "Server URL"} GlobalServer = Flag{Type: String, Name: flagkey.Server, Usage: "Server URL"}
NamespaceFunctionFlag = Flag{Type: String, Name: flagkey.NamespaceFunction, Aliases: []string{"fns"}, Usage: "Namespace for function object", DefaultValue: metav1.NamespaceDefault} NamespaceFunction = Flag{Type: String, Name: flagkey.NamespaceFunction, Aliases: []string{"fns"}, Usage: "Namespace for function object", DefaultValue: metav1.NamespaceDefault}
NamespaceEnvironmentFlag = Flag{Type: String, Name: flagkey.NamespaceEnvironment, Aliases: []string{"envns"}, Usage: "Namespace for environment object", DefaultValue: metav1.NamespaceDefault} NamespaceEnvironment = Flag{Type: String, Name: flagkey.NamespaceEnvironment, Aliases: []string{"envns"}, Usage: "Namespace for environment object", DefaultValue: metav1.NamespaceDefault}
NamespacePackageFlag = Flag{Type: String, Name: flagkey.NamespacePackage, Aliases: []string{"pkgns"}, Usage: "Namespace for package object", DefaultValue: metav1.NamespaceDefault} NamespacePackage = Flag{Type: String, Name: flagkey.NamespacePackage, Aliases: []string{"pkgns"}, Usage: "Namespace for package object", DefaultValue: metav1.NamespaceDefault}
NamespaceTriggerFlag = Flag{Type: String, Name: flagkey.NamespaceTrigger, Aliases: []string{"triggerns"}, Usage: "Namespace for trigger object", DefaultValue: metav1.NamespaceDefault} NamespaceTrigger = Flag{Type: String, Name: flagkey.NamespaceTrigger, Aliases: []string{"triggerns"}, Usage: "Namespace for trigger object", DefaultValue: metav1.NamespaceDefault}
NamespaceRecorderFlag = Flag{Type: String, Name: flagkey.NamespaceRecorder, Aliases: []string{"recorderns"}, Usage: "Namespace for recorder object", DefaultValue: metav1.NamespaceDefault} NamespaceRecorder = Flag{Type: String, Name: flagkey.NamespaceRecorder, Aliases: []string{"recorderns"}, Usage: "Namespace for recorder object", DefaultValue: metav1.NamespaceDefault}
NamespaceCanaryFlag = Flag{Type: String, Name: flagkey.NamespaceCanary, Aliases: []string{"canaryns"}, Usage: "Namespace for canary config object", DefaultValue: metav1.NamespaceDefault} NamespaceCanary = Flag{Type: String, Name: flagkey.NamespaceCanary, Aliases: []string{"canaryns"}, Usage: "Namespace for canary config object", DefaultValue: metav1.NamespaceDefault}
RunTimeMinCPUFlag = Flag{Type: Int, Name: flagkey.RuntimeMincpu, Usage: "Minimum CPU to be assigned to pod (In millicore, minimum 1)"} RunTimeMinCPU = Flag{Type: Int, Name: flagkey.RuntimeMincpu, Usage: "Minimum CPU to be assigned to pod (In millicore, minimum 1)"}
RunTimeMaxCPUFlag = Flag{Type: Int, Name: flagkey.RuntimeMaxcpu, Usage: "Maximum CPU to be assigned to pod (In millicore, minimum 1)"} RunTimeMaxCPU = Flag{Type: Int, Name: flagkey.RuntimeMaxcpu, Usage: "Maximum CPU to be assigned to pod (In millicore, minimum 1)"}
RunTimeTargetCPUFlag = Flag{Type: Int, Name: flagkey.RuntimeTargetcpu, Usage: "Target average CPU usage percentage across pods for scaling", DefaultValue: 80} RunTimeTargetCPU = Flag{Type: Int, Name: flagkey.RuntimeTargetcpu, Usage: "Target average CPU usage percentage across pods for scaling", DefaultValue: 80}
RunTimeMinMemoryFlag = Flag{Type: Int, Name: flagkey.RuntimeMinmemory, Usage: "Minimum memory to be assigned to pod (In megabyte)"} RunTimeMinMemory = Flag{Type: Int, Name: flagkey.RuntimeMinmemory, Usage: "Minimum memory to be assigned to pod (In megabyte)"}
RunTimeMaxMemoryFlag = Flag{Type: Int, Name: flagkey.RuntimeMaxmemory, Usage: "Maximum memory to be assigned to pod (In megabyte)"} RunTimeMaxMemory = Flag{Type: Int, Name: flagkey.RuntimeMaxmemory, Usage: "Maximum memory to be assigned to pod (In megabyte)"}
ReplicasMinFlag = Flag{Type: Int, Name: flagkey.ReplicasMinscale, Usage: "Minimum number of pods (Uses resource inputs to configure HPA)", DefaultValue: 1} ReplicasMin = Flag{Type: Int, Name: flagkey.ReplicasMinscale, Usage: "Minimum number of pods (Uses resource inputs to configure HPA)", DefaultValue: 1}
ReplicasMaxFlag = Flag{Type: Int, Name: flagkey.ReplicasMaxscale, Usage: "Maximum number of pods (Uses resource inputs to configure HPA)", DefaultValue: 1} ReplicasMax = Flag{Type: Int, Name: flagkey.ReplicasMaxscale, Usage: "Maximum number of pods (Uses resource inputs to configure HPA)", DefaultValue: 1}
FnNameFlag = Flag{Type: String, Name: flagkey.FnName, Usage: "Function name"} FnName = Flag{Type: String, Name: flagkey.FnName, Usage: "Function name"}
FnSpecializationTimeoutFlag = Flag{Type: Int, Name: flagkey.FnSpecializationTimeout, Aliases: []string{"st"}, Usage: "Timeout for newdeploy to wait for function pod creation", DefaultValue: fv1.DefaultSpecializationTimeOut} FnSpecializationTimeout = Flag{Type: Int, Name: flagkey.FnSpecializationTimeout, Aliases: []string{"st"}, Usage: "Timeout for newdeploy to wait for function pod creation", DefaultValue: fv1.DefaultSpecializationTimeOut}
FnEnvNameFlag = Flag{Type: String, Name: flagkey.FnEnvironmentName, Usage: "Environment name for function"} FnEnvName = Flag{Type: String, Name: flagkey.FnEnvironmentName, Usage: "Environment name for function"}
FnCodeFlag = Flag{Type: String, Name: flagkey.FnCode, Usage: "Local path or URL for single file source code"} FnCode = Flag{Type: String, Name: flagkey.FnCode, Usage: "Local path or URL for single file source code"}
FnKeepURLFlag = Flag{Type: Bool, Name: flagkey.PkgKeepURL, Aliases: []string{"keepurl"}, Usage: "Keep the providing URL in archive instead of downloading file from it. (If set, no checksum will be generated for file integrity check. You must ensure the file won't be changed.)"} FnKeepURL = Flag{Type: Bool, Name: flagkey.PkgKeepURL, Aliases: []string{"keepurl"}, Usage: "Keep the providing URL in archive instead of downloading file from it. (If set, no checksum will be generated for file integrity check. You must ensure the file won't be changed.)"}
FnPkgNameFlag = Flag{Type: String, Name: flagkey.FnPackageName, Aliases: []string{"pkg"}, Usage: "Name of the existing package (--deploy and --src and --env will be ignored), should be in the same namespace as the function"} FnPkgName = Flag{Type: String, Name: flagkey.FnPackageName, Aliases: []string{"pkg"}, Usage: "Name of the existing package (--deploy and --src and --env will be ignored), should be in the same namespace as the function"}
FnEntryPointFlag = Flag{Type: String, Name: flagkey.FnEntrypoint, Aliases: []string{"entry"}, Usage: "Entry point for environment v2 to load with"} FnEntryPoint = Flag{Type: String, Name: flagkey.FnEntrypoint, Aliases: []string{"entry"}, Usage: "Entry point for environment v2 to load with"}
FnBuildCmdFlag = Flag{Type: String, Name: flagkey.FnBuildCmd, Usage: "Package build command for builder to run with"} FnBuildCmd = Flag{Type: String, Name: flagkey.FnBuildCmd, Usage: "Package build command for builder to run with"}
FnSecretFlag = Flag{Type: StringSlice, Name: flagkey.FnSecret, Usage: "Function access to secret, should be present in the same namespace as the function. You can provide multiple secrets using multiple --secrets flags. In the case of fn update the the secrets will be replaced by the provided list of secrets."} FnSecret = Flag{Type: StringSlice, Name: flagkey.FnSecret, Usage: "Function access to secret, should be present in the same namespace as the function. You can provide multiple secrets using multiple --secrets flags. In the case of fn update the the secrets will be replaced by the provided list of secrets."}
FnCfgMapFlag = Flag{Type: StringSlice, Name: flagkey.FnCfgMap, Usage: "Function access to configmap, should be present in the same namespace as the function. You can provide multiple configmaps using multiple --configmap flags. In case of fn update the configmaps will be replaced by the provided list of configmaps."} FnCfgMap = Flag{Type: StringSlice, Name: flagkey.FnCfgMap, Usage: "Function access to configmap, should be present in the same namespace as the function. You can provide multiple configmaps using multiple --configmap flags. In case of fn update the configmaps will be replaced by the provided list of configmaps."}
FnExecutorTypeFlag = Flag{Type: String, Name: flagkey.FnExecutorType, Usage: "Executor type for execution; one of 'poolmgr', 'newdeploy'", DefaultValue: types.ExecutorTypePoolmgr} FnExecutorType = Flag{Type: String, Name: flagkey.FnExecutorType, Usage: "Executor type for execution; one of 'poolmgr', 'newdeploy'", DefaultValue: types.ExecutorTypePoolmgr}
FnExecutionTimeoutFlag = Flag{Type: Int, Name: flagkey.FnExecutionTimeout, Aliases: []string{"ft"}, Usage: "Time duration to wait for the response while executing the function", DefaultValue: 60} FnExecutionTimeout = Flag{Type: Int, Name: flagkey.FnExecutionTimeout, Aliases: []string{"ft"}, Usage: "Time duration to wait for the response while executing the function", DefaultValue: 60}
FnLogPodFlag = Flag{Type: String, Name: flagkey.FnLogPod, Usage: "Function pod name (use the latest pod name if unspecified)"} FnLogPod = Flag{Type: String, Name: flagkey.FnLogPod, Usage: "Function pod name (use the latest pod name if unspecified)"}
FnLogFollowFlag = Flag{Type: Bool, Name: flagkey.FnLogFollow, Short: "f", Usage: "Specify if the logs should be streamed"} FnLogFollow = Flag{Type: Bool, Name: flagkey.FnLogFollow, Short: "f", Usage: "Specify if the logs should be streamed"}
FnLogDetailFlag = Flag{Type: Bool, Name: flagkey.FnLogDetail, Short: "d", Usage: "Display detailed information"} FnLogDetail = Flag{Type: Bool, Name: flagkey.FnLogDetail, Short: "d", Usage: "Display detailed information"}
FnLogDBTypeFlag = Flag{Type: String, Name: flagkey.FnLogDBType, Usage: "Log database type, e.g. influxdb (currently only influxdb is supported)", DefaultValue: "influxdb"} FnLogDBType = Flag{Type: String, Name: flagkey.FnLogDBType, Usage: "Log database type, e.g. influxdb (currently only influxdb is supported)", DefaultValue: "influxdb"}
FnLogReverseQueryFlag = Flag{Type: Bool, Name: flagkey.FnLogReverseQuery, Short: "r", Usage: "Specify the log reverse query base on time, it will be invalid if the 'follow' flag is specified"} FnLogReverseQuery = Flag{Type: Bool, Name: flagkey.FnLogReverseQuery, Short: "r", Usage: "Specify the log reverse query base on time, it will be invalid if the 'follow' flag is specified"}
FnLogCountFlag = Flag{Type: Int, Name: flagkey.FnLogCount, Usage: "Get N most recent log records", DefaultValue: 20} FnLogCount = Flag{Type: Int, Name: flagkey.FnLogCount, Usage: "Get N most recent log records", DefaultValue: 20}
FnTestBodyFlag = Flag{Type: String, Name: flagkey.FnTestBody, Short: "b", Usage: "Request body"} FnTestBody = Flag{Type: String, Name: flagkey.FnTestBody, Short: "b", Usage: "Request body"}
FnTestTimeoutFlag = Flag{Type: Duration, Name: flagkey.FnTestTimeout, Short: "t", Usage: "Length of time to wait for the response. If set to zero or negative number, no timeout is set", DefaultValue: 30 * time.Second} FnTestTimeout = Flag{Type: Duration, Name: flagkey.FnTestTimeout, Short: "t", Usage: "Length of time to wait for the response. If set to zero or negative number, no timeout is set", DefaultValue: 30 * time.Second}
FnTestHeaderFlag = Flag{Type: StringSlice, Name: flagkey.FnTestHeader, Short: "H", Usage: "Request headers"} FnTestHeader = Flag{Type: StringSlice, Name: flagkey.FnTestHeader, Short: "H", Usage: "Request headers"}
FnTestQueryFlag = Flag{Type: StringSlice, Name: flagkey.FnTestQuery, Short: "q", Usage: "Request query parameters: -q key1=value1 -q key2=value2"} FnTestQuery = Flag{Type: StringSlice, Name: flagkey.FnTestQuery, Short: "q", Usage: "Request query parameters: -q key1=value1 -q key2=value2"}
HtNameFlag = Flag{Type: String, Name: flagkey.HtName, Usage: "HTTP trigger name"} HtName = Flag{Type: String, Name: flagkey.HtName, Usage: "HTTP trigger name"}
HtMethodFlag = Flag{Type: String, Name: flagkey.HtMethod, Usage: "HTTP Method: GET|POST|PUT|DELETE|HEAD", DefaultValue: http.MethodGet} HtMethod = Flag{Type: String, Name: flagkey.HtMethod, Usage: "HTTP Method: GET|POST|PUT|DELETE|HEAD", DefaultValue: http.MethodGet}
HtUrlFlag = Flag{Type: String, Name: flagkey.HtUrl, Usage: "URL pattern (See gorilla/mux supported patterns)"} HtUrl = Flag{Type: String, Name: flagkey.HtUrl, Usage: "URL pattern (See gorilla/mux supported patterns)"}
HtHostFlag = Flag{Type: String, Name: flagkey.HtHost, Usage: "Use --ingressrule instead", Deprecated: true, Substitute: flagkey.HtIngressRule} HtHost = Flag{Type: String, Name: flagkey.HtHost, Usage: "Use --ingressrule instead", Deprecated: true, Substitute: flagkey.HtIngressRule}
HtIngressFlag = Flag{Type: Bool, Name: flagkey.HtIngress, Usage: "Creates ingress with same URL"} HtIngress = Flag{Type: Bool, Name: flagkey.HtIngress, Usage: "Creates ingress with same URL"}
HtIngressRuleFlag = Flag{Type: String, Name: flagkey.HtIngressRule, Usage: "Host for Ingress rule: --ingressrule host=path (the format of host/path depends on what ingress controller you used)"} HtIngressRule = Flag{Type: String, Name: flagkey.HtIngressRule, Usage: "Host for Ingress rule: --ingressrule host=path (the format of host/path depends on what ingress controller you used)"}
HtIngressAnnotationFlag = Flag{Type: StringSlice, Name: flagkey.HtIngressAnnotation, Usage: "Annotation for Ingress: --ingressannotation key=value (the format of annotation depends on what ingress controller you used)"} HtIngressAnnotation = Flag{Type: StringSlice, Name: flagkey.HtIngressAnnotation, Usage: "Annotation for Ingress: --ingressannotation key=value (the format of annotation depends on what ingress controller you used)"}
HtIngressTLSFlag = Flag{Type: String, Name: flagkey.HtIngressTLS, Usage: "Name of the Secret contains TLS key and crt for Ingress (the usability of TLS features depends on what ingress controller you used)"} HtIngressTLS = Flag{Type: String, Name: flagkey.HtIngressTLS, Usage: "Name of the Secret contains TLS key and crt for Ingress (the usability of TLS features depends on what ingress controller you used)"}
HtFnNameFlag = Flag{Type: StringSlice, Name: flagkey.HtFnName, Usage: "Name(s) of the function for this trigger. (If 2 functions are supplied with this flag, traffic gets routed to them based on weights supplied with --weight flag.)"} HtFnName = Flag{Type: StringSlice, Name: flagkey.HtFnName, Usage: "Name(s) of the function for this trigger. (If 2 functions are supplied with this flag, traffic gets routed to them based on weights supplied with --weight flag.)"}
HtFnWeightFlag = Flag{Type: IntSlice, Name: flagkey.HtFnWeight, Usage: "Weight for each function supplied with --function flag, in the same order. Used for canary deployment"} HtFnWeight = Flag{Type: IntSlice, Name: flagkey.HtFnWeight, Usage: "Weight for each function supplied with --function flag, in the same order. Used for canary deployment"}
HtFnFilterFlag = Flag{Type: String, Name: flagkey.HtFilter, Usage: "Name of the function for trigger(s)"} HtFnFilter = Flag{Type: String, Name: flagkey.HtFilter, Usage: "Name of the function for trigger(s)"}
TtNameFlag = Flag{Type: String, Name: flagkey.TtName, Usage: "Time Trigger name"} TtName = Flag{Type: String, Name: flagkey.TtName, Usage: "Time Trigger name"}
TtCronFlag = Flag{Type: String, Name: flagkey.TtCron, Usage: "Time trigger cron spec with each asterisk representing respectively second, minute, hour, the day of the month, month and day of the week. Also supports readable formats like '@every 5m', '@hourly'"} TtCron = Flag{Type: String, Name: flagkey.TtCron, Usage: "Time trigger cron spec with each asterisk representing respectively second, minute, hour, the day of the month, month and day of the week. Also supports readable formats like '@every 5m', '@hourly'"}
TtFnNameFlag = Flag{Type: String, Name: flagkey.TtFnName, Usage: "Function name"} TtFnName = Flag{Type: String, Name: flagkey.TtFnName, Usage: "Function name"}
TtRoundFlag = Flag{Type: Int, Name: flagkey.TtRound, Usage: "Get next N rounds of invocation time", DefaultValue: 1} TtRound = Flag{Type: Int, Name: flagkey.TtRound, Usage: "Get next N rounds of invocation time", DefaultValue: 1}
MqtNameFlag = Flag{Type: String, Name: flagkey.MqtName, Usage: "Message queue trigger name"} MqtName = Flag{Type: String, Name: flagkey.MqtName, Usage: "Message queue trigger name"}
MqtFnNameFlag = Flag{Type: String, Name: flagkey.MqtFnName, Usage: "Function name"} MqtFnName = Flag{Type: String, Name: flagkey.MqtFnName, Usage: "Function name"}
MqtMQTypeFlag = Flag{Type: String, Name: flagkey.MqtMQType, Usage: "Message queue type, e.g. nats-streaming, azure-storage-queue", DefaultValue: "nats-streaming"} MqtMQType = Flag{Type: String, Name: flagkey.MqtMQType, Usage: "Message queue type, e.g. nats-streaming, azure-storage-queue", DefaultValue: "nats-streaming"}
MqtTopicFlag = Flag{Type: String, Name: flagkey.MqtTopic, Usage: "Message queue Topic the trigger listens on"} MqtTopic = Flag{Type: String, Name: flagkey.MqtTopic, Usage: "Message queue Topic the trigger listens on"}
MqtRespTopicFlag = Flag{Type: String, Name: flagkey.MqtRespTopic, Usage: "Topic that the function response is sent on (response discarded if unspecified)"} MqtRespTopic = Flag{Type: String, Name: flagkey.MqtRespTopic, Usage: "Topic that the function response is sent on (response discarded if unspecified)"}
MqtErrorTopicFlag = Flag{Type: String, Name: flagkey.MqtErrorTopic, Usage: "Topic that the function error messages are sent to (errors discarded if unspecified"} MqtErrorTopic = Flag{Type: String, Name: flagkey.MqtErrorTopic, Usage: "Topic that the function error messages are sent to (errors discarded if unspecified"}
MqtMaxRetriesFlag = Flag{Type: Int, Name: flagkey.MqtMaxRetries, Usage: "Maximum number of times the function will be retried upon failure", DefaultValue: 0} MqtMaxRetries = Flag{Type: Int, Name: flagkey.MqtMaxRetries, Usage: "Maximum number of times the function will be retried upon failure", DefaultValue: 0}
MqtMsgContentTypeFlag = Flag{Type: String, Name: flagkey.MqtMsgContentType, Short: "c", Usage: "Content type of messages that publish to the topic", DefaultValue: "application/json"} MqtMsgContentType = Flag{Type: String, Name: flagkey.MqtMsgContentType, Short: "c", Usage: "Content type of messages that publish to the topic", DefaultValue: "application/json"}
RecorderNameFlag = Flag{Type: String, Name: flagkey.RecorderName, Usage: "Recorder name"} RecorderName = Flag{Type: String, Name: flagkey.RecorderName, Usage: "Recorder name"}
RecorderFnFlag = Flag{Type: String, Name: flagkey.RecorderFn, Usage: "Record Function name(s): --function=fnA"} RecorderFn = Flag{Type: String, Name: flagkey.RecorderFn, Usage: "Record Function name(s): --function=fnA"}
RecorderTriggersFlag = Flag{Type: StringSlice, Name: flagkey.RecorderTriggers, Usage: "Record Trigger name(s): --trigger=trigger1,trigger2,trigger3"} RecorderTriggers = Flag{Type: StringSlice, Name: flagkey.RecorderTriggers, Usage: "Record Trigger name(s): --trigger=trigger1,trigger2,trigger3"}
RecorderRetentionPolicyFlag = Flag{Type: String, Name: flagkey.RecorderRetentionPolicy, Usage: "Retention policy (number of days)"} RecorderRetentionPolicy = Flag{Type: String, Name: flagkey.RecorderRetentionPolicy, Usage: "Retention policy (number of days)"}
RecorderEvictionPolicyFlag = Flag{Type: String, Name: flagkey.RecorderEvictionPolcy, Usage: "Eviction policy (default LRU)"} RecorderEvictionPolicy = Flag{Type: String, Name: flagkey.RecorderEvictionPolcy, Usage: "Eviction policy (default LRU)"}
RecorderEnabledFlag = Flag{Type: Bool, Name: flagkey.RecorderEnabled, Usage: "Enable recorder"} RecorderEnabled = Flag{Type: Bool, Name: flagkey.RecorderEnabled, Usage: "Enable recorder"}
RecorderDisabledFlag = Flag{Type: Bool, Name: flagkey.RecorderDisabled, Usage: "Disable recorder"} RecorderDisabled = Flag{Type: Bool, Name: flagkey.RecorderDisabled, Usage: "Disable recorder"}
RecordsFilterTimeFromFlag = Flag{Type: String, Name: flagkey.RecordsFilterTimeFrom, Usage: "Filter records by time interval; specify start of interval"} RecordsFilterTimeFrom = Flag{Type: String, Name: flagkey.RecordsFilterTimeFrom, Usage: "Filter records by time interval; specify start of interval"}
RecordsFilterTimeToFlag = Flag{Type: String, Name: flagkey.RecordsFilterTimeTo, Usage: "Filter records by time interval; specify end of interval"} RecordsFilterTimeTo = Flag{Type: String, Name: flagkey.RecordsFilterTimeTo, Usage: "Filter records by time interval; specify end of interval"}
RecordsFilterFunctionFlag = Flag{Type: String, Name: flagkey.RecordsFilterFunction, Usage: "Filter records by function"} RecordsFilterFunction = Flag{Type: String, Name: flagkey.RecordsFilterFunction, Usage: "Filter records by function"}
RecordsFilterTriggerFlag = Flag{Type: String, Name: flagkey.RecordsFilterTrigger, Usage: "Filter records by trigger"} RecordsFilterTrigger = Flag{Type: String, Name: flagkey.RecordsFilterTrigger, Usage: "Filter records by trigger"}
RecordsVerbosityFlag = Flag{Type: Bool, Name: flagkey.RecordsVerbosity, Usage: "Toggle verbosity -- view more detailed requests/responses"} RecordsVerbosity = Flag{Type: Bool, Name: flagkey.RecordsVerbosity, Usage: "Toggle verbosity -- view more detailed requests/responses"}
RecordsVvFlag = Flag{Type: Bool, Name: flagkey.RecordsVv, Usage: "Toggle verbosity -- view raw requests/responses"} RecordsVv = Flag{Type: Bool, Name: flagkey.RecordsVv, Usage: "Toggle verbosity -- view raw requests/responses"}
RecordsReqIDFlag = Flag{Type: String, Name: flagkey.RecordsReqID, Usage: "Replay a particular request by providing the reqUID (to view reqUIDs, do 'fission records view')"} RecordsReqID = Flag{Type: String, Name: flagkey.RecordsReqID, Usage: "Replay a particular request by providing the reqUID (to view reqUIDs, do 'fission records view')"}
EnvNameFlag = Flag{Type: String, Name: flagkey.EnvName, Usage: "Environment name"} EnvName = Flag{Type: String, Name: flagkey.EnvName, Usage: "Environment name"}
EnvPoolsizeFlag = Flag{Type: Int, Name: flagkey.EnvPoolsize, Usage: "Size of the pool", DefaultValue: 3} EnvPoolsize = Flag{Type: Int, Name: flagkey.EnvPoolsize, Usage: "Size of the pool", DefaultValue: 3}
EnvImageFlag = Flag{Type: String, Name: flagkey.EnvImage, Usage: "Environment image URL"} EnvImage = Flag{Type: String, Name: flagkey.EnvImage, Usage: "Environment image URL"}
EnvBuilderImageFlag = Flag{Type: String, Name: flagkey.EnvBuilderImage, Usage: "Environment builder image URL"} EnvBuilderImage = Flag{Type: String, Name: flagkey.EnvBuilderImage, Usage: "Environment builder image URL"}
EnvBuildCmdFlag = Flag{Type: String, Name: flagkey.EnvBuildcommand, Usage: "Build command for environment builder to build source package"} EnvBuildCmd = Flag{Type: String, Name: flagkey.EnvBuildcommand, Usage: "Build command for environment builder to build source package"}
EnvKeepArchiveFlag = Flag{Type: Bool, Name: flagkey.EnvKeeparchive, Usage: "Keep the archive instead of extracting it into a directory"} EnvKeepArchive = Flag{Type: Bool, Name: flagkey.EnvKeeparchive, Usage: "Keep the archive instead of extracting it into a directory"}
EnvExternalNetworkFlag = Flag{Type: Bool, Name: flagkey.EnvExternalNetwork, Usage: "Allow environment access external network when istio feature enabled"} EnvExternalNetwork = Flag{Type: Bool, Name: flagkey.EnvExternalNetwork, Usage: "Allow environment access external network when istio feature enabled"}
EnvTerminationGracePeriodFlag = Flag{Type: Int, Name: flagkey.EnvGracePeriod, Aliases: []string{"period"}, Usage: "Grace time (in seconds) for pod to perform connection draining before termination", DefaultValue: 360} EnvTerminationGracePeriod = Flag{Type: Int, Name: flagkey.EnvGracePeriod, Aliases: []string{"period"}, Usage: "Grace time (in seconds) for pod to perform connection draining before termination", DefaultValue: 360}
EnvVersionFlag = Flag{Type: Int, Name: flagkey.EnvVersion, Usage: "Environment API version (1 means v1 interface)", DefaultValue: 1} EnvVersion = Flag{Type: Int, Name: flagkey.EnvVersion, Usage: "Environment API version (1 means v1 interface)", DefaultValue: 1}
KwNameFlag = Flag{Type: String, Name: flagkey.KwName, Usage: "Watch name"} KwName = Flag{Type: String, Name: flagkey.KwName, Usage: "Watch name"}
KwFnNameFlag = Flag{Type: String, Name: flagkey.KwFnName, Usage: "Function name"} KwFnName = Flag{Type: String, Name: flagkey.KwFnName, Usage: "Function name"}
KwNamespaceFlag = Flag{Type: String, Name: flagkey.KwNamespace, Usage: "Namespace of resource to watch"} KwNamespace = Flag{Type: String, Name: flagkey.KwNamespace, Aliases: []string{"ns"}, Usage: "Namespace of resource to watch", DefaultValue: metav1.NamespaceDefault}
KwObjTypeFlag = Flag{Type: String, Name: flagkey.KwObjType, Usage: "Type of resource to watch (Pod, Service, etc.)"} KwObjType = Flag{Type: String, Name: flagkey.KwObjType, Usage: "Type of resource to watch (Pod, Service, etc.)", DefaultValue: "pod"}
KwLabelsFlag = Flag{Type: String, Name: flagkey.KwLabels, Usage: "Label selector of the form a=b,c=d"} KwLabels = Flag{Type: String, Name: flagkey.KwLabels, Usage: "Label selector of the form a=b,c=d"}
PkgNameFlag = Flag{Type: String, Name: flagkey.PkgName, Usage: "Package name"} PkgName = Flag{Type: String, Name: flagkey.PkgName, Usage: "Package name"}
PkgForceFlag = Flag{Type: Bool, Name: flagkey.PkgForce, Short: "f", Usage: "Force update a package even if it is used by one or more functions"} PkgForce = Flag{Type: Bool, Name: flagkey.PkgForce, Short: "f", Usage: "Force update a package even if it is used by one or more functions"}
PkgEnvironmentFlag = Flag{Type: String, Name: flagkey.PkgEnvironment, Usage: "Environment name"} PkgEnvironment = Flag{Type: String, Name: flagkey.PkgEnvironment, Usage: "Environment name"}
PkgKeepURLFlag = Flag{Type: Bool, Name: flagkey.PkgKeepURL, Aliases: []string{"keepurl"}, Usage: "Keep the providing URL in archive instead of downloading file from it. (If set, no checksum will be generated for file integrity check. You must ensure the file won't be changed.)"} PkgKeepURL = Flag{Type: Bool, Name: flagkey.PkgKeepURL, Aliases: []string{"keepurl"}, Usage: "Keep the providing URL in archive instead of downloading file from it. (If set, no checksum will be generated for file integrity check. You must ensure the file won't be changed.)"}
PkgBuildCmdFlag = Flag{Type: String, Name: flagkey.PkgBuildCmd, Usage: "Build command for builder to run with"} PkgBuildCmd = Flag{Type: String, Name: flagkey.PkgBuildCmd, Usage: "Build command for builder to run with"}
PkgOutputFlag = Flag{Type: String, Name: flagkey.PkgOutput, Short: "o", Usage: "Output filename to save archive content"} PkgOutput = Flag{Type: String, Name: flagkey.PkgOutput, Short: "o", Usage: "Output filename to save archive content"}
PkgStatusFlag = Flag{Type: String, Name: flagkey.PkgStatus, Usage: `Filter packages by status`} PkgStatus = Flag{Type: String, Name: flagkey.PkgStatus, Usage: `Filter packages by status`}
PkgOrphanFlag = Flag{Type: Bool, Name: flagkey.PkgOrphan, Usage: "Orphan packages that are not referenced by any function"} PkgOrphan = Flag{Type: Bool, Name: flagkey.PkgOrphan, Usage: "Orphan packages that are not referenced by any function"}
PkgDeployArchiveFlag = Flag{Type: StringSlice, Name: flagkey.PkgDeployArchive, Aliases: []string{"deploy"}, Usage: "Local path or URL for binary archive"} PkgDeployArchive = Flag{Type: StringSlice, Name: flagkey.PkgDeployArchive, Aliases: []string{"deploy"}, Usage: "Local path or URL for binary archive"}
PkgSrcArchiveFlag = Flag{Type: StringSlice, Name: flagkey.PkgSrcArchive, Aliases: []string{"source", "src"}, Usage: "Local path or URL for source archive"} PkgSrcArchive = Flag{Type: StringSlice, Name: flagkey.PkgSrcArchive, Aliases: []string{"source", "src"}, Usage: "Local path or URL for source archive"}
SpecSaveFlag = Flag{Type: Bool, Name: flagkey.SpecSave, Usage: "Save to the spec directory instead of creating on cluster"} SpecSave = Flag{Type: Bool, Name: flagkey.SpecSave, Usage: "Save to the spec directory instead of creating on cluster"}
SpecDirFlag = Flag{Type: String, Name: flagkey.SpecDir, Usage: "Directory to store specs, defaults to ./specs"} SpecDir = Flag{Type: String, Name: flagkey.SpecDir, Usage: "Directory to store specs, defaults to ./specs"}
SpecNameFlag = Flag{Type: String, Name: flagkey.SpecName, Usage: "Name for the app, applied to resources as a Kubernetes annotation"} SpecName = Flag{Type: String, Name: flagkey.SpecName, Usage: "Name for the app, applied to resources as a Kubernetes annotation"}
SpecDeployIDFlag = Flag{Type: String, Name: flagkey.SpecDeployID, Aliases: []string{"id"}, Usage: "Deployment ID for the spec deployment config"} SpecDeployID = Flag{Type: String, Name: flagkey.SpecDeployID, Aliases: []string{"id"}, Usage: "Deployment ID for the spec deployment config"}
SpecWaitFlag = Flag{Type: Bool, Name: flagkey.SpecWait, Usage: "Wait for package builds"} SpecWait = Flag{Type: Bool, Name: flagkey.SpecWait, Usage: "Wait for package builds"}
SpecWatchFlag = Flag{Type: Bool, Name: flagkey.SpecWatch, Usage: "Watch local files for change, and re-apply specs as necessary"} SpecWatch = Flag{Type: Bool, Name: flagkey.SpecWatch, Usage: "Watch local files for change, and re-apply specs as necessary"}
SpecDeleteFlag = Flag{Type: Bool, Name: flagkey.SpecDelete, Usage: "Allow apply to delete resources that no longer exist in the specification"} SpecDelete = Flag{Type: Bool, Name: flagkey.SpecDelete, Usage: "Allow apply to delete resources that no longer exist in the specification"}
SupportOutputFlag = Flag{Type: String, Name: flagkey.SupportOutput, Short: "o", Usage: "Output directory to save dump archive/files", DefaultValue: flagkey.DefaultSpecOutputDir} SupportOutput = Flag{Type: String, Name: flagkey.SupportOutput, Short: "o", Usage: "Output directory to save dump archive/files", DefaultValue: flagkey.DefaultSpecOutputDir}
SupportNoZipFlag = Flag{Type: Bool, Name: flagkey.SupportNoZip, Usage: "Save dump information into multiple files instead of single zip file"} SupportNoZip = Flag{Type: Bool, Name: flagkey.SupportNoZip, Usage: "Save dump information into multiple files instead of single zip file"}
CanaryNameFlag = Flag{Type: String, Name: flagkey.CanaryName, Usage: "Name for the canary config"} CanaryName = Flag{Type: String, Name: flagkey.CanaryName, Usage: "Name for the canary config"}
CanaryTriggerNameFlag = Flag{Type: String, Name: flagkey.CanaryHTTPTriggerName, Usage: "Http trigger that this config references"} CanaryTriggerName = Flag{Type: String, Name: flagkey.CanaryHTTPTriggerName, Usage: "Http trigger that this config references"}
CanaryNewFuncFlag = Flag{Type: String, Name: flagkey.CanaryNewFunc, Aliases: []string{"newfn"}, Usage: "New version of the function"} CanaryNewFunc = Flag{Type: String, Name: flagkey.CanaryNewFunc, Aliases: []string{"newfn"}, Usage: "New version of the function"}
CanaryOldFuncFlag = Flag{Type: String, Name: flagkey.CanaryOldFunc, Aliases: []string{"oldfn"}, Usage: "Old stable version of the function"} CanaryOldFunc = Flag{Type: String, Name: flagkey.CanaryOldFunc, Aliases: []string{"oldfn"}, Usage: "Old stable version of the function"}
CanaryWeightIncrementFlag = Flag{Type: Int, Name: flagkey.CanaryWeightIncrement, Aliases: []string{"step"}, Usage: "Weight increment step for function", DefaultValue: 20} CanaryWeightIncrement = Flag{Type: Int, Name: flagkey.CanaryWeightIncrement, Aliases: []string{"step"}, Usage: "Weight increment step for function", DefaultValue: 20}
CanaryIncrementIntervalFlag = Flag{Type: String, Name: flagkey.CanaryIncrementInterval, Aliases: []string{"internal"}, Usage: "Weight increment interval, string representation of time.Duration, ex : 1m, 2h, 2d", DefaultValue: "2m"} CanaryIncrementInterval = Flag{Type: String, Name: flagkey.CanaryIncrementInterval, Aliases: []string{"internal"}, Usage: "Weight increment interval, string representation of time.Duration, ex : 1m, 2h, 2d", DefaultValue: "2m"}
CanaryFailureThresholdFlag = Flag{Type: Int, Name: flagkey.CanaryFailureThreshold, Aliases: []string{"threshold"}, Usage: "Threshold in percentage beyond which the new version of the function is considered unstable", DefaultValue: 10} CanaryFailureThreshold = Flag{Type: Int, Name: flagkey.CanaryFailureThreshold, Aliases: []string{"threshold"}, Usage: "Threshold in percentage beyond which the new version of the function is considered unstable", DefaultValue: 10}
) )
+1 -1
View File
@@ -116,7 +116,7 @@ const (
KwName = resourceName KwName = resourceName
KwFnName = "function" KwFnName = "function"
KwNamespace = "ns" KwNamespace = "namespace"
KwObjType = "type" KwObjType = "type"
KwLabels = "labels" KwLabels = "labels"
+13 -30
View File
@@ -195,8 +195,8 @@ func GetVersion(client *client.Client) info.Versions {
return versions return versions
} }
func GetServer(flags cli.Input) (c *client.Client, err error) { func GetServer(input cli.Input) (c *client.Client, err error) {
serverUrl := flags.GlobalString(flagkey.Server) serverUrl := input.GlobalString(flagkey.Server)
if len(serverUrl) == 0 { if len(serverUrl) == 0 {
// starts local portforwarder etc. // starts local portforwarder etc.
serverUrl, err = GetApplicationUrl("application=fission-api") serverUrl, err = GetApplicationUrl("application=fission-api")
@@ -215,7 +215,7 @@ func GetServer(flags cli.Input) (c *client.Client, err error) {
return client.MakeClient(serverUrl), nil return client.MakeClient(serverUrl), nil
} }
func GetResourceReqs(flags cli.Input, resReqs *v1.ResourceRequirements) (*v1.ResourceRequirements, error) { func GetResourceReqs(input cli.Input, resReqs *v1.ResourceRequirements) (*v1.ResourceRequirements, error) {
r := &v1.ResourceRequirements{} r := &v1.ResourceRequirements{}
if resReqs != nil { if resReqs != nil {
@@ -233,8 +233,8 @@ func GetResourceReqs(flags cli.Input, resReqs *v1.ResourceRequirements) (*v1.Res
e := utils.MultiErrorWithFormat() e := utils.MultiErrorWithFormat()
if flags.IsSet(flagkey.RuntimeMincpu) { if input.IsSet(flagkey.RuntimeMincpu) {
mincpu := flags.Int(flagkey.RuntimeMincpu) mincpu := input.Int(flagkey.RuntimeMincpu)
cpuRequest, err := resource.ParseQuantity(strconv.Itoa(mincpu) + "m") cpuRequest, err := resource.ParseQuantity(strconv.Itoa(mincpu) + "m")
if err != nil { if err != nil {
e = multierror.Append(e, errors.Wrap(err, "Failed to parse mincpu")) e = multierror.Append(e, errors.Wrap(err, "Failed to parse mincpu"))
@@ -242,8 +242,8 @@ func GetResourceReqs(flags cli.Input, resReqs *v1.ResourceRequirements) (*v1.Res
r.Requests[v1.ResourceCPU] = cpuRequest r.Requests[v1.ResourceCPU] = cpuRequest
} }
if flags.IsSet(flagkey.RuntimeMinmemory) { if input.IsSet(flagkey.RuntimeMinmemory) {
minmem := flags.Int(flagkey.RuntimeMinmemory) minmem := input.Int(flagkey.RuntimeMinmemory)
memRequest, err := resource.ParseQuantity(strconv.Itoa(minmem) + "Mi") memRequest, err := resource.ParseQuantity(strconv.Itoa(minmem) + "Mi")
if err != nil { if err != nil {
e = multierror.Append(e, errors.Wrap(err, "Failed to parse minmemory")) e = multierror.Append(e, errors.Wrap(err, "Failed to parse minmemory"))
@@ -251,8 +251,8 @@ func GetResourceReqs(flags cli.Input, resReqs *v1.ResourceRequirements) (*v1.Res
r.Requests[v1.ResourceMemory] = memRequest r.Requests[v1.ResourceMemory] = memRequest
} }
if flags.IsSet(flagkey.RuntimeMaxcpu) { if input.IsSet(flagkey.RuntimeMaxcpu) {
maxcpu := flags.Int(flagkey.RuntimeMaxcpu) maxcpu := input.Int(flagkey.RuntimeMaxcpu)
cpuLimit, err := resource.ParseQuantity(strconv.Itoa(maxcpu) + "m") cpuLimit, err := resource.ParseQuantity(strconv.Itoa(maxcpu) + "m")
if err != nil { if err != nil {
e = multierror.Append(e, errors.Wrap(err, "Failed to parse maxcpu")) e = multierror.Append(e, errors.Wrap(err, "Failed to parse maxcpu"))
@@ -260,8 +260,8 @@ func GetResourceReqs(flags cli.Input, resReqs *v1.ResourceRequirements) (*v1.Res
r.Limits[v1.ResourceCPU] = cpuLimit r.Limits[v1.ResourceCPU] = cpuLimit
} }
if flags.IsSet(flagkey.RuntimeMaxmemory) { if input.IsSet(flagkey.RuntimeMaxmemory) {
maxmem := flags.Int(flagkey.RuntimeMaxmemory) maxmem := input.Int(flagkey.RuntimeMaxmemory)
memLimit, err := resource.ParseQuantity(strconv.Itoa(maxmem) + "Mi") memLimit, err := resource.ParseQuantity(strconv.Itoa(maxmem) + "Mi")
if err != nil { if err != nil {
e = multierror.Append(e, errors.Wrap(err, "Failed to parse maxmemory")) e = multierror.Append(e, errors.Wrap(err, "Failed to parse maxmemory"))
@@ -297,27 +297,10 @@ func GetResourceReqs(flags cli.Input, resReqs *v1.ResourceRequirements) (*v1.Res
}, nil }, nil
} }
func GetSpecDir(flags cli.Input) string { func GetSpecDir(input cli.Input) string {
specDir := flags.String(flagkey.SpecDir) specDir := input.String(flagkey.SpecDir)
if len(specDir) == 0 { if len(specDir) == 0 {
specDir = "specs" specDir = "specs"
} }
return specDir return specDir
} }
// GetMetadata returns a pointer to ObjectMeta that is populated with resource name and namespace given by the user.
func GetMetadata(nameFlagText string, namespaceFlagText string, flags cli.Input) (*metav1.ObjectMeta, error) {
name := flags.String(nameFlagText)
if len(name) == 0 {
return nil, errors.Errorf("need a resource name, use --%v", nameFlagText)
}
ns := flags.String(namespaceFlagText)
m := &metav1.ObjectMeta{
Name: name,
Namespace: ns,
}
return m, nil
}
@@ -65,5 +65,8 @@ if [[ "$response" != "$expectedRespOutput" ]]; then
exit 1 exit 1
fi fi
log "Deleting message queue trigger"
fission mqtrigger delete --name $mqt
log "Subscriber received expected response: $response" log "Subscriber received expected response: $response"
log "Test PASSED" log "Test PASSED"
@@ -73,4 +73,8 @@ if [[ "$response" != "$expectedRespOutput" ]]; then
else else
log "Responses match." log "Responses match."
fi fi
log "Deleting message queue trigger"
fission mqtrigger delete --name $mqt
log "Test PASSED" log "Test PASSED"
+5 -5
View File
@@ -36,7 +36,7 @@ create_archive() {
create_package() { create_package() {
log "Creating package" log "Creating package"
pkg=$(fission package create --deploy "$tmp_dir/test-deploy-pkg.zip" --env $env| cut -f2 -d' '| tr -d \') fission package create --name $1 --deploy "$tmp_dir/test-deploy-pkg.zip" --env $env
} }
delete_package() { delete_package() {
@@ -74,14 +74,14 @@ main() {
log "created archive test-deploy-pkg.zip" log "created archive test-deploy-pkg.zip"
# create packages with the huge archive # create packages with the huge archive
create_package pkg_1=$(generate_test_id)
pkg_1=$pkg create_package $pkg_1
get_archive_url_from_package $pkg_1 get_archive_url_from_package $pkg_1
url_1=$url url_1=$url
log "pkg: $pkg_1, archive_url : $url_1" log "pkg: $pkg_1, archive_url : $url_1"
create_package pkg_2=$(generate_test_id)
pkg_2=$pkg create_package $pkg_2
get_archive_url_from_package $pkg_2 get_archive_url_from_package $pkg_2
url_2=$url url_2=$url
log "pkg: $pkg_2, archive_url : $url_2" log "pkg: $pkg_2, archive_url : $url_2"
+4 -2
View File
@@ -33,7 +33,8 @@ fission env create --name $env --image $GO_RUNTIME_IMAGE --builder $GO_BUILDER_I
timeout 90 bash -c "wait_for_builder $env" timeout 90 bash -c "wait_for_builder $env"
pkgName=$(fission package create --src hello.go --env $env| cut -f2 -d' '| tr -d \') pkgName=$(generate_test_id)
fission package create --name $pkgName --src hello.go --env $env
# wait for build to finish at most 90s # wait for build to finish at most 90s
timeout 90 bash -c "waitBuild $pkgName" timeout 90 bash -c "waitBuild $pkgName"
@@ -58,7 +59,8 @@ timeout 60 bash -c "test_fn $fn_nd 'Hello'"
# Create zip file without top level directory (module-example) # Create zip file without top level directory (module-example)
cd module-example && zip -r $tmp_dir/module.zip * cd module-example && zip -r $tmp_dir/module.zip *
pkgName=$(fission package create --src $tmp_dir/module.zip --env $env| cut -f2 -d' '| tr -d \') pkgName=$(generate_test_id)
fission package create --name $pkgName --src $tmp_dir/module.zip --env $env
# wait for build to finish at most 90s # wait for build to finish at most 90s
timeout 90 bash -c "waitBuild $pkgName" timeout 90 bash -c "waitBuild $pkgName"
@@ -37,7 +37,8 @@ fission env create --name $env --image $JVM_RUNTIME_IMAGE --version 2 --keeparch
timeout 90 bash -c "wait_for_builder $env" timeout 90 bash -c "wait_for_builder $env"
log "Creating package from the source archive" log "Creating package from the source archive"
pkg_name=`fission package create --sourcearchive $tmp_dir/java-src-pkg.zip --env $env|cut -d' ' -f 2|cut -d"'" -f 2` pkg_name=$(generate_test_id)
fission package create --name $pkg_name --sourcearchive $tmp_dir/java-src-pkg.zip --env $env
log "Created package $pkg_name" log "Created package $pkg_name"
log "Checking the status of package" log "Checking the status of package"
@@ -29,7 +29,6 @@ fn2=test-python-env-2-$TEST_ID
fn3=test-python-env-3-$TEST_ID fn3=test-python-env-3-$TEST_ID
fn4=test-python-env-4-$TEST_ID fn4=test-python-env-4-$TEST_ID
fn5=test-python-env-5-$TEST_ID fn5=test-python-env-5-$TEST_ID
pkg=
log "Creating v1api environment ..." log "Creating v1api environment ..."
@@ -50,7 +49,8 @@ log "Creating package ..."
pushd $ROOT/test/tests/test_environments/python_src/ pushd $ROOT/test/tests/test_environments/python_src/
zip -r $tmp_dir/src-pkg.zip * zip -r $tmp_dir/src-pkg.zip *
popd popd
pkg=$(fission package create --src $tmp_dir/src-pkg.zip --env $env_v2api | cut -f2 -d' '| tr -d \') pkg=$(generate_test_id)
fission package create --name $pkg --src $tmp_dir/src-pkg.zip --env $env_v2api
timeout 60s bash -c "waitBuild $pkg" timeout 60s bash -c "waitBuild $pkg"
@@ -33,7 +33,8 @@ fission env create --name $env --image $TS_RUNTIME_IMAGE --version 2 --period 5
zip -r half_plus_two.zip ./half_plus_two zip -r half_plus_two.zip ./half_plus_two
pkgName=$(fission package create --deploy half_plus_two.zip --env $env| cut -f2 -d' '| tr -d \') pkgName=$(generate_test_id)
fission package create --name $pkgName --deploy half_plus_two.zip --env $env
# wait for build to finish at most 90s # wait for build to finish at most 90s
timeout 90 bash -c "waitBuild $pkgName" timeout 90 bash -c "waitBuild $pkgName"
+8 -4
View File
@@ -59,7 +59,8 @@ timeout 180s bash -c "wait_for_builder $env"
# 1) Multiple source files (multiple inputs, Using * expression, from a directory) # 1) Multiple source files (multiple inputs, Using * expression, from a directory)
# Currently only * expression implemented as a test # Currently only * expression implemented as a test
pushd $ROOT/examples/python/ pushd $ROOT/examples/python/
pkg1=$(fission package create --src "sourcepkg/*" --env $env --buildcmd "./build.sh"| cut -f2 -d' '| tr -d \') pkg1="pkg1-${TEST_ID}"
fission package create --name $pkg1 --src "sourcepkg/*" --env $env --buildcmd "./build.sh"
popd popd
# wait for build to finish at most 60s # wait for build to finish at most 60s
timeout 60s bash -c "waitBuild $pkg1" timeout 60s bash -c "waitBuild $pkg1"
@@ -77,7 +78,8 @@ checkFunctionResponse $fn1 'a: 1 b: {c: 3, d: 4}'
# 2) Source archive file # 2) Source archive file
log "Creating pacakage with source archive" log "Creating pacakage with source archive"
zip -jr $tmp_dir/demo-src-pkg.zip $ROOT/examples/python/sourcepkg/ zip -jr $tmp_dir/demo-src-pkg.zip $ROOT/examples/python/sourcepkg/
pkg2=$(fission package create --src $tmp_dir/demo-src-pkg.zip --env $env --buildcmd "./build.sh"| cut -f2 -d' '| tr -d \') pkg2="pkg2-${TEST_ID}"
fission package create --name $pkg2 --src $tmp_dir/demo-src-pkg.zip --env $env --buildcmd "./build.sh"
# wait for build to finish at most 60s # wait for build to finish at most 60s
timeout 60s bash -c "waitBuild $pkg2" timeout 60s bash -c "waitBuild $pkg2"
@@ -98,7 +100,8 @@ checkFunctionResponse $fn2 'a: 1 b: {c: 3, d: 4}'
# 4) Deployment files from a directory # 4) Deployment files from a directory
pushd $ROOT/examples/python/ pushd $ROOT/examples/python/
pkg4=$(fission package create --deploy "multifile/*" --env $env| cut -f2 -d' '| tr -d \') pkg4="pkg4-${TEST_ID}"
fission package create --name $pkg4 --deploy "multifile/*" --env $env
popd popd
log "Creating function " $fn4 log "Creating function " $fn4
fission fn create --name $fn4 --pkg $pkg4 --entrypoint "main.main" fission fn create --name $fn4 --pkg $pkg4 --entrypoint "main.main"
@@ -118,7 +121,8 @@ mkdir $tmp_dir/deploypkg
touch $tmp_dir/deploypkg/__init__.py touch $tmp_dir/deploypkg/__init__.py
printf 'def main():\n return "Hello, world!"' > $tmp_dir/deploypkg/hello.py printf 'def main():\n return "Hello, world!"' > $tmp_dir/deploypkg/hello.py
zip -jr $tmp_dir/demo-deploy-pkg.zip $tmp_dir/deploypkg/ zip -jr $tmp_dir/demo-deploy-pkg.zip $tmp_dir/deploypkg/
pkg5=$(fission package create --deploy $tmp_dir/demo-deploy-pkg.zip --env $env| cut -f2 -d' '| tr -d \') pkg5="pkg5-${TEST_ID}"
fission package create --name $pkg5 --deploy $tmp_dir/demo-deploy-pkg.zip --env $env
log "Updating function " $fn5 log "Updating function " $fn5