Show warning when trying to create a route with non-existent function (#539)

This commit is contained in:
Ta-Ching Chen
2018-03-09 02:45:30 +08:00
committed by GitHub
parent b4300feabc
commit afd7f7f436
+16
View File
@@ -28,6 +28,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"github.com/fission/fission"
"github.com/fission/fission/controller/client"
"github.com/fission/fission/crd"
)
@@ -57,6 +58,17 @@ func getMethod(method string) string {
return ""
}
func checkFunctionExistence(fissionClient *client.Client, fnName string) {
meta := &metav1.ObjectMeta{
Name: fnName,
Namespace: metav1.NamespaceDefault,
}
_, err := fissionClient.FunctionGet(meta)
if err != nil {
fmt.Printf("function '%v' does not exist, use 'fission function create --name %v ...' to create the function\n", fnName, fnName)
}
}
func htCreate(c *cli.Context) error {
client := getClient(c.GlobalString("server"))
@@ -73,6 +85,8 @@ func htCreate(c *cli.Context) error {
method = "GET"
}
checkFunctionExistence(client, fnName)
// just name triggers by uuid.
triggerName := uuid.NewV4().String()
@@ -115,6 +129,8 @@ func htUpdate(c *cli.Context) error {
fatal("Nothing to update. Use --function to specify a new function.")
}
checkFunctionExistence(client, newFn)
ht, err := client.HTTPTriggerGet(&metav1.ObjectMeta{
Name: htName,
Namespace: metav1.NamespaceDefault,