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
This commit is contained in:
Ta-Ching Chen
2018-01-26 16:35:17 -08:00
committed by Soam Vasani
parent 0a733b20c3
commit 4f7eb19b7c
+13
View File
@@ -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 <image>`\n", envName, envName)
} else {
checkErr(err, "retrieve environment information")
}
}
srcArchiveName := c.String("src")
deployArchiveName := c.String("code")
if len(deployArchiveName) == 0 {