Merge pull request #26461 from hashicorp/jbardin/refresh-false
always load instance state when -refresh=false
This commit is contained in:
commit
804449eda1
|
@ -6403,12 +6403,18 @@ resource "test_instance" "a" {
|
|||
SkipRefresh: true,
|
||||
})
|
||||
|
||||
_, diags := ctx.Plan()
|
||||
plan, diags := ctx.Plan()
|
||||
assertNoErrors(t, diags)
|
||||
|
||||
if p.ReadResourceCalled {
|
||||
t.Fatal("Resource should not have been refreshed")
|
||||
}
|
||||
|
||||
for _, c := range plan.Changes.Resources {
|
||||
if c.Action != plans.NoOp {
|
||||
t.Fatalf("expected no changes, got %s for %q", c.Action, c.Addr)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestContext2Plan_dataInModuleDependsOn(t *testing.T) {
|
||||
|
|
|
@ -146,24 +146,23 @@ func (n *NodePlannableResourceInstance) managedResourceExecute(ctx EvalContext,
|
|||
return err
|
||||
}
|
||||
|
||||
instanceRefreshState, err = n.ReadResourceInstanceState(ctx, addr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
refreshLifecycle := &EvalRefreshLifecycle{
|
||||
Addr: addr,
|
||||
Config: n.Config,
|
||||
State: &instanceRefreshState,
|
||||
ForceCreateBeforeDestroy: n.ForceCreateBeforeDestroy,
|
||||
}
|
||||
_, err = refreshLifecycle.Eval(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Refresh, maybe
|
||||
if !skipRefresh {
|
||||
instanceRefreshState, err = n.ReadResourceInstanceState(ctx, addr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
refreshLifecycle := &EvalRefreshLifecycle{
|
||||
Addr: addr,
|
||||
Config: n.Config,
|
||||
State: &instanceRefreshState,
|
||||
ForceCreateBeforeDestroy: n.ForceCreateBeforeDestroy,
|
||||
}
|
||||
_, err = refreshLifecycle.Eval(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
refresh := &EvalRefresh{
|
||||
Addr: addr.Resource,
|
||||
ProviderAddr: n.ResolvedProvider,
|
||||
|
|
Loading…
Reference in New Issue