github.com/jorgemarey/terraform@v0.6.7-0.20151113041428-536ba76b21bb/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 // DefaultDataDirectory is the directory where local state is stored 26 // by default. 27 const DefaultDataDirectory = ".terraform" 28 29 // DefaultParallelism is the limit Terraform places on total parallel 30 // operations as it walks the dependency graph. 31 const DefaultParallelism = 10 32 33 func validateContext(ctx *terraform.Context, ui cli.Ui) bool { 34 if ws, es := ctx.Validate(); len(ws) > 0 || len(es) > 0 { 35 ui.Output( 36 "There are warnings and/or errors related to your configuration. Please\n" + 37 "fix these before continuing.\n") 38 39 if len(ws) > 0 { 40 ui.Warn("Warnings:\n") 41 for _, w := range ws { 42 ui.Warn(fmt.Sprintf(" * %s", w)) 43 } 44 45 if len(es) > 0 { 46 ui.Output("") 47 } 48 } 49 50 if len(es) > 0 { 51 ui.Error("Errors:\n") 52 for _, e := range es { 53 ui.Error(fmt.Sprintf(" * %s", e)) 54 } 55 return false 56 } else { 57 ui.Warn(fmt.Sprintf("\n"+ 58 "No errors found. Continuing with %d warning(s).\n", len(ws))) 59 return true 60 } 61 } 62 63 return true 64 }