terraform: don't crash if validating orphan

This commit is contained in:
Mitchell Hashimoto 2014-10-11 15:58:52 -07:00
parent bbdb375612
commit 6e7d23d612
1 changed files with 10 additions and 8 deletions

View File

@ -1053,14 +1053,16 @@ func (c *walkContext) validateWalkFn() depgraph.WalkFunc {
// If the resouce name doesn't match the name regular
// expression, show a warning.
if !config.NameRegexp.Match([]byte(rn.Config.Name)) {
l.Lock()
meta.Warns = append(meta.Warns, fmt.Sprintf(
"%s: module name can only contain letters, numbers, "+
"dashes, and underscores.\n"+
"This will be an error in Terraform 0.4",
rn.Resource.Id))
l.Unlock()
if rn.Config != nil {
if !config.NameRegexp.Match([]byte(rn.Config.Name)) {
l.Lock()
meta.Warns = append(meta.Warns, fmt.Sprintf(
"%s: module name can only contain letters, numbers, "+
"dashes, and underscores.\n"+
"This will be an error in Terraform 0.4",
rn.Resource.Id))
l.Unlock()
}
}
log.Printf("[INFO] Validating resource: %s", rn.Resource.Id)