github.com/ezbercih/terraform@v0.1.1-0.20140729011846-3c33865e0839/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  // DefaultStateFilename is the default filename used for the state file.
    11  const DefaultStateFilename = "terraform.tfstate"
    12  
    13  // DefaultBackupExtention is added to the state file to form the path
    14  const DefaultBackupExtention = ".backup"
    15  
    16  func validateContext(ctx *terraform.Context, ui cli.Ui) bool {
    17  	if ws, es := ctx.Validate(); len(ws) > 0 || len(es) > 0 {
    18  		ui.Output(
    19  			"There are warnings and/or errors related to your configuration. Please\n" +
    20  				"fix these before continuing.\n")
    21  
    22  		if len(ws) > 0 {
    23  			ui.Output("Warnings:\n")
    24  			for _, w := range ws {
    25  				ui.Output(fmt.Sprintf("  * %s", w))
    26  			}
    27  
    28  			if len(es) > 0 {
    29  				ui.Output("")
    30  			}
    31  		}
    32  
    33  		if len(es) > 0 {
    34  			ui.Output("Errors:\n")
    35  			for _, e := range es {
    36  				ui.Output(fmt.Sprintf("  * %s", e))
    37  			}
    38  		}
    39  
    40  		return false
    41  	}
    42  
    43  	return true
    44  }