From b3795e2d297842de77f1e3ef22aa7ba1375fd145 Mon Sep 17 00:00:00 2001 From: James Bardin Date: Wed, 24 May 2017 16:16:35 -0400 Subject: [PATCH] remove old state hook code --- command/hook_state.go | 33 --------------------------------- command/hook_state_test.go | 29 ----------------------------- 2 files changed, 62 deletions(-) delete mode 100644 command/hook_state.go delete mode 100644 command/hook_state_test.go diff --git a/command/hook_state.go b/command/hook_state.go deleted file mode 100644 index ab5c47a11..000000000 --- a/command/hook_state.go +++ /dev/null @@ -1,33 +0,0 @@ -package command - -import ( - "sync" - - "github.com/hashicorp/terraform/state" - "github.com/hashicorp/terraform/terraform" -) - -// StateHook is a hook that continuously updates the state by calling -// WriteState on a state.State. -type StateHook struct { - terraform.NilHook - sync.Mutex - - State state.State -} - -func (h *StateHook) PostStateUpdate( - s *terraform.State) (terraform.HookAction, error) { - h.Lock() - defer h.Unlock() - - if h.State != nil { - // Write the new state - if err := h.State.WriteState(s); err != nil { - return terraform.HookActionHalt, err - } - } - - // Continue forth - return terraform.HookActionContinue, nil -} diff --git a/command/hook_state_test.go b/command/hook_state_test.go deleted file mode 100644 index 0d0fd7927..000000000 --- a/command/hook_state_test.go +++ /dev/null @@ -1,29 +0,0 @@ -package command - -import ( - "testing" - - "github.com/hashicorp/terraform/state" - "github.com/hashicorp/terraform/terraform" -) - -func TestStateHook_impl(t *testing.T) { - var _ terraform.Hook = new(StateHook) -} - -func TestStateHook(t *testing.T) { - is := &state.InmemState{} - var hook terraform.Hook = &StateHook{State: is} - - s := state.TestStateInitial() - action, err := hook.PostStateUpdate(s) - if err != nil { - t.Fatalf("err: %s", err) - } - if action != terraform.HookActionContinue { - t.Fatalf("bad: %v", action) - } - if !is.State().Equal(s) { - t.Fatalf("bad state: %#v", is.State()) - } -}