use addrs.ConfigResource for dependency tracking
We can't get module instances during transformation, so we need to reduce the Dependencies to using `addrs.ConfigResource` for now.
This commit is contained in:
parent
0afa3710fd
commit
b3fc0dab94
|
@ -213,7 +213,7 @@ func TestApply_destroyTargeted(t *testing.T) {
|
|||
}.Instance(addrs.NoKey).Absolute(addrs.RootModuleInstance),
|
||||
&states.ResourceInstanceObjectSrc{
|
||||
AttrsJSON: []byte(`{"id":"i-abc123"}`),
|
||||
Dependencies: []addrs.AbsResource{mustResourceAddr("test_instance.foo")},
|
||||
Dependencies: []addrs.ConfigResource{mustResourceAddr("test_instance.foo")},
|
||||
Status: states.ObjectReady,
|
||||
},
|
||||
addrs.AbsProviderConfig{
|
||||
|
|
|
@ -268,7 +268,7 @@ func testState() *states.State {
|
|||
// of all of the containing wrapping objects and arrays.
|
||||
AttrsJSON: []byte("{\n \"id\": \"bar\"\n }"),
|
||||
Status: states.ObjectReady,
|
||||
Dependencies: []addrs.AbsResource{},
|
||||
Dependencies: []addrs.ConfigResource{},
|
||||
DependsOn: []addrs.Referenceable{},
|
||||
},
|
||||
addrs.AbsProviderConfig{
|
||||
|
@ -881,10 +881,10 @@ func normalizeJSON(t *testing.T, src []byte) string {
|
|||
return buf.String()
|
||||
}
|
||||
|
||||
func mustResourceAddr(s string) addrs.AbsResource {
|
||||
func mustResourceAddr(s string) addrs.ConfigResource {
|
||||
addr, diags := addrs.ParseAbsResourceStr(s)
|
||||
if diags.HasErrors() {
|
||||
panic(diags.Err())
|
||||
}
|
||||
return addr
|
||||
return addr.Config()
|
||||
}
|
||||
|
|
|
@ -277,7 +277,7 @@ func TestRefresh_defaultState(t *testing.T) {
|
|||
expected := &states.ResourceInstanceObjectSrc{
|
||||
Status: states.ObjectReady,
|
||||
AttrsJSON: []byte("{\n \"ami\": null,\n \"id\": \"yes\"\n }"),
|
||||
Dependencies: []addrs.AbsResource{},
|
||||
Dependencies: []addrs.ConfigResource{},
|
||||
DependsOn: []addrs.Referenceable{},
|
||||
}
|
||||
if !reflect.DeepEqual(actual, expected) {
|
||||
|
@ -342,7 +342,7 @@ func TestRefresh_outPath(t *testing.T) {
|
|||
expected := &states.ResourceInstanceObjectSrc{
|
||||
Status: states.ObjectReady,
|
||||
AttrsJSON: []byte("{\n \"ami\": null,\n \"id\": \"yes\"\n }"),
|
||||
Dependencies: []addrs.AbsResource{},
|
||||
Dependencies: []addrs.ConfigResource{},
|
||||
DependsOn: []addrs.Referenceable{},
|
||||
}
|
||||
if !reflect.DeepEqual(actual, expected) {
|
||||
|
@ -572,7 +572,7 @@ func TestRefresh_backup(t *testing.T) {
|
|||
expected := &states.ResourceInstanceObjectSrc{
|
||||
Status: states.ObjectReady,
|
||||
AttrsJSON: []byte("{\n \"ami\": null,\n \"id\": \"changed\"\n }"),
|
||||
Dependencies: []addrs.AbsResource{},
|
||||
Dependencies: []addrs.ConfigResource{},
|
||||
DependsOn: []addrs.Referenceable{},
|
||||
}
|
||||
if !reflect.DeepEqual(actual, expected) {
|
||||
|
@ -639,7 +639,7 @@ func TestRefresh_disableBackup(t *testing.T) {
|
|||
expected := &states.ResourceInstanceObjectSrc{
|
||||
Status: states.ObjectReady,
|
||||
AttrsJSON: []byte("{\n \"ami\": null,\n \"id\": \"yes\"\n }"),
|
||||
Dependencies: []addrs.AbsResource{},
|
||||
Dependencies: []addrs.ConfigResource{},
|
||||
DependsOn: []addrs.Referenceable{},
|
||||
}
|
||||
if !reflect.DeepEqual(actual, expected) {
|
||||
|
|
|
@ -82,7 +82,7 @@ func TestShow_aliasedProvider(t *testing.T) {
|
|||
// of all of the containing wrapping objects and arrays.
|
||||
AttrsJSON: []byte("{\n \"id\": \"bar\"\n }"),
|
||||
Status: states.ObjectReady,
|
||||
Dependencies: []addrs.AbsResource{},
|
||||
Dependencies: []addrs.ConfigResource{},
|
||||
DependsOn: []addrs.Referenceable{},
|
||||
},
|
||||
addrs.RootModuleInstance.ProviderConfigAliased(addrs.NewLegacyProvider("test"), "alias"),
|
||||
|
|
|
@ -41,7 +41,7 @@ func TestStateMv(t *testing.T) {
|
|||
&states.ResourceInstanceObjectSrc{
|
||||
AttrsJSON: []byte(`{"id":"foo","foo":"value","bar":"value"}`),
|
||||
Status: states.ObjectReady,
|
||||
Dependencies: []addrs.AbsResource{mustResourceAddr("test_instance.foo")},
|
||||
Dependencies: []addrs.ConfigResource{mustResourceAddr("test_instance.foo")},
|
||||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
|
@ -172,7 +172,7 @@ func TestStateMv_resourceToInstance(t *testing.T) {
|
|||
&states.ResourceInstanceObjectSrc{
|
||||
AttrsJSON: []byte(`{"id":"foo","foo":"value","bar":"value"}`),
|
||||
Status: states.ObjectReady,
|
||||
Dependencies: []addrs.AbsResource{mustResourceAddr("test_instance.foo")},
|
||||
Dependencies: []addrs.ConfigResource{mustResourceAddr("test_instance.foo")},
|
||||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
|
@ -549,7 +549,7 @@ func TestStateMv_backupExplicit(t *testing.T) {
|
|||
&states.ResourceInstanceObjectSrc{
|
||||
AttrsJSON: []byte(`{"id":"foo","foo":"value","bar":"value"}`),
|
||||
Status: states.ObjectReady,
|
||||
Dependencies: []addrs.AbsResource{mustResourceAddr("test_instance.foo")},
|
||||
Dependencies: []addrs.ConfigResource{mustResourceAddr("test_instance.foo")},
|
||||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
|
@ -1068,7 +1068,7 @@ func TestStateMv_withinBackend(t *testing.T) {
|
|||
&states.ResourceInstanceObjectSrc{
|
||||
AttrsJSON: []byte(`{"id":"foo","foo":"value","bar":"value"}`),
|
||||
Status: states.ObjectReady,
|
||||
Dependencies: []addrs.AbsResource{mustResourceAddr("test_instance.foo")},
|
||||
Dependencies: []addrs.ConfigResource{mustResourceAddr("test_instance.foo")},
|
||||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("test"),
|
||||
|
|
|
@ -34,7 +34,7 @@ type ResourceInstanceObject struct {
|
|||
// the dependency relationships for an object whose configuration is no
|
||||
// longer available, such as if it has been removed from configuration
|
||||
// altogether, or is now deposed.
|
||||
Dependencies []addrs.AbsResource
|
||||
Dependencies []addrs.ConfigResource
|
||||
|
||||
// CreateBeforeDestroy reflects the status of the lifecycle
|
||||
// create_before_destroy option when this instance was last updated.
|
||||
|
|
|
@ -53,7 +53,7 @@ type ResourceInstanceObjectSrc struct {
|
|||
// ResourceInstanceObject.
|
||||
Private []byte
|
||||
Status ObjectStatus
|
||||
Dependencies []addrs.AbsResource
|
||||
Dependencies []addrs.ConfigResource
|
||||
CreateBeforeDestroy bool
|
||||
// deprecated
|
||||
DependsOn []addrs.Referenceable
|
||||
|
|
|
@ -153,9 +153,9 @@ func (obj *ResourceInstanceObjectSrc) DeepCopy() *ResourceInstanceObjectSrc {
|
|||
|
||||
// Some addrs.Referencable implementations are technically mutable, but
|
||||
// we treat them as immutable by convention and so we don't deep-copy here.
|
||||
var dependencies []addrs.AbsResource
|
||||
var dependencies []addrs.ConfigResource
|
||||
if obj.Dependencies != nil {
|
||||
dependencies = make([]addrs.AbsResource, len(obj.Dependencies))
|
||||
dependencies = make([]addrs.ConfigResource, len(obj.Dependencies))
|
||||
copy(dependencies, obj.Dependencies)
|
||||
}
|
||||
|
||||
|
@ -198,9 +198,9 @@ func (obj *ResourceInstanceObject) DeepCopy() *ResourceInstanceObject {
|
|||
|
||||
// Some addrs.Referenceable implementations are technically mutable, but
|
||||
// we treat them as immutable by convention and so we don't deep-copy here.
|
||||
var dependencies []addrs.AbsResource
|
||||
var dependencies []addrs.ConfigResource
|
||||
if obj.Dependencies != nil {
|
||||
dependencies = make([]addrs.AbsResource, len(obj.Dependencies))
|
||||
dependencies = make([]addrs.ConfigResource, len(obj.Dependencies))
|
||||
copy(dependencies, obj.Dependencies)
|
||||
}
|
||||
|
||||
|
|
|
@ -141,7 +141,7 @@ func TestStateDeepCopy(t *testing.T) {
|
|||
SchemaVersion: 1,
|
||||
AttrsJSON: []byte(`{"woozles":"confuzles"}`),
|
||||
Private: []byte("private data"),
|
||||
Dependencies: []addrs.AbsResource{},
|
||||
Dependencies: []addrs.ConfigResource{},
|
||||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewDefaultProvider("test"),
|
||||
|
@ -159,9 +159,9 @@ func TestStateDeepCopy(t *testing.T) {
|
|||
SchemaVersion: 1,
|
||||
AttrsJSON: []byte(`{"woozles":"confuzles"}`),
|
||||
Private: []byte("private data"),
|
||||
Dependencies: []addrs.AbsResource{
|
||||
Dependencies: []addrs.ConfigResource{
|
||||
{
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
Resource: addrs.Resource{
|
||||
Mode: addrs.ManagedResourceMode,
|
||||
Type: "test_thing",
|
||||
|
|
|
@ -218,14 +218,14 @@ func prepareStateV4(sV4 *stateV4) (*File, tfdiags.Diagnostics) {
|
|||
|
||||
{
|
||||
depsRaw := isV4.Dependencies
|
||||
deps := make([]addrs.AbsResource, 0, len(depsRaw))
|
||||
deps := make([]addrs.ConfigResource, 0, len(depsRaw))
|
||||
for _, depRaw := range depsRaw {
|
||||
addr, addrDiags := addrs.ParseAbsResourceStr(depRaw)
|
||||
diags = diags.Append(addrDiags)
|
||||
if addrDiags.HasErrors() {
|
||||
continue
|
||||
}
|
||||
deps = append(deps, addr)
|
||||
deps = append(deps, addr.Config())
|
||||
}
|
||||
obj.Dependencies = deps
|
||||
}
|
||||
|
|
|
@ -298,7 +298,7 @@ func TestContext2Apply_resourceDependsOnModuleStateOnly(t *testing.T) {
|
|||
&states.ResourceInstanceObjectSrc{
|
||||
Status: states.ObjectReady,
|
||||
AttrsJSON: []byte(`{"id":"parent"}`),
|
||||
Dependencies: []addrs.AbsResource{mustResourceAddr("module.child.aws_instance.child")},
|
||||
Dependencies: []addrs.ConfigResource{mustResourceAddr("module.child.aws_instance.child")},
|
||||
},
|
||||
mustProviderConfig(`provider["registry.terraform.io/-/aws"]`),
|
||||
)
|
||||
|
@ -1273,7 +1273,7 @@ func testContext2Apply_destroyDependsOn(t *testing.T) {
|
|||
&states.ResourceInstanceObjectSrc{
|
||||
Status: states.ObjectReady,
|
||||
AttrsJSON: []byte(`{"id":"foo"}`),
|
||||
Dependencies: []addrs.AbsResource{mustResourceAddr("aws_instance.bar")},
|
||||
Dependencies: []addrs.ConfigResource{mustResourceAddr("aws_instance.bar")},
|
||||
},
|
||||
mustProviderConfig(`provider["registry.terraform.io/-/aws"]`),
|
||||
)
|
||||
|
@ -1329,7 +1329,7 @@ func TestContext2Apply_destroyDependsOnStateOnly(t *testing.T) {
|
|||
&states.ResourceInstanceObjectSrc{
|
||||
Status: states.ObjectReady,
|
||||
AttrsJSON: []byte(`{"id":"foo"}`),
|
||||
Dependencies: []addrs.AbsResource{},
|
||||
Dependencies: []addrs.ConfigResource{},
|
||||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("aws"),
|
||||
|
@ -1345,14 +1345,14 @@ func TestContext2Apply_destroyDependsOnStateOnly(t *testing.T) {
|
|||
&states.ResourceInstanceObjectSrc{
|
||||
Status: states.ObjectReady,
|
||||
AttrsJSON: []byte(`{"id":"bar"}`),
|
||||
Dependencies: []addrs.AbsResource{
|
||||
addrs.AbsResource{
|
||||
Dependencies: []addrs.ConfigResource{
|
||||
addrs.ConfigResource{
|
||||
Resource: addrs.Resource{
|
||||
Mode: addrs.ManagedResourceMode,
|
||||
Type: "aws_instance",
|
||||
Name: "foo",
|
||||
},
|
||||
Module: root.Addr,
|
||||
Module: root.Addr.Module(),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -1427,7 +1427,7 @@ func TestContext2Apply_destroyDependsOnStateOnlyModule(t *testing.T) {
|
|||
&states.ResourceInstanceObjectSrc{
|
||||
Status: states.ObjectReady,
|
||||
AttrsJSON: []byte(`{"id":"foo"}`),
|
||||
Dependencies: []addrs.AbsResource{},
|
||||
Dependencies: []addrs.ConfigResource{},
|
||||
},
|
||||
addrs.AbsProviderConfig{
|
||||
Provider: addrs.NewLegacyProvider("aws"),
|
||||
|
@ -1443,14 +1443,14 @@ func TestContext2Apply_destroyDependsOnStateOnlyModule(t *testing.T) {
|
|||
&states.ResourceInstanceObjectSrc{
|
||||
Status: states.ObjectReady,
|
||||
AttrsJSON: []byte(`{"id":"bar"}`),
|
||||
Dependencies: []addrs.AbsResource{
|
||||
addrs.AbsResource{
|
||||
Dependencies: []addrs.ConfigResource{
|
||||
addrs.ConfigResource{
|
||||
Resource: addrs.Resource{
|
||||
Mode: addrs.ManagedResourceMode,
|
||||
Type: "aws_instance",
|
||||
Name: "foo",
|
||||
},
|
||||
Module: child.Addr,
|
||||
Module: child.Addr.Module(),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -2708,7 +2708,7 @@ func TestContext2Apply_moduleDestroyOrder(t *testing.T) {
|
|||
&states.ResourceInstanceObjectSrc{
|
||||
Status: states.ObjectReady,
|
||||
AttrsJSON: []byte(`{"id":"b"}`),
|
||||
Dependencies: []addrs.AbsResource{mustResourceAddr("module.child.aws_instance.a")},
|
||||
Dependencies: []addrs.ConfigResource{mustResourceAddr("module.child.aws_instance.a")},
|
||||
},
|
||||
mustProviderConfig(`provider["registry.terraform.io/-/aws"]`),
|
||||
)
|
||||
|
@ -3170,8 +3170,8 @@ func TestContext2Apply_moduleProviderAliasTargets(t *testing.T) {
|
|||
},
|
||||
),
|
||||
Targets: []addrs.Targetable{
|
||||
addrs.AbsResource{
|
||||
Module: addrs.RootModuleInstance,
|
||||
addrs.ConfigResource{
|
||||
Module: addrs.RootModule,
|
||||
Resource: addrs.Resource{
|
||||
Mode: addrs.ManagedResourceMode,
|
||||
Type: "nonexistent",
|
||||
|
@ -8025,7 +8025,7 @@ func TestContext2Apply_targetedDestroyCountDeps(t *testing.T) {
|
|||
&states.ResourceInstanceObjectSrc{
|
||||
Status: states.ObjectReady,
|
||||
AttrsJSON: []byte(`{"id":"i-abc123"}`),
|
||||
Dependencies: []addrs.AbsResource{mustResourceAddr("aws_instance.foo")},
|
||||
Dependencies: []addrs.ConfigResource{mustResourceAddr("aws_instance.foo")},
|
||||
},
|
||||
mustProviderConfig(`provider["registry.terraform.io/-/aws"]`),
|
||||
)
|
||||
|
@ -8631,14 +8631,14 @@ func TestContext2Apply_createBefore_depends(t *testing.T) {
|
|||
&states.ResourceInstanceObjectSrc{
|
||||
Status: states.ObjectReady,
|
||||
AttrsJSON: []byte(`{"id":"baz","instance":"bar"}`),
|
||||
Dependencies: []addrs.AbsResource{
|
||||
addrs.AbsResource{
|
||||
Dependencies: []addrs.ConfigResource{
|
||||
addrs.ConfigResource{
|
||||
Resource: addrs.Resource{
|
||||
Mode: addrs.ManagedResourceMode,
|
||||
Type: "aws_instance",
|
||||
Name: "web",
|
||||
},
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -8764,14 +8764,14 @@ func TestContext2Apply_singleDestroy(t *testing.T) {
|
|||
&states.ResourceInstanceObjectSrc{
|
||||
Status: states.ObjectReady,
|
||||
AttrsJSON: []byte(`{"id":"baz","instance":"bar"}`),
|
||||
Dependencies: []addrs.AbsResource{
|
||||
addrs.AbsResource{
|
||||
Dependencies: []addrs.ConfigResource{
|
||||
addrs.ConfigResource{
|
||||
Resource: addrs.Resource{
|
||||
Mode: addrs.ManagedResourceMode,
|
||||
Type: "aws_instance",
|
||||
Name: "web",
|
||||
},
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -10639,22 +10639,22 @@ func TestContext2Apply_cbdCycle(t *testing.T) {
|
|||
&states.ResourceInstanceObjectSrc{
|
||||
Status: states.ObjectReady,
|
||||
AttrsJSON: []byte(`{"id":"a","require_new":"old","foo":"b"}`),
|
||||
Dependencies: []addrs.AbsResource{
|
||||
addrs.AbsResource{
|
||||
Dependencies: []addrs.ConfigResource{
|
||||
addrs.ConfigResource{
|
||||
Resource: addrs.Resource{
|
||||
Mode: addrs.ManagedResourceMode,
|
||||
Type: "test_instance",
|
||||
Name: "b",
|
||||
},
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
addrs.AbsResource{
|
||||
addrs.ConfigResource{
|
||||
Resource: addrs.Resource{
|
||||
Mode: addrs.ManagedResourceMode,
|
||||
Type: "test_instance",
|
||||
Name: "c",
|
||||
},
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -10672,14 +10672,14 @@ func TestContext2Apply_cbdCycle(t *testing.T) {
|
|||
&states.ResourceInstanceObjectSrc{
|
||||
Status: states.ObjectReady,
|
||||
AttrsJSON: []byte(`{"id":"b","require_new":"old","foo":"c"}`),
|
||||
Dependencies: []addrs.AbsResource{
|
||||
addrs.AbsResource{
|
||||
Dependencies: []addrs.ConfigResource{
|
||||
addrs.ConfigResource{
|
||||
Resource: addrs.Resource{
|
||||
Mode: addrs.ManagedResourceMode,
|
||||
Type: "test_instance",
|
||||
Name: "c",
|
||||
},
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -1985,10 +1985,10 @@ func TestRefresh_updateDependencies(t *testing.T) {
|
|||
&states.ResourceInstanceObjectSrc{
|
||||
Status: states.ObjectReady,
|
||||
AttrsJSON: []byte(`{"id":"foo"}`),
|
||||
Dependencies: []addrs.AbsResource{
|
||||
Dependencies: []addrs.ConfigResource{
|
||||
// Existing dependencies should not be removed during refresh
|
||||
{
|
||||
Module: addrs.RootModuleInstance,
|
||||
Module: addrs.RootModule,
|
||||
Resource: addrs.Resource{
|
||||
Mode: addrs.ManagedResourceMode,
|
||||
Type: "aws_instance",
|
||||
|
|
|
@ -205,7 +205,7 @@ type EvalWriteState struct {
|
|||
|
||||
// Dependencies are the inter-resource dependencies to be stored in the
|
||||
// state.
|
||||
Dependencies *[]addrs.AbsResource
|
||||
Dependencies *[]addrs.ConfigResource
|
||||
}
|
||||
|
||||
func (n *EvalWriteState) Eval(ctx EvalContext) (interface{}, error) {
|
||||
|
@ -538,7 +538,7 @@ type EvalRefreshDependencies struct {
|
|||
// Prior State
|
||||
State **states.ResourceInstanceObject
|
||||
// Dependencies to write to the new state
|
||||
Dependencies *[]addrs.AbsResource
|
||||
Dependencies *[]addrs.ConfigResource
|
||||
}
|
||||
|
||||
func (n *EvalRefreshDependencies) Eval(ctx EvalContext) (interface{}, error) {
|
||||
|
@ -548,7 +548,7 @@ func (n *EvalRefreshDependencies) Eval(ctx EvalContext) (interface{}, error) {
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
depMap := make(map[string]addrs.AbsResource)
|
||||
depMap := make(map[string]addrs.ConfigResource)
|
||||
for _, d := range *n.Dependencies {
|
||||
depMap[d.String()] = d
|
||||
}
|
||||
|
@ -562,7 +562,7 @@ func (n *EvalRefreshDependencies) Eval(ctx EvalContext) (interface{}, error) {
|
|||
return nil, nil
|
||||
}
|
||||
|
||||
deps := make([]addrs.AbsResource, 0, len(depMap))
|
||||
deps := make([]addrs.ConfigResource, 0, len(depMap))
|
||||
for _, d := range depMap {
|
||||
deps = append(deps, d)
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ func TestApplyGraphBuilder_depCbd(t *testing.T) {
|
|||
&states.ResourceInstanceObjectSrc{
|
||||
Status: states.ObjectReady,
|
||||
AttrsJSON: []byte(`{"id":"B","test_list":["x"]}`),
|
||||
Dependencies: []addrs.AbsResource{mustResourceAddr("test_object.A")},
|
||||
Dependencies: []addrs.ConfigResource{mustResourceAddr("test_object.A")},
|
||||
},
|
||||
mustProviderConfig(`provider["registry.terraform.io/-/test"]`),
|
||||
)
|
||||
|
@ -273,7 +273,7 @@ func TestApplyGraphBuilder_destroyStateOnly(t *testing.T) {
|
|||
&states.ResourceInstanceObjectSrc{
|
||||
Status: states.ObjectReady,
|
||||
AttrsJSON: []byte(`{"id":"bar"}`),
|
||||
Dependencies: []addrs.AbsResource{mustResourceAddr("module.child.test_object.A")},
|
||||
Dependencies: []addrs.ConfigResource{mustResourceAddr("module.child.test_object.A")},
|
||||
},
|
||||
mustProviderConfig(`provider["registry.terraform.io/-/test"]`),
|
||||
)
|
||||
|
@ -378,7 +378,7 @@ func TestApplyGraphBuilder_moduleDestroy(t *testing.T) {
|
|||
&states.ResourceInstanceObjectSrc{
|
||||
Status: states.ObjectReady,
|
||||
AttrsJSON: []byte(`{"id":"foo","value":"foo"}`),
|
||||
Dependencies: []addrs.AbsResource{mustResourceAddr("module.A.test_object.foo")},
|
||||
Dependencies: []addrs.ConfigResource{mustResourceAddr("module.A.test_object.foo")},
|
||||
},
|
||||
mustProviderConfig(`provider["registry.terraform.io/-/test"]`),
|
||||
)
|
||||
|
@ -566,14 +566,14 @@ func TestApplyGraphBuilder_updateFromOrphan(t *testing.T) {
|
|||
&states.ResourceInstanceObjectSrc{
|
||||
Status: states.ObjectReady,
|
||||
AttrsJSON: []byte(`{"id":"b_id","test_string":"a_id"}`),
|
||||
Dependencies: []addrs.AbsResource{
|
||||
addrs.AbsResource{
|
||||
Dependencies: []addrs.ConfigResource{
|
||||
addrs.ConfigResource{
|
||||
Resource: addrs.Resource{
|
||||
Mode: addrs.ManagedResourceMode,
|
||||
Type: "test_object",
|
||||
Name: "a",
|
||||
},
|
||||
Module: root.Addr,
|
||||
Module: root.Addr.Module(),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -670,14 +670,14 @@ func TestApplyGraphBuilder_updateFromCBDOrphan(t *testing.T) {
|
|||
&states.ResourceInstanceObjectSrc{
|
||||
Status: states.ObjectReady,
|
||||
AttrsJSON: []byte(`{"id":"b_id","test_string":"a_id"}`),
|
||||
Dependencies: []addrs.AbsResource{
|
||||
addrs.AbsResource{
|
||||
Dependencies: []addrs.ConfigResource{
|
||||
addrs.ConfigResource{
|
||||
Resource: addrs.Resource{
|
||||
Mode: addrs.ManagedResourceMode,
|
||||
Type: "test_object",
|
||||
Name: "a",
|
||||
},
|
||||
Module: root.Addr,
|
||||
Module: root.Addr.Module(),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -36,7 +36,7 @@ type GraphNodeResourceInstance interface {
|
|||
|
||||
// StateDependencies returns any inter-resource dependencies that are
|
||||
// stored in the state.
|
||||
StateDependencies() []addrs.AbsResource
|
||||
StateDependencies() []addrs.ConfigResource
|
||||
}
|
||||
|
||||
// NodeAbstractResource represents a resource that has no associated
|
||||
|
@ -99,7 +99,7 @@ type NodeAbstractResourceInstance struct {
|
|||
// interfaces if you're running those transforms, but also be explicitly
|
||||
// set if you already have that information.
|
||||
ResourceState *states.Resource
|
||||
Dependencies []addrs.AbsResource
|
||||
Dependencies []addrs.ConfigResource
|
||||
}
|
||||
|
||||
var (
|
||||
|
@ -142,11 +142,6 @@ func (n *NodeAbstractResourceInstance) Name() string {
|
|||
return n.ResourceInstanceAddr().String()
|
||||
}
|
||||
|
||||
//// GraphNodeModuleInstance
|
||||
//func (n *NodeAbstractResource) Path() addrs.ModuleInstance {
|
||||
// return n.Addr.Module.UnkeyedInstanceShim()
|
||||
//}
|
||||
|
||||
func (n *NodeAbstractResourceInstance) Path() addrs.ModuleInstance {
|
||||
return n.Addr.Module
|
||||
}
|
||||
|
@ -271,7 +266,7 @@ func dottedInstanceAddr(tr addrs.ResourceInstance) string {
|
|||
}
|
||||
|
||||
// StateDependencies returns the dependencies saved in the state.
|
||||
func (n *NodeAbstractResourceInstance) StateDependencies() []addrs.AbsResource {
|
||||
func (n *NodeAbstractResourceInstance) StateDependencies() []addrs.ConfigResource {
|
||||
if rs := n.ResourceState; rs != nil {
|
||||
if s := rs.Instance(n.Addr.Resource.Key); s != nil {
|
||||
if s.Current != nil {
|
||||
|
|
|
@ -24,7 +24,7 @@ type NodeApplyableResourceInstance struct {
|
|||
*NodeAbstractResourceInstance
|
||||
|
||||
destroyNode GraphNodeDestroyerCBD
|
||||
graphNodeDeposer // implementation of GraphNodeDeposer
|
||||
graphNodeDeposer // implementation of GraphNodeDeposerConfig
|
||||
}
|
||||
|
||||
var (
|
||||
|
@ -100,12 +100,7 @@ func (n *NodeApplyableResourceInstance) References() []*addrs.Reference {
|
|||
|
||||
// GraphNodeAttachDependencies
|
||||
func (n *NodeApplyableResourceInstance) AttachDependencies(deps []addrs.ConfigResource) {
|
||||
var shimmed []addrs.AbsResource
|
||||
for _, r := range deps {
|
||||
shimmed = append(shimmed, r.Absolute(r.Module.UnkeyedInstanceShim()))
|
||||
}
|
||||
|
||||
n.Dependencies = shimmed
|
||||
n.Dependencies = deps
|
||||
}
|
||||
|
||||
// GraphNodeEvalable
|
||||
|
|
|
@ -19,7 +19,7 @@ type nodeExpandRefreshableManagedResource struct {
|
|||
|
||||
// We attach dependencies to the Resource during refresh, since the
|
||||
// instances are instantiated during DynamicExpand.
|
||||
Dependencies []addrs.AbsResource
|
||||
Dependencies []addrs.ConfigResource
|
||||
}
|
||||
|
||||
var (
|
||||
|
@ -33,12 +33,7 @@ var (
|
|||
|
||||
// GraphNodeAttachDependencies
|
||||
func (n *nodeExpandRefreshableManagedResource) AttachDependencies(deps []addrs.ConfigResource) {
|
||||
var shimmed []addrs.AbsResource
|
||||
for _, r := range deps {
|
||||
shimmed = append(shimmed, r.Absolute(r.Module.UnkeyedInstanceShim()))
|
||||
}
|
||||
|
||||
n.Dependencies = shimmed
|
||||
n.Dependencies = deps
|
||||
}
|
||||
|
||||
func (n *nodeExpandRefreshableManagedResource) References() []*addrs.Reference {
|
||||
|
@ -69,7 +64,7 @@ type NodeRefreshableManagedResource struct {
|
|||
|
||||
// We attach dependencies to the Resource during refresh, since the
|
||||
// instances are instantiated during DynamicExpand.
|
||||
Dependencies []addrs.AbsResource
|
||||
Dependencies []addrs.ConfigResource
|
||||
}
|
||||
|
||||
var (
|
||||
|
|
|
@ -210,12 +210,12 @@ func mustResourceInstanceAddr(s string) addrs.AbsResourceInstance {
|
|||
return addr
|
||||
}
|
||||
|
||||
func mustResourceAddr(s string) addrs.AbsResource {
|
||||
func mustResourceAddr(s string) addrs.ConfigResource {
|
||||
addr, diags := addrs.ParseAbsResourceStr(s)
|
||||
if diags.HasErrors() {
|
||||
panic(diags.Err())
|
||||
}
|
||||
return addr
|
||||
return addr.Config()
|
||||
}
|
||||
|
||||
func mustProviderConfig(s string) addrs.AbsProviderConfig {
|
||||
|
|
|
@ -94,7 +94,7 @@ func TestCBDEdgeTransformer(t *testing.T) {
|
|||
&states.ResourceInstanceObjectSrc{
|
||||
Status: states.ObjectReady,
|
||||
AttrsJSON: []byte(`{"id":"B","test_list":["x"]}`),
|
||||
Dependencies: []addrs.AbsResource{mustResourceAddr("test_object.A")},
|
||||
Dependencies: []addrs.ConfigResource{mustResourceAddr("test_object.A")},
|
||||
},
|
||||
mustProviderConfig(`provider["registry.terraform.io/-/test"]`),
|
||||
)
|
||||
|
@ -164,7 +164,7 @@ func TestCBDEdgeTransformerMulti(t *testing.T) {
|
|||
&states.ResourceInstanceObjectSrc{
|
||||
Status: states.ObjectReady,
|
||||
AttrsJSON: []byte(`{"id":"C","test_list":["x"]}`),
|
||||
Dependencies: []addrs.AbsResource{
|
||||
Dependencies: []addrs.ConfigResource{
|
||||
mustResourceAddr("test_object.A"),
|
||||
mustResourceAddr("test_object.B"),
|
||||
},
|
||||
|
@ -234,7 +234,7 @@ func TestCBDEdgeTransformer_depNonCBDCount(t *testing.T) {
|
|||
&states.ResourceInstanceObjectSrc{
|
||||
Status: states.ObjectReady,
|
||||
AttrsJSON: []byte(`{"id":"B","test_list":["x"]}`),
|
||||
Dependencies: []addrs.AbsResource{mustResourceAddr("test_object.A")},
|
||||
Dependencies: []addrs.ConfigResource{mustResourceAddr("test_object.A")},
|
||||
},
|
||||
mustProviderConfig(`provider["registry.terraform.io/-/test"]`),
|
||||
)
|
||||
|
@ -243,7 +243,7 @@ func TestCBDEdgeTransformer_depNonCBDCount(t *testing.T) {
|
|||
&states.ResourceInstanceObjectSrc{
|
||||
Status: states.ObjectReady,
|
||||
AttrsJSON: []byte(`{"id":"B","test_list":["x"]}`),
|
||||
Dependencies: []addrs.AbsResource{mustResourceAddr("test_object.A")},
|
||||
Dependencies: []addrs.ConfigResource{mustResourceAddr("test_object.A")},
|
||||
},
|
||||
mustProviderConfig(`provider["registry.terraform.io/-/test"]`),
|
||||
)
|
||||
|
@ -320,7 +320,7 @@ func TestCBDEdgeTransformer_depNonCBDCountBoth(t *testing.T) {
|
|||
&states.ResourceInstanceObjectSrc{
|
||||
Status: states.ObjectReady,
|
||||
AttrsJSON: []byte(`{"id":"B","test_list":["x"]}`),
|
||||
Dependencies: []addrs.AbsResource{mustResourceAddr("test_object.A")},
|
||||
Dependencies: []addrs.ConfigResource{mustResourceAddr("test_object.A")},
|
||||
},
|
||||
mustProviderConfig(`provider["registry.terraform.io/-/test"]`),
|
||||
)
|
||||
|
@ -329,7 +329,7 @@ func TestCBDEdgeTransformer_depNonCBDCountBoth(t *testing.T) {
|
|||
&states.ResourceInstanceObjectSrc{
|
||||
Status: states.ObjectReady,
|
||||
AttrsJSON: []byte(`{"id":"B","test_list":["x"]}`),
|
||||
Dependencies: []addrs.AbsResource{mustResourceAddr("test_object.A")},
|
||||
Dependencies: []addrs.ConfigResource{mustResourceAddr("test_object.A")},
|
||||
},
|
||||
mustProviderConfig(`provider["registry.terraform.io/-/test"]`),
|
||||
)
|
||||
|
|
|
@ -28,7 +28,7 @@ func TestDestroyEdgeTransformer_basic(t *testing.T) {
|
|||
&states.ResourceInstanceObjectSrc{
|
||||
Status: states.ObjectReady,
|
||||
AttrsJSON: []byte(`{"id":"B","test_string":"x"}`),
|
||||
Dependencies: []addrs.AbsResource{mustResourceAddr("test_object.A")},
|
||||
Dependencies: []addrs.ConfigResource{mustResourceAddr("test_object.A")},
|
||||
},
|
||||
mustProviderConfig(`provider["registry.terraform.io/-/test"]`),
|
||||
)
|
||||
|
@ -72,7 +72,7 @@ func TestDestroyEdgeTransformer_multi(t *testing.T) {
|
|||
&states.ResourceInstanceObjectSrc{
|
||||
Status: states.ObjectReady,
|
||||
AttrsJSON: []byte(`{"id":"B","test_string":"x"}`),
|
||||
Dependencies: []addrs.AbsResource{mustResourceAddr("test_object.A")},
|
||||
Dependencies: []addrs.ConfigResource{mustResourceAddr("test_object.A")},
|
||||
},
|
||||
mustProviderConfig(`provider["registry.terraform.io/-/test"]`),
|
||||
)
|
||||
|
@ -81,7 +81,7 @@ func TestDestroyEdgeTransformer_multi(t *testing.T) {
|
|||
&states.ResourceInstanceObjectSrc{
|
||||
Status: states.ObjectReady,
|
||||
AttrsJSON: []byte(`{"id":"C","test_string":"x"}`),
|
||||
Dependencies: []addrs.AbsResource{
|
||||
Dependencies: []addrs.ConfigResource{
|
||||
mustResourceAddr("test_object.A"),
|
||||
mustResourceAddr("test_object.B"),
|
||||
},
|
||||
|
@ -138,7 +138,7 @@ func TestDestroyEdgeTransformer_module(t *testing.T) {
|
|||
&states.ResourceInstanceObjectSrc{
|
||||
Status: states.ObjectReady,
|
||||
AttrsJSON: []byte(`{"id":"a"}`),
|
||||
Dependencies: []addrs.AbsResource{mustResourceAddr("module.child.test_object.b")},
|
||||
Dependencies: []addrs.ConfigResource{mustResourceAddr("module.child.test_object.b")},
|
||||
},
|
||||
mustProviderConfig(`provider["registry.terraform.io/-/test"]`),
|
||||
)
|
||||
|
@ -191,7 +191,7 @@ func TestDestroyEdgeTransformer_moduleOnly(t *testing.T) {
|
|||
&states.ResourceInstanceObjectSrc{
|
||||
Status: states.ObjectReady,
|
||||
AttrsJSON: []byte(`{"id":"b","test_string":"x"}`),
|
||||
Dependencies: []addrs.AbsResource{mustResourceAddr("module.child.test_object.a")},
|
||||
Dependencies: []addrs.ConfigResource{mustResourceAddr("module.child.test_object.a")},
|
||||
},
|
||||
mustProviderConfig(`provider["registry.terraform.io/-/test"]`),
|
||||
)
|
||||
|
@ -200,7 +200,7 @@ func TestDestroyEdgeTransformer_moduleOnly(t *testing.T) {
|
|||
&states.ResourceInstanceObjectSrc{
|
||||
Status: states.ObjectReady,
|
||||
AttrsJSON: []byte(`{"id":"c","test_string":"x"}`),
|
||||
Dependencies: []addrs.AbsResource{
|
||||
Dependencies: []addrs.ConfigResource{
|
||||
mustResourceAddr("module.child.test_object.a"),
|
||||
mustResourceAddr("module.child.test_object.b"),
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue