terraform: deep copy the state when refreshing
This commit is contained in:
parent
cb80118674
commit
e5e4ac7548
|
@ -80,6 +80,10 @@ func (c *Context2) GraphBuilder() GraphBuilder {
|
|||
// Even in the case an error is returned, the state will be returned and
|
||||
// will potentially be partially updated.
|
||||
func (c *Context2) Refresh() (*State, []error) {
|
||||
// Copy our own state
|
||||
c.state = c.state.deepcopy()
|
||||
|
||||
// Do the walk
|
||||
if _, err := c.walk(walkRefresh); err != nil {
|
||||
var errs error
|
||||
return nil, multierror.Append(errs, err).Errors
|
||||
|
|
|
@ -315,8 +315,7 @@ func TestContext2Refresh_outputPartial(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
/*
|
||||
func TestContextRefresh_state(t *testing.T) {
|
||||
func TestContext2Refresh_state(t *testing.T) {
|
||||
p := testProvider("aws")
|
||||
m := testModule(t, "refresh-basic")
|
||||
state := &State{
|
||||
|
@ -333,7 +332,7 @@ func TestContextRefresh_state(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}
|
||||
ctx := testContext(t, &ContextOpts{
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"aws": testProviderFuncFixed(p),
|
||||
|
@ -356,13 +355,17 @@ func TestContextRefresh_state(t *testing.T) {
|
|||
t.Fatal("refresh should be called")
|
||||
}
|
||||
if !reflect.DeepEqual(p.RefreshState, originalMod.Resources["aws_instance.web"].Primary) {
|
||||
t.Fatalf("bad: %#v %#v", p.RefreshState, originalMod.Resources["aws_instance.web"].Primary)
|
||||
t.Fatalf(
|
||||
"bad:\n\n%#v\n\n%#v",
|
||||
p.RefreshState,
|
||||
originalMod.Resources["aws_instance.web"].Primary)
|
||||
}
|
||||
if !reflect.DeepEqual(mod.Resources["aws_instance.web"].Primary, p.RefreshReturn) {
|
||||
t.Fatalf("bad: %#v", mod.Resources)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
func TestContextRefresh_tainted(t *testing.T) {
|
||||
p := testProvider("aws")
|
||||
m := testModule(t, "refresh-basic")
|
||||
|
|
Loading…
Reference in New Issue