github.com/graywolf-at-work-2/terraform-vendor@v1.4.5/internal/command/command.go (about) 1 package command 2 3 import ( 4 "fmt" 5 "os" 6 "runtime" 7 ) 8 9 // Set to true when we're testing 10 var test bool = false 11 12 // DefaultDataDir is the default directory for storing local data. 13 const DefaultDataDir = ".terraform" 14 15 // PluginPathFile is the name of the file in the data dir which stores the list 16 // of directories supplied by the user with the `-plugin-dir` flag during init. 17 const PluginPathFile = "plugin_path" 18 19 // pluginMachineName is the directory name used in new plugin paths. 20 const pluginMachineName = runtime.GOOS + "_" + runtime.GOARCH 21 22 // DefaultPluginVendorDir is the location in the config directory to look for 23 // user-added plugin binaries. Terraform only reads from this path if it 24 // exists, it is never created by terraform. 25 const DefaultPluginVendorDir = "terraform.d/plugins/" + pluginMachineName 26 27 // DefaultStateFilename is the default filename used for the state file. 28 const DefaultStateFilename = "terraform.tfstate" 29 30 // DefaultVarsFilename is the default filename used for vars 31 const DefaultVarsFilename = "terraform.tfvars" 32 33 // DefaultBackupExtension is added to the state file to form the path 34 const DefaultBackupExtension = ".backup" 35 36 // DefaultParallelism is the limit Terraform places on total parallel 37 // operations as it walks the dependency graph. 38 const DefaultParallelism = 10 39 40 // ErrUnsupportedLocalOp is the common error message shown for operations 41 // that require a backend.Local. 42 const ErrUnsupportedLocalOp = `The configured backend doesn't support this operation. 43 44 The "backend" in Terraform defines how Terraform operates. The default 45 backend performs all operations locally on your machine. Your configuration 46 is configured to use a non-local backend. This backend doesn't support this 47 operation. 48 ` 49 50 // ModulePath returns the path to the root module and validates CLI arguments. 51 // 52 // This centralizes the logic for any commands that previously accepted 53 // a module path via CLI arguments. This will error if any extraneous arguments 54 // are given and suggest using the -chdir flag instead. 55 // 56 // If your command accepts more than one arg, then change the slice bounds 57 // to pass validation. 58 func ModulePath(args []string) (string, error) { 59 // TODO: test 60 61 if len(args) > 0 { 62 return "", fmt.Errorf("Too many command line arguments. Did you mean to use -chdir?") 63 } 64 65 path, err := os.Getwd() 66 if err != nil { 67 return "", fmt.Errorf("Error getting pwd: %s", err) 68 } 69 70 return path, nil 71 }