Show warning when referencing nonexistent resources in spec (#1415)

This commit is contained in:
Ta-Ching Chen
2019-11-18 13:46:28 +08:00
committed by GitHub
parent 81ece23bfe
commit 3aca0edfcc
7 changed files with 166 additions and 34 deletions
+20
View File
@@ -89,7 +89,27 @@ func (opts *CreateSubCommand) run(input cli.Input) error {
}
var specDir, specFile string
if input.Bool(flagkey.SpecSave) {
specDir = util.GetSpecDir(input)
fr, err := spec.ReadSpecs(specDir)
if err != nil {
return errors.Wrap(err, fmt.Sprintf("error reading spec in '%v'", specDir))
}
exists, err := fr.ExistsInSpecs(fv1.Environment{
Metadata: metav1.ObjectMeta{
Name: envName,
Namespace: envNamespace,
},
})
if err != nil {
return err
}
if !exists {
console.Warn(fmt.Sprintf("Package '%v' references unknown Environment '%v', please create it before applying spec",
pkgName, envName))
}
specDir = util.GetSpecDir(input)
specFile = fmt.Sprintf("package-%v.yaml", pkgName)
}