terraform: Ensure ConnInfo is initialized

This commit is contained in:
Armon Dadgar 2014-07-14 16:41:57 -07:00
parent 2b6d7dc0b9
commit fec8e95a09
2 changed files with 12 additions and 0 deletions

View File

@ -467,6 +467,14 @@ func (c *Context) applyWalkFn() depgraph.WalkFunc {
diff.init() diff.init()
} }
// If we do not have any connection info, initialize
if r.State.ConnInfo == nil {
r.State.ConnInfo = &ResourceConnectionInfo{}
}
if r.State.ConnInfo.Raw == nil {
r.State.ConnInfo.Raw = make(map[string]interface{})
}
// Remove any output values from the diff // Remove any output values from the diff
for k, ad := range diff.Attributes { for k, ad := range diff.Attributes {
if ad.Type == DiffAttrOutput { if ad.Type == DiffAttrOutput {

View File

@ -513,6 +513,10 @@ func TestContextApply_Provisioner_ConnInfo(t *testing.T) {
pr := testProvisioner() pr := testProvisioner()
p.ApplyFn = func(s *ResourceState, d *ResourceDiff) (*ResourceState, error) { p.ApplyFn = func(s *ResourceState, d *ResourceDiff) (*ResourceState, error) {
if s.ConnInfo == nil || s.ConnInfo.Raw == nil {
t.Fatalf("ConnInfo not initialized")
}
result, _ := testApplyFn(s, d) result, _ := testApplyFn(s, d)
result.ConnInfo = &ResourceConnectionInfo{ result.ConnInfo = &ResourceConnectionInfo{
Raw: map[string]interface{}{ Raw: map[string]interface{}{