From d43e67ffcc5533aa082d64cc578adee1e92e465b Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Tue, 11 Sep 2018 17:42:30 -0700 Subject: [PATCH] core: Drop InstanceInfo.HumanId Our shims from new provider API to old can't populate the InstanceInfo fully since the new API only includes the type name, and so anyone depending on this method is now broken anyway. In practice only our own tests depend on this, and so we'll drop it to make it explicit that it no longer works (rather than having it return nonsense) and then fix up the remaining tests that were depending on it to use a different strategy. --- terraform/resource.go | 18 ------------------ terraform/resource_test.go | 35 ----------------------------------- 2 files changed, 53 deletions(-) diff --git a/terraform/resource.go b/terraform/resource.go index df327eef2b..961289c6fc 100644 --- a/terraform/resource.go +++ b/terraform/resource.go @@ -153,15 +153,6 @@ func NewInstanceInfo(addr addrs.AbsResourceInstance) *InstanceInfo { } } -// HumanId is a unique Id that is human-friendly and useful for UI elements. -func (i *InstanceInfo) HumanId() string { - p := normalizeModulePath(i.ModulePath) - if p.IsRoot() { - return i.Id - } - return fmt.Sprintf("%s.%s", p.String(), i.Id) -} - // ResourceAddress returns the address of the resource that the receiver is describing. func (i *InstanceInfo) ResourceAddress() *ResourceAddress { // GROSS: for tainted and deposed instances, their status gets appended @@ -202,15 +193,6 @@ func (i *InstanceInfo) ResourceAddress() *ResourceAddress { return addr } -func (i *InstanceInfo) uniqueId() string { - prefix := i.HumanId() - if v := i.uniqueExtra; v != "" { - prefix += " " + v - } - - return prefix -} - // ResourceConfig is a legacy type that was formerly used to represent // interpolatable configuration blocks. It is now only used to shim to old // APIs that still use this type, via NewResourceConfigShimmed. diff --git a/terraform/resource_test.go b/terraform/resource_test.go index 4566492dc3..35ac6e4897 100644 --- a/terraform/resource_test.go +++ b/terraform/resource_test.go @@ -12,41 +12,6 @@ import ( "github.com/mitchellh/reflectwalk" ) -func TestInstanceInfo(t *testing.T) { - cases := []struct { - Info *InstanceInfo - Result string - }{ - { - &InstanceInfo{ - Id: "foo", - }, - "foo", - }, - { - &InstanceInfo{ - Id: "foo", - ModulePath: rootModulePath, - }, - "foo", - }, - { - &InstanceInfo{ - Id: "foo", - ModulePath: []string{"root", "consul"}, - }, - "module.consul.foo", - }, - } - - for i, tc := range cases { - actual := tc.Info.HumanId() - if actual != tc.Result { - t.Fatalf("%d: %s", i, actual) - } - } -} - func TestInstanceInfoResourceAddress(t *testing.T) { tests := []struct { Input *InstanceInfo