generating configuration is not allowed with the remote backend

This commit is contained in:
CJ Horton 2023-05-31 11:51:39 -07:00
parent 6ca13bfc1e
commit 8a3f4e903b
2 changed files with 39 additions and 0 deletions

View File

@ -69,6 +69,15 @@ func (b *Remote) opPlan(stopCtx, cancelCtx context.Context, op *backend.Operatio
))
}
if op.GenerateConfigOut != "" {
diags = diags.Append(tfdiags.Sourceless(
tfdiags.Error,
"Generating configuration is not currently supported",
`The "remote" backend does not currently support generating resource configuration `+
`as part of a plan.`,
))
}
if b.hasExplicitVariableValues(op) {
diags = diags.Append(tfdiags.Sourceless(
tfdiags.Error,

View File

@ -1248,3 +1248,33 @@ func TestRemote_planOtherError(t *testing.T) {
t.Fatalf("expected error message, got: %s", err.Error())
}
}
func TestRemote_planWithGenConfigOut(t *testing.T) {
b, bCleanup := testBackendDefault(t)
defer bCleanup()
op, configCleanup, done := testOperationPlan(t, "./testdata/plan")
defer configCleanup()
op.GenerateConfigOut = "generated.tf"
op.Workspace = backend.DefaultStateName
run, err := b.Operation(context.Background(), op)
if err != nil {
t.Fatalf("error starting operation: %v", err)
}
<-run.Done()
output := done(t)
if run.Result == backend.OperationSuccess {
t.Fatal("expected plan operation to fail")
}
if !run.PlanEmpty {
t.Fatalf("expected plan to be empty")
}
errOutput := output.Stderr()
if !strings.Contains(errOutput, "Generating configuration is not currently supported") {
t.Fatalf("expected error about config generation, got: %v", errOutput)
}
}