Add method and subpath flags to timetrigger object for triggering a function (#3017)
* Update timetrigger crd and add method and subpath fields in spec. Update fission-cli to accept user input for method and subpath fields. Update publisher package to utilize these fields for triggering a function. Update timer controller to use method and subpath fields for publishing a request. Add a new test TestPublisherSubpath in pulisher package. Signed-off-by: Md Soharab Ansari <soharab.ansari@infracloud.io> * Use kubebuilder default annotation. Update test for fission-cli timetrigger create, update command to support method and subpath flags. Signed-off-by: Md Soharab Ansari <soharab.ansari@infracloud.io> --------- Signed-off-by: Md Soharab Ansari <soharab.ansari@infracloud.io>
This commit is contained in:
@@ -31,7 +31,11 @@ func Commands() *cobra.Command {
|
||||
}
|
||||
wrapper.SetFlags(createCmd, flag.FlagSet{
|
||||
Optional: []flag.Flag{flag.TtName, flag.TtFnName,
|
||||
flag.TtCron, flag.NamespaceFunction, flag.SpecSave, flag.SpecDry},
|
||||
flag.TtCron, flag.NamespaceFunction,
|
||||
flag.TtMethod, flag.FnSubPath,
|
||||
|
||||
flag.SpecSave, flag.SpecDry,
|
||||
},
|
||||
})
|
||||
|
||||
updateCmd := &cobra.Command{
|
||||
@@ -42,7 +46,10 @@ func Commands() *cobra.Command {
|
||||
}
|
||||
wrapper.SetFlags(updateCmd, flag.FlagSet{
|
||||
Required: []flag.Flag{flag.TtName},
|
||||
Optional: []flag.Flag{flag.TtFnName, flag.TtCron, flag.NamespaceTrigger},
|
||||
Optional: []flag.Flag{flag.TtFnName, flag.TtCron, flag.NamespaceTrigger,
|
||||
|
||||
flag.TtMethod, flag.FnSubPath,
|
||||
},
|
||||
})
|
||||
|
||||
deleteCmd := &cobra.Command{
|
||||
|
||||
@@ -116,6 +116,8 @@ func (opts *CreateSubCommand) complete(input cli.Input) (err error) {
|
||||
Type: fv1.FunctionReferenceTypeFunctionName,
|
||||
Name: fnName,
|
||||
},
|
||||
Method: input.String(flagkey.TtMethod),
|
||||
Subpath: input.String(flagkey.FnSubPath),
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -54,10 +54,10 @@ func (opts *ListSubCommand) do(input cli.Input) (err error) {
|
||||
|
||||
w := tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', 0)
|
||||
|
||||
fmt.Fprintf(w, "%v\t%v\t%v\n", "NAME", "CRON", "FUNCTION_NAME")
|
||||
fmt.Fprintf(w, "%v\t%v\t%v\t%v\t%v\n", "NAME", "CRON", "FUNCTION_NAME", "METHOD", "SUBPATH")
|
||||
for _, tt := range tts.Items {
|
||||
fmt.Fprintf(w, "%v\t%v\t%v\n",
|
||||
tt.ObjectMeta.Name, tt.Spec.Cron, tt.Spec.FunctionReference.Name)
|
||||
fmt.Fprintf(w, "%v\t%v\t%v\t%v\t%v\n",
|
||||
tt.ObjectMeta.Name, tt.Spec.Cron, tt.Spec.FunctionReference.Name, tt.Spec.Method, tt.Spec.Subpath)
|
||||
}
|
||||
w.Flush()
|
||||
|
||||
|
||||
@@ -77,8 +77,18 @@ func (opts *UpdateSubCommand) complete(input cli.Input) error {
|
||||
updated = true
|
||||
}
|
||||
|
||||
if input.IsSet(flagkey.TtMethod) {
|
||||
tt.Spec.Method = input.String(flagkey.TtMethod)
|
||||
updated = true
|
||||
}
|
||||
|
||||
if input.IsSet(flagkey.FnSubPath) {
|
||||
tt.Spec.Subpath = input.String(flagkey.FnSubPath)
|
||||
updated = true
|
||||
}
|
||||
|
||||
if !updated {
|
||||
return errors.New("nothing to update. Use --cron or --function")
|
||||
return errors.New("nothing to update. Use --cron or --function or --method or --subpath")
|
||||
}
|
||||
|
||||
opts.trigger = tt
|
||||
|
||||
@@ -157,6 +157,7 @@ var (
|
||||
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'"}
|
||||
TtFnName = Flag{Type: String, Name: flagkey.TtFnName, Usage: "Function name"}
|
||||
TtRound = Flag{Type: Int, Name: flagkey.TtRound, Usage: "Get next N rounds of invocation time", DefaultValue: 1}
|
||||
TtMethod = Flag{Type: String, Name: flagkey.TtMethod, Usage: "HTTP Methods: GET,POST,PUT,DELETE,HEAD."}
|
||||
|
||||
MqtName = Flag{Type: String, Name: flagkey.MqtName, Usage: "Message queue trigger name"}
|
||||
MqtFnName = Flag{Type: String, Name: flagkey.MqtFnName, Usage: "Function name"}
|
||||
|
||||
@@ -110,6 +110,7 @@ const (
|
||||
TtCron = "cron"
|
||||
TtFnName = "function"
|
||||
TtRound = "round"
|
||||
TtMethod = "method"
|
||||
|
||||
MqtName = resourceName
|
||||
MqtFnName = "function"
|
||||
|
||||
Reference in New Issue
Block a user