Skip to content
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion command/apply_destroy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
6 changes: 3 additions & 3 deletions command/command_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down Expand Up @@ -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()
}
8 changes: 4 additions & 4 deletions command/refresh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion command/show_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
8 changes: 4 additions & 4 deletions command/state_mv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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"),
Expand Down Expand Up @@ -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"),
Expand Down
16 changes: 0 additions & 16 deletions configs/module_call.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,26 +68,10 @@ func decodeModuleBlock(block *hcl.Block, override bool) (*ModuleCall, hcl.Diagno

if attr, exists := content.Attributes["count"]; exists {
mc.Count = attr.Expr

// We currently parse this, but don't yet do anything with it.
diags = append(diags, &hcl.Diagnostic{
Severity: hcl.DiagError,
Summary: "Reserved argument name in module block",
Detail: fmt.Sprintf("The name %q is reserved for use in a future version of Terraform.", attr.Name),
Subject: &attr.NameRange,
})
}

if attr, exists := content.Attributes["for_each"]; exists {
mc.ForEach = attr.Expr

// We currently parse this, but don't yet do anything with it.
diags = append(diags, &hcl.Diagnostic{
Severity: hcl.DiagError,
Summary: "Reserved argument name in module block",
Detail: fmt.Sprintf("The name %q is reserved for use in a future version of Terraform.", attr.Name),
Subject: &attr.NameRange,
})
}

if attr, exists := content.Attributes["depends_on"]; exists {
Expand Down
2 changes: 0 additions & 2 deletions configs/module_call_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ func TestLoadModuleCall(t *testing.T) {

file, diags := parser.LoadConfigFile("module-calls.tf")
assertExactDiagnostics(t, diags, []string{
`module-calls.tf:19,3-8: Reserved argument name in module block; The name "count" is reserved for use in a future version of Terraform.`,
`module-calls.tf:20,3-11: Reserved argument name in module block; The name "for_each" is reserved for use in a future version of Terraform.`,
`module-calls.tf:22,3-13: Reserved argument name in module block; The name "depends_on" is reserved for use in a future version of Terraform.`,
})

Expand Down
2 changes: 1 addition & 1 deletion states/instance_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion states/instance_object_src.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ type ResourceInstanceObjectSrc struct {
// ResourceInstanceObject.
Private []byte
Status ObjectStatus
Dependencies []addrs.AbsResource
Dependencies []addrs.ConfigResource
CreateBeforeDestroy bool
// deprecated
DependsOn []addrs.Referenceable
Expand Down
8 changes: 4 additions & 4 deletions states/state_deepcopy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down Expand Up @@ -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)
}

Expand Down
6 changes: 3 additions & 3 deletions states/state_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions states/statefile/version4.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Loading