From 4f7eb19b7c47dd3afdcbca2eeedfc0ec8b31f1bd Mon Sep 17 00:00:00 2001 From: Ta-Ching Chen Date: Sat, 27 Jan 2018 08:35:17 +0800 Subject: [PATCH] Show warning when user tries to create a function with a non-existent environment (#436) Show warning when user try to create a function with non-existent environment --- fission/function.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/fission/function.go b/fission/function.go index bfbf72e5..93334f78 100644 --- a/fission/function.go +++ b/fission/function.go @@ -106,6 +106,19 @@ func fnCreate(c *cli.Context) error { fatal("Need --env argument.") } + // examine existence of given environment + _, err := client.EnvironmentGet(&metav1.ObjectMeta{ + Namespace: metav1.NamespaceDefault, + Name: envName, + }) + if err != nil { + if e, ok := err.(fission.Error); ok && e.Code == fission.ErrorNotFound { + fmt.Printf("Environment \"%v\" does not exist. Please create the environment before executing the function. \nFor example: `fission env create --name %v --image `\n", envName, envName) + } else { + checkErr(err, "retrieve environment information") + } + } + srcArchiveName := c.String("src") deployArchiveName := c.String("code") if len(deployArchiveName) == 0 {