Port backend/local: Check dependency lock consistency before any operations
This is a port of the changes made in #29683
This commit is contained in:
parent
d5567b479c
commit
a4e196d067
|
@ -19,6 +19,7 @@ import (
|
||||||
"github.com/hashicorp/terraform/internal/command/arguments"
|
"github.com/hashicorp/terraform/internal/command/arguments"
|
||||||
"github.com/hashicorp/terraform/internal/command/clistate"
|
"github.com/hashicorp/terraform/internal/command/clistate"
|
||||||
"github.com/hashicorp/terraform/internal/command/views"
|
"github.com/hashicorp/terraform/internal/command/views"
|
||||||
|
"github.com/hashicorp/terraform/internal/depsfile"
|
||||||
"github.com/hashicorp/terraform/internal/initwd"
|
"github.com/hashicorp/terraform/internal/initwd"
|
||||||
"github.com/hashicorp/terraform/internal/plans"
|
"github.com/hashicorp/terraform/internal/plans"
|
||||||
"github.com/hashicorp/terraform/internal/plans/planfile"
|
"github.com/hashicorp/terraform/internal/plans/planfile"
|
||||||
|
@ -45,13 +46,19 @@ func testOperationApplyWithTimeout(t *testing.T, configDir string, timeout time.
|
||||||
stateLockerView := views.NewStateLocker(arguments.ViewHuman, view)
|
stateLockerView := views.NewStateLocker(arguments.ViewHuman, view)
|
||||||
operationView := views.NewOperation(arguments.ViewHuman, false, view)
|
operationView := views.NewOperation(arguments.ViewHuman, false, view)
|
||||||
|
|
||||||
|
// Many of our tests use an overridden "null" provider that's just in-memory
|
||||||
|
// inside the test process, not a separate plugin on disk.
|
||||||
|
depLocks := depsfile.NewLocks()
|
||||||
|
depLocks.SetProviderOverridden(addrs.MustParseProviderSourceString("registry.terraform.io/hashicorp/null"))
|
||||||
|
|
||||||
return &backend.Operation{
|
return &backend.Operation{
|
||||||
ConfigDir: configDir,
|
ConfigDir: configDir,
|
||||||
ConfigLoader: configLoader,
|
ConfigLoader: configLoader,
|
||||||
PlanRefresh: true,
|
PlanRefresh: true,
|
||||||
StateLocker: clistate.NewLocker(timeout, stateLockerView),
|
StateLocker: clistate.NewLocker(timeout, stateLockerView),
|
||||||
Type: backend.OperationTypeApply,
|
Type: backend.OperationTypeApply,
|
||||||
View: operationView,
|
View: operationView,
|
||||||
|
DependencyLocks: depLocks,
|
||||||
}, configCleanup, done
|
}, configCleanup, done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ import (
|
||||||
"github.com/hashicorp/terraform/internal/command/arguments"
|
"github.com/hashicorp/terraform/internal/command/arguments"
|
||||||
"github.com/hashicorp/terraform/internal/command/clistate"
|
"github.com/hashicorp/terraform/internal/command/clistate"
|
||||||
"github.com/hashicorp/terraform/internal/command/views"
|
"github.com/hashicorp/terraform/internal/command/views"
|
||||||
|
"github.com/hashicorp/terraform/internal/depsfile"
|
||||||
"github.com/hashicorp/terraform/internal/initwd"
|
"github.com/hashicorp/terraform/internal/initwd"
|
||||||
"github.com/hashicorp/terraform/internal/plans"
|
"github.com/hashicorp/terraform/internal/plans"
|
||||||
"github.com/hashicorp/terraform/internal/plans/planfile"
|
"github.com/hashicorp/terraform/internal/plans/planfile"
|
||||||
|
@ -41,13 +42,19 @@ func testOperationPlanWithTimeout(t *testing.T, configDir string, timeout time.D
|
||||||
stateLockerView := views.NewStateLocker(arguments.ViewHuman, view)
|
stateLockerView := views.NewStateLocker(arguments.ViewHuman, view)
|
||||||
operationView := views.NewOperation(arguments.ViewHuman, false, view)
|
operationView := views.NewOperation(arguments.ViewHuman, false, view)
|
||||||
|
|
||||||
|
// Many of our tests use an overridden "null" provider that's just in-memory
|
||||||
|
// inside the test process, not a separate plugin on disk.
|
||||||
|
depLocks := depsfile.NewLocks()
|
||||||
|
depLocks.SetProviderOverridden(addrs.MustParseProviderSourceString("registry.terraform.io/hashicorp/null"))
|
||||||
|
|
||||||
return &backend.Operation{
|
return &backend.Operation{
|
||||||
ConfigDir: configDir,
|
ConfigDir: configDir,
|
||||||
ConfigLoader: configLoader,
|
ConfigLoader: configLoader,
|
||||||
PlanRefresh: true,
|
PlanRefresh: true,
|
||||||
StateLocker: clistate.NewLocker(timeout, stateLockerView),
|
StateLocker: clistate.NewLocker(timeout, stateLockerView),
|
||||||
Type: backend.OperationTypePlan,
|
Type: backend.OperationTypePlan,
|
||||||
View: operationView,
|
View: operationView,
|
||||||
|
DependencyLocks: depLocks,
|
||||||
}, configCleanup, done
|
}, configCleanup, done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue