Prepending a slash to user input url if missing. (#547)

* Prepending a slash to user input url if missing.

* Adding the url slash check for spec.
This commit is contained in:
smruthi2187
2018-03-26 12:31:02 -07:00
committed by Soam Vasani
parent 03046170dc
commit 77be3379b2
3 changed files with 11 additions and 0 deletions
+4
View File
@@ -274,6 +274,10 @@ func fnCreate(c *cli.Context) error {
if len(triggerUrl) == 0 {
return nil
}
if !strings.HasPrefix(triggerUrl, "/") {
triggerUrl = fmt.Sprintf("/%s", triggerUrl)
}
method := c.String("method")
if len(method) == 0 {
method = "GET"
+4
View File
@@ -80,6 +80,10 @@ func htCreate(c *cli.Context) error {
if len(triggerUrl) == 0 {
fatal("Need a trigger URL, use --url")
}
if !strings.HasPrefix(triggerUrl, "/") {
triggerUrl = fmt.Sprintf("/%s", triggerUrl)
}
method := c.String("method")
if len(method) == 0 {
method = "GET"
+3
View File
@@ -246,6 +246,9 @@ func parseYaml(path string, b []byte, fr *FissionResources) error {
warn(fmt.Sprintf("Failed to parse %v in %v: %v", tm.Kind, path, err))
return err
}
if !strings.HasPrefix(v.Spec.RelativeURL, "/") {
v.Spec.RelativeURL = fmt.Sprintf("/%s", v.Spec.RelativeURL)
}
fr.httpTriggers = append(fr.httpTriggers, v)
case "KubernetesWatchTrigger":
var v crd.KubernetesWatchTrigger