Fixed the spec validation UX issue (#898)

Improved some of warnings/messages shown to the user when using `fission spec` command. The `spec validate` command now shows appropriate warnings instead
This commit is contained in:
Vishal
2018-09-21 14:52:49 +05:30
committed by GitHub
parent 6b49c194ca
commit 188138ccd8
5 changed files with 37 additions and 14 deletions
+12 -10
View File
@@ -173,16 +173,18 @@ func fnCreate(c *cli.Context) error {
log.Fatal("Need --env argument.")
}
// examine existence of given environment
_, err := client.EnvironmentGet(&metav1.ObjectMeta{
Namespace: envNamespace,
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 --envns %v --image <image>`\n", envName, envName, envNamespace)
} else {
util.CheckErr(err, "retrieve environment information")
// examine existence of given environment. If specs - then spec validate will do it, don't check here.
if !spec {
_, err := client.EnvironmentGet(&metav1.ObjectMeta{
Namespace: envNamespace,
Name: envName,
})
if err != nil {
if e, ok := err.(fission.Error); ok && e.Code == fission.ErrorNotFound {
log.Warn(fmt.Sprintf("Environment \"%v\" does not exist. Please create the environment before executing the function. \nFor example: `fission env create --name %v --envns %v --image <image>`\n", envName, envName, envNamespace))
} else {
util.CheckErr(err, "retrieve environment information")
}
}
}