github.com/grange74/terraform@v0.7.0-rc3.0.20160722171430-8c8803864753/command/command.go (about) 1 package command 2 3 import ( 4 "fmt" 5 6 "github.com/hashicorp/terraform/terraform" 7 "github.com/mitchellh/cli" 8 ) 9 10 // Set to true when we're testing 11 var test bool = false 12 13 // DefaultDataDir is the default directory for storing local data. 14 const DefaultDataDir = ".terraform" 15 16 // DefaultStateFilename is the default filename used for the state file. 17 const DefaultStateFilename = "terraform.tfstate" 18 19 // DefaultVarsFilename is the default filename used for vars 20 const DefaultVarsFilename = "terraform.tfvars" 21 22 // DefaultBackupExtension is added to the state file to form the path 23 const DefaultBackupExtension = ".backup" 24 25 // DefaultParallelism is the limit Terraform places on total parallel 26 // operations as it walks the dependency graph. 27 const DefaultParallelism = 10 28 29 func validateContext(ctx *terraform.Context, ui cli.Ui) bool { 30 if ws, es := ctx.Validate(); len(ws) > 0 || len(es) > 0 { 31 ui.Output( 32 "There are warnings and/or errors related to your configuration. Please\n" + 33 "fix these before continuing.\n") 34 35 if len(ws) > 0 { 36 ui.Warn("Warnings:\n") 37 for _, w := range ws { 38 ui.Warn(fmt.Sprintf(" * %s", w)) 39 } 40 41 if len(es) > 0 { 42 ui.Output("") 43 } 44 } 45 46 if len(es) > 0 { 47 ui.Error("Errors:\n") 48 for _, e := range es { 49 ui.Error(fmt.Sprintf(" * %s", e)) 50 } 51 return false 52 } else { 53 ui.Warn(fmt.Sprintf("\n"+ 54 "No errors found. Continuing with %d warning(s).\n", len(ws))) 55 return true 56 } 57 } 58 59 return true 60 }