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