opentofu/command/command.go

55 lines
1.2 KiB
Go
Raw Normal View History

2014-07-01 12:02:13 -05:00
package command
import (
"fmt"
"github.com/hashicorp/terraform/terraform"
2014-07-03 15:12:45 -05:00
"github.com/mitchellh/cli"
2014-07-01 12:02:13 -05:00
)
2014-09-29 13:24:16 -05:00
// Set to true when we're testing
var test bool = false
2014-07-11 23:03:56 -05:00
// DefaultStateFilename is the default filename used for the state file.
const DefaultStateFilename = "terraform.tfstate"
// DefaultVarsFilename is the default filename used for vars
const DefaultVarsFilename = "terraform.tfvars"
2014-07-27 17:09:04 -05:00
// DefaultBackupExtention is added to the state file to form the path
const DefaultBackupExtention = ".backup"
// DefaultDataDirectory is the directory where local state is stored
// by default.
const DefaultDataDirectory = ".terraform"
2014-07-03 15:12:45 -05:00
func validateContext(ctx *terraform.Context, ui cli.Ui) bool {
if ws, es := ctx.Validate(); len(ws) > 0 || len(es) > 0 {
ui.Output(
"There are warnings and/or errors related to your configuration. Please\n" +
"fix these before continuing.\n")
if len(ws) > 0 {
ui.Output("Warnings:\n")
for _, w := range ws {
ui.Output(fmt.Sprintf(" * %s", w))
}
if len(es) > 0 {
ui.Output("")
}
}
if len(es) > 0 {
ui.Output("Errors:\n")
for _, e := range es {
ui.Output(fmt.Sprintf(" * %s", e))
}
}
return false
}
return true
}