Set proper Mode when moving a data source in state
ResourceAddr.Mode wasn't properly set when moving a module, so data sources would lose the "data." prefix when their module was moved within the State.
This commit is contained in:
parent
c908f3ceae
commit
705527e6fe
|
@ -113,7 +113,7 @@ func stateAddFunc_Module_Module(s *State, fromAddr, addr *ResourceAddress, raw i
|
|||
addrCopy.Type = resourceKey.Type
|
||||
addrCopy.Name = resourceKey.Name
|
||||
addrCopy.Index = resourceKey.Index
|
||||
//addrCopy.Mode = resourceKey.Mode
|
||||
addrCopy.Mode = resourceKey.Mode
|
||||
|
||||
// Perform an add
|
||||
if err := s.Add(fromAddr.String(), addrCopy.String(), v); err != nil {
|
||||
|
@ -333,7 +333,7 @@ func stateAddInitAddr(s *State, addr *ResourceAddress) (interface{}, bool) {
|
|||
Name: addr.Name,
|
||||
Type: addr.Type,
|
||||
Index: addr.Index,
|
||||
//Mode: addr.Mode,
|
||||
Mode: addr.Mode,
|
||||
}).String()
|
||||
exists = true
|
||||
resource, ok := mod.Resources[resourceKey]
|
||||
|
|
|
@ -627,6 +627,41 @@ func TestStateAdd(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
"ModuleState => Module Addr (new with data source)",
|
||||
false,
|
||||
"",
|
||||
"module.foo",
|
||||
&ModuleState{
|
||||
Path: rootModulePath,
|
||||
Resources: map[string]*ResourceState{
|
||||
"data.test_instance.foo": &ResourceState{
|
||||
Type: "test_instance",
|
||||
Primary: &InstanceState{
|
||||
ID: "foo",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
&State{},
|
||||
&State{
|
||||
Modules: []*ModuleState{
|
||||
&ModuleState{
|
||||
Path: []string{"root", "foo"},
|
||||
Resources: map[string]*ResourceState{
|
||||
"data.test_instance.foo": &ResourceState{
|
||||
Type: "test_instance",
|
||||
Primary: &InstanceState{
|
||||
ID: "foo",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for i, tc := range cases {
|
||||
|
|
Loading…
Reference in New Issue