terraform: instance => module
This commit is contained in:
parent
4d268b6eca
commit
163f19fd00
|
@ -159,6 +159,15 @@ func stateAddFunc_Instance_Instance(s *State, fromAddr, addr *ResourceAddress, r
|
|||
return nil
|
||||
}
|
||||
|
||||
func stateAddFunc_Instance_Module(
|
||||
s *State, from, to *ResourceAddress, raw interface{}) error {
|
||||
addr := *to
|
||||
addr.Type = from.Type
|
||||
addr.Name = from.Name
|
||||
|
||||
return s.Add(from.String(), addr.String(), raw)
|
||||
}
|
||||
|
||||
func stateAddFunc_Instance_Resource(
|
||||
s *State, from, to *ResourceAddress, raw interface{}) error {
|
||||
addr := *to
|
||||
|
@ -185,6 +194,7 @@ func init() {
|
|||
},
|
||||
stateAddInstance: {
|
||||
stateAddInstance: stateAddFunc_Instance_Instance,
|
||||
stateAddModule: stateAddFunc_Instance_Module,
|
||||
stateAddResource: stateAddFunc_Instance_Resource,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -317,6 +317,32 @@ func TestStateAdd(t *testing.T) {
|
|||
},
|
||||
},
|
||||
},
|
||||
|
||||
"InstanceState => Module (new)": {
|
||||
false,
|
||||
"aws_instance.bar.primary",
|
||||
"module.foo",
|
||||
&InstanceState{
|
||||
ID: "foo",
|
||||
},
|
||||
|
||||
&State{},
|
||||
&State{
|
||||
Modules: []*ModuleState{
|
||||
&ModuleState{
|
||||
Path: []string{"root", "foo"},
|
||||
Resources: map[string]*ResourceState{
|
||||
"aws_instance.bar": &ResourceState{
|
||||
Type: "aws_instance",
|
||||
Primary: &InstanceState{
|
||||
ID: "foo",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for k, tc := range cases {
|
||||
|
|
Loading…
Reference in New Issue