terraform: copy deps and provider for resource state
This commit is contained in:
parent
cb060f9063
commit
e65a726936
|
@ -95,7 +95,7 @@ func stateAddFunc_Module_Module(s *State, addr *ResourceAddress, raw interface{}
|
|||
}
|
||||
|
||||
func stateAddFunc_Resource_Resource(s *State, addr *ResourceAddress, raw interface{}) error {
|
||||
src := raw.(*ResourceState)
|
||||
src := raw.(*ResourceState).deepcopy()
|
||||
|
||||
// Initialize the resource
|
||||
resourceRaw, exists := stateAddInitAddr(s, addr)
|
||||
|
@ -104,9 +104,8 @@ func stateAddFunc_Resource_Resource(s *State, addr *ResourceAddress, raw interfa
|
|||
}
|
||||
resource := resourceRaw.(*ResourceState)
|
||||
resource.Type = src.Type
|
||||
|
||||
// TODO: Dependencies
|
||||
// TODO: Provider?
|
||||
resource.Dependencies = src.Dependencies
|
||||
resource.Provider = src.Provider
|
||||
|
||||
// Move the primary
|
||||
if src.Primary != nil {
|
||||
|
|
|
@ -163,6 +163,38 @@ func TestStateAdd(t *testing.T) {
|
|||
},
|
||||
},
|
||||
|
||||
"ResourceState w/ deps, provider => Resource Addr (new)": {
|
||||
false,
|
||||
"aws_instance.foo",
|
||||
&ResourceState{
|
||||
Type: "test_instance",
|
||||
Provider: "foo",
|
||||
Dependencies: []string{"bar"},
|
||||
Primary: &InstanceState{
|
||||
ID: "foo",
|
||||
},
|
||||
},
|
||||
|
||||
&State{},
|
||||
&State{
|
||||
Modules: []*ModuleState{
|
||||
&ModuleState{
|
||||
Path: []string{"root"},
|
||||
Resources: map[string]*ResourceState{
|
||||
"aws_instance.foo": &ResourceState{
|
||||
Type: "test_instance",
|
||||
Provider: "foo",
|
||||
Dependencies: []string{"bar"},
|
||||
Primary: &InstanceState{
|
||||
ID: "foo",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
"ResourceState => Resource Addr (existing)": {
|
||||
true,
|
||||
"aws_instance.foo",
|
||||
|
|
Loading…
Reference in New Issue