backend: Remove Operation.Parallelism field
The presence of this field was confusing because in practice the local backend doesn't use it for anything and the remote backend was using it only to return an error if it's set to anything other than the default, under the assumption that it would always match ContextOpts.Parallelism. The "command" package is the one actually responsible for handling this option, and it does so by placing it into the partial ContextOpts which it passes into the backend when preparing for a local operation. To make that clearer, here we remove Operation.Parallelism and change the few uses of it to refer to ContextOpts.Parallelism instead, so that everyone is reading and writing this value from the same place.
This commit is contained in:
parent
d33a423722
commit
718fa3895f
|
@ -249,7 +249,6 @@ type Operation struct {
|
||||||
// behavior of the operation.
|
// behavior of the operation.
|
||||||
PlanMode plans.Mode
|
PlanMode plans.Mode
|
||||||
AutoApprove bool
|
AutoApprove bool
|
||||||
Parallelism int
|
|
||||||
Targets []addrs.Targetable
|
Targets []addrs.Targetable
|
||||||
ForceReplace []addrs.AbsResourceInstance
|
ForceReplace []addrs.AbsResourceInstance
|
||||||
Variables map[string]UnparsedVariableValue
|
Variables map[string]UnparsedVariableValue
|
||||||
|
|
|
@ -42,7 +42,7 @@ func (b *Remote) opApply(stopCtx, cancelCtx context.Context, op *backend.Operati
|
||||||
return nil, diags.Err()
|
return nil, diags.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
if op.Parallelism != defaultParallelism {
|
if b.ContextOpts != nil && b.ContextOpts.Parallelism != defaultParallelism {
|
||||||
diags = diags.Append(tfdiags.Sourceless(
|
diags = diags.Append(tfdiags.Sourceless(
|
||||||
tfdiags.Error,
|
tfdiags.Error,
|
||||||
"Custom parallelism values are currently not supported",
|
"Custom parallelism values are currently not supported",
|
||||||
|
|
|
@ -46,7 +46,6 @@ func testOperationApplyWithTimeout(t *testing.T, configDir string, timeout time.
|
||||||
return &backend.Operation{
|
return &backend.Operation{
|
||||||
ConfigDir: configDir,
|
ConfigDir: configDir,
|
||||||
ConfigLoader: configLoader,
|
ConfigLoader: configLoader,
|
||||||
Parallelism: defaultParallelism,
|
|
||||||
PlanRefresh: true,
|
PlanRefresh: true,
|
||||||
StateLocker: clistate.NewLocker(timeout, stateLockerView),
|
StateLocker: clistate.NewLocker(timeout, stateLockerView),
|
||||||
Type: backend.OperationTypeApply,
|
Type: backend.OperationTypeApply,
|
||||||
|
@ -223,7 +222,10 @@ func TestRemote_applyWithParallelism(t *testing.T) {
|
||||||
op, configCleanup, done := testOperationApply(t, "./testdata/apply")
|
op, configCleanup, done := testOperationApply(t, "./testdata/apply")
|
||||||
defer configCleanup()
|
defer configCleanup()
|
||||||
|
|
||||||
op.Parallelism = 3
|
if b.ContextOpts == nil {
|
||||||
|
b.ContextOpts = &terraform.ContextOpts{}
|
||||||
|
}
|
||||||
|
b.ContextOpts.Parallelism = 3
|
||||||
op.Workspace = backend.DefaultStateName
|
op.Workspace = backend.DefaultStateName
|
||||||
|
|
||||||
run, err := b.Operation(context.Background(), op)
|
run, err := b.Operation(context.Background(), op)
|
||||||
|
|
|
@ -38,7 +38,7 @@ func (b *Remote) opPlan(stopCtx, cancelCtx context.Context, op *backend.Operatio
|
||||||
return nil, diags.Err()
|
return nil, diags.Err()
|
||||||
}
|
}
|
||||||
|
|
||||||
if op.Parallelism != defaultParallelism {
|
if b.ContextOpts != nil && b.ContextOpts.Parallelism != defaultParallelism {
|
||||||
diags = diags.Append(tfdiags.Sourceless(
|
diags = diags.Append(tfdiags.Sourceless(
|
||||||
tfdiags.Error,
|
tfdiags.Error,
|
||||||
"Custom parallelism values are currently not supported",
|
"Custom parallelism values are currently not supported",
|
||||||
|
|
|
@ -44,7 +44,6 @@ func testOperationPlanWithTimeout(t *testing.T, configDir string, timeout time.D
|
||||||
return &backend.Operation{
|
return &backend.Operation{
|
||||||
ConfigDir: configDir,
|
ConfigDir: configDir,
|
||||||
ConfigLoader: configLoader,
|
ConfigLoader: configLoader,
|
||||||
Parallelism: defaultParallelism,
|
|
||||||
PlanRefresh: true,
|
PlanRefresh: true,
|
||||||
StateLocker: clistate.NewLocker(timeout, stateLockerView),
|
StateLocker: clistate.NewLocker(timeout, stateLockerView),
|
||||||
Type: backend.OperationTypePlan,
|
Type: backend.OperationTypePlan,
|
||||||
|
@ -198,7 +197,10 @@ func TestRemote_planWithParallelism(t *testing.T) {
|
||||||
op, configCleanup, done := testOperationPlan(t, "./testdata/plan")
|
op, configCleanup, done := testOperationPlan(t, "./testdata/plan")
|
||||||
defer configCleanup()
|
defer configCleanup()
|
||||||
|
|
||||||
op.Parallelism = 3
|
if b.ContextOpts == nil {
|
||||||
|
b.ContextOpts = &terraform.ContextOpts{}
|
||||||
|
}
|
||||||
|
b.ContextOpts.Parallelism = 3
|
||||||
op.Workspace = backend.DefaultStateName
|
op.Workspace = backend.DefaultStateName
|
||||||
|
|
||||||
run, err := b.Operation(context.Background(), op)
|
run, err := b.Operation(context.Background(), op)
|
||||||
|
|
|
@ -349,7 +349,6 @@ func (m *Meta) Operation(b backend.Backend) *backend.Operation {
|
||||||
|
|
||||||
return &backend.Operation{
|
return &backend.Operation{
|
||||||
PlanOutBackend: planOutBackend,
|
PlanOutBackend: planOutBackend,
|
||||||
Parallelism: m.parallelism,
|
|
||||||
Targets: m.targets,
|
Targets: m.targets,
|
||||||
UIIn: m.UIInput(),
|
UIIn: m.UIInput(),
|
||||||
UIOut: m.Ui,
|
UIOut: m.Ui,
|
||||||
|
|
Loading…
Reference in New Issue