From 536c2fe6f1c397c035df5cdf30a170af1da1e77b Mon Sep 17 00:00:00 2001 From: Sander van Harmelen Date: Fri, 19 Oct 2018 19:19:49 +0200 Subject: [PATCH] Make `state mv` use the new `states.Filter` --- command/state_mv.go | 36 +++++------------------------------- 1 file changed, 5 insertions(+), 31 deletions(-) diff --git a/command/state_mv.go b/command/state_mv.go index 15f4a35ab..85a759b3e 100644 --- a/command/state_mv.go +++ b/command/state_mv.go @@ -5,7 +5,6 @@ import ( "strings" "github.com/hashicorp/terraform/states" - "github.com/hashicorp/terraform/terraform" "github.com/mitchellh/cli" ) @@ -141,43 +140,18 @@ func (c *StateMvCommand) Run(args []string) int { // addableResult takes the result from a filter operation and returns what to // call State.Add with. The reason we do this is because in the module case // we must add the list of all modules returned versus just the root module. -func (c *StateMvCommand) addableResult(results []*terraform.StateFilterResult) interface{} { +func (c *StateMvCommand) addableResult(results []*states.FilterResult) interface{} { switch v := results[0].Value.(type) { - case *terraform.ModuleState: - // If a module state then we should add the full list of modules - result := []*terraform.ModuleState{v} + case *states.Module: + // If a state module then we should add the full list of modules + result := []*states.Module{v} if len(results) > 1 { for _, r := range results[1:] { - if ms, ok := r.Value.(*terraform.ModuleState); ok { + if ms, ok := r.Value.(*states.Module); ok { result = append(result, ms) } } } - - return result - - case *terraform.ResourceState: - // If a resource state with more than one result, it has a multi-count - // and we need to add all of them. - result := []*terraform.ResourceState{v} - if len(results) > 1 { - for _, r := range results[1:] { - rs, ok := r.Value.(*terraform.ResourceState) - if !ok { - continue - } - - if rs.Type == v.Type { - result = append(result, rs) - } - } - } - - // If we only have one item, add it directly - if len(result) == 1 { - return result[0] - } - return result default: