mirror of
https://github.com/opentofu/opentofu.git
synced 2024-12-30 10:47:14 -06:00
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.
This commit is contained in:
parent
441f7f0849
commit
e3dad1bcc1
@ -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.
|
// ResourceAddress returns the address of the resource that the receiver is describing.
|
||||||
func (i *InstanceInfo) ResourceAddress() *ResourceAddress {
|
func (i *InstanceInfo) ResourceAddress() *ResourceAddress {
|
||||||
// GROSS: for tainted and deposed instances, their status gets appended
|
// GROSS: for tainted and deposed instances, their status gets appended
|
||||||
@ -202,15 +193,6 @@ func (i *InstanceInfo) ResourceAddress() *ResourceAddress {
|
|||||||
return addr
|
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
|
// ResourceConfig is a legacy type that was formerly used to represent
|
||||||
// interpolatable configuration blocks. It is now only used to shim to old
|
// interpolatable configuration blocks. It is now only used to shim to old
|
||||||
// APIs that still use this type, via NewResourceConfigShimmed.
|
// APIs that still use this type, via NewResourceConfigShimmed.
|
||||||
|
@ -12,41 +12,6 @@ import (
|
|||||||
"github.com/mitchellh/reflectwalk"
|
"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) {
|
func TestInstanceInfoResourceAddress(t *testing.T) {
|
||||||
tests := []struct {
|
tests := []struct {
|
||||||
Input *InstanceInfo
|
Input *InstanceInfo
|
||||||
|
Loading…
Reference in New Issue
Block a user