command: make state unexported on Meta

This commit is contained in:
Mitchell Hashimoto 2014-07-27 22:58:35 -07:00
parent 80ce9ad513
commit b172f45b94
4 changed files with 11 additions and 9 deletions

View File

@ -78,11 +78,11 @@ func (c *ApplyCommand) Run(args []string) int {
}
// Create a backup of the state before updating
if backupPath != "-" && c.State != nil {
if backupPath != "-" && c.state != nil {
log.Printf("[INFO] Writing backup state to: %s", backupPath)
f, err := os.Create(backupPath)
if err == nil {
err = terraform.WriteState(c.State, f)
err = terraform.WriteState(c.state, f)
f.Close()
}
if err != nil {

View File

@ -16,7 +16,10 @@ type Meta struct {
Color bool
ContextOpts *terraform.ContextOpts
Ui cli.Ui
State *terraform.State
// State read when calling `Context`. This is available after calling
// `Context`.
state *terraform.State
// This can be set by the command itself to provide extra hooks.
extraHooks []terraform.Hook
@ -79,7 +82,7 @@ func (m *Meta) Context(path, statePath string) (*terraform.Context, bool, error)
}
// Store the loaded state
m.State = state
m.state = state
config, err := config.LoadDir(path)
if err != nil {
@ -93,7 +96,6 @@ func (m *Meta) Context(path, statePath string) (*terraform.Context, bool, error)
opts.State = state
ctx := terraform.NewContext(opts)
return ctx, false, nil
}
// contextOpts returns the options to use to initialize a Terraform

View File

@ -76,11 +76,11 @@ func (c *PlanCommand) Run(args []string) int {
if refresh {
// Create a backup of the state before updating
if backupPath != "-" && c.State != nil {
if backupPath != "-" && c.state != nil {
log.Printf("[INFO] Writing backup state to: %s", backupPath)
f, err := os.Create(backupPath)
if err == nil {
err = terraform.WriteState(c.State, f)
err = terraform.WriteState(c.state, f)
f.Close()
}
if err != nil {

View File

@ -94,11 +94,11 @@ func (c *RefreshCommand) Run(args []string) int {
}
// Create a backup of the state before updating
if backupPath != "-" && c.State != nil {
if backupPath != "-" && c.state != nil {
log.Printf("[INFO] Writing backup state to: %s", backupPath)
f, err := os.Create(backupPath)
if err == nil {
err = terraform.WriteState(c.State, f)
err = terraform.WriteState(c.state, f)
f.Close()
}
if err != nil {