From 0c6d133d616de8889e51afa1a3ea29b360e7ead5 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 22 Feb 2015 11:11:24 -0800 Subject: [PATCH] command/refresh: get rid of remote package --- command/refresh.go | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/command/refresh.go b/command/refresh.go index f8765506a..38d630050 100644 --- a/command/refresh.go +++ b/command/refresh.go @@ -5,8 +5,6 @@ import ( "log" "os" "strings" - - "github.com/hashicorp/terraform/remote" ) // RefreshCommand is a cli.Command implementation that refreshes the state @@ -44,16 +42,16 @@ func (c *RefreshCommand) Run(args []string) int { } // Check if remote state is enabled - remoteEnabled, err := remote.HaveLocalState() + state, err := c.State() if err != nil { - c.Ui.Error(fmt.Sprintf("Failed to check for remote state: %v", err)) + c.Ui.Error(fmt.Sprintf("Failed to load state: %s", err)) return 1 } // Verify that the state path exists. The "ContextArg" function below // will actually do this, but we want to provide a richer error message // if possible. - if !remoteEnabled { + if !state.State().IsRemote() { if _, err := os.Stat(c.Meta.statePath); err != nil { if os.IsNotExist(err) { c.Ui.Error(fmt.Sprintf( @@ -95,14 +93,14 @@ func (c *RefreshCommand) Run(args []string) int { return 1 } - state, err := ctx.Refresh() + newState, err := ctx.Refresh() if err != nil { c.Ui.Error(fmt.Sprintf("Error refreshing state: %s", err)) return 1 } log.Printf("[INFO] Writing state output to: %s", c.Meta.StateOutPath()) - if err := c.Meta.PersistState(state); err != nil { + if err := c.Meta.PersistState(newState); err != nil { c.Ui.Error(fmt.Sprintf("Error writing state file: %s", err)) return 1 }