maintain private data through provider ACC tests
The private->meta data was lost in the test harness.
This commit is contained in:
parent
49fee6ba78
commit
4cb6ebe22c
|
@ -1,6 +1,7 @@
|
|||
package resource
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
|
||||
"github.com/hashicorp/terraform/addrs"
|
||||
|
@ -52,20 +53,33 @@ func shimNewState(newState *states.State, providers map[string]terraform.Resourc
|
|||
resource := getResource(providers, providerType, res.Addr)
|
||||
|
||||
for key, i := range res.Instances {
|
||||
resState := &terraform.ResourceState{
|
||||
Type: resType,
|
||||
Provider: res.ProviderConfig.String(),
|
||||
}
|
||||
|
||||
// We should always have a Current instance here, but be safe about checking.
|
||||
if i.Current != nil {
|
||||
flatmap, err := shimmedAttributes(i.Current, resource)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("error decoding state for %q: %s", resType, err)
|
||||
}
|
||||
|
||||
resState := &terraform.ResourceState{
|
||||
Type: resType,
|
||||
Primary: &terraform.InstanceState{
|
||||
var meta map[string]interface{}
|
||||
if i.Current.Private != nil {
|
||||
err := json.Unmarshal(i.Current.Private, &meta)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
resState.Primary = &terraform.InstanceState{
|
||||
ID: flatmap["id"],
|
||||
Attributes: flatmap,
|
||||
Tainted: i.Current.Status == states.ObjectTainted,
|
||||
},
|
||||
Provider: res.ProviderConfig.String(),
|
||||
Meta: meta,
|
||||
}
|
||||
|
||||
if i.Current.SchemaVersion != 0 {
|
||||
resState.Primary.Meta = map[string]interface{}{
|
||||
"schema_version": i.Current.SchemaVersion,
|
||||
|
@ -89,6 +103,7 @@ func shimNewState(newState *states.State, providers map[string]terraform.Resourc
|
|||
}
|
||||
|
||||
mod.Resources[res.Addr.String()+idx] = resState
|
||||
}
|
||||
|
||||
// add any deposed instances
|
||||
for _, dep := range i.Deposed {
|
||||
|
@ -97,10 +112,19 @@ func shimNewState(newState *states.State, providers map[string]terraform.Resourc
|
|||
return nil, fmt.Errorf("error decoding deposed state for %q: %s", resType, err)
|
||||
}
|
||||
|
||||
var meta map[string]interface{}
|
||||
if dep.Private != nil {
|
||||
err := json.Unmarshal(dep.Private, &meta)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
deposed := &terraform.InstanceState{
|
||||
ID: flatmap["id"],
|
||||
Attributes: flatmap,
|
||||
Tainted: dep.Status == states.ObjectTainted,
|
||||
Meta: meta,
|
||||
}
|
||||
if dep.SchemaVersion != 0 {
|
||||
deposed.Meta = map[string]interface{}{
|
||||
|
|
Loading…
Reference in New Issue