mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-25 18:45:20 -06:00
tofu: Context.Validate now takes a context.Context
This continues our ongoing effort to get a coherent chain of context.Context all the way from "package main" to all of our calls to external components. Context.Validate doesn't yet do anything with its new context, but we'll plumb this deeper in future. Since the local backend's implementation of backend.Local.LocalRun calls Validate on the given configuration before returning, it this also extends that interface method to take a context, and so the various commands that directly create "local runs" (rather than going through the backend operation API) now all pass in a context derived from the one created in "package main". All of the _test.go file updates here are purely mechanical additions of the extra argument. No test is materially modified by this change, which is intentional to get some assurance that isn't a breaking change. Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
This commit is contained in:
parent
6522f73249
commit
9cadb097ba
@ -169,7 +169,7 @@ type Local interface {
|
||||
// backend's implementations of this to understand what this actually
|
||||
// does, because this operation has no well-defined contract aside from
|
||||
// "whatever it already does".
|
||||
LocalRun(*Operation) (*LocalRun, statemgr.Full, tfdiags.Diagnostics)
|
||||
LocalRun(context.Context, *Operation) (*LocalRun, statemgr.Full, tfdiags.Diagnostics)
|
||||
}
|
||||
|
||||
// LocalRun represents the assortment of objects that we can collect or
|
||||
|
@ -81,7 +81,7 @@ func (b *Local) opApply(
|
||||
op.Hooks = append(op.Hooks, stateHook)
|
||||
|
||||
// Get our context
|
||||
lr, _, opState, contextDiags := b.localRun(op)
|
||||
lr, _, opState, contextDiags := b.localRun(ctx, op)
|
||||
diags = diags.Append(contextDiags)
|
||||
if contextDiags.HasErrors() {
|
||||
op.ReportResult(runningOp, diags)
|
||||
|
@ -26,7 +26,7 @@ import (
|
||||
)
|
||||
|
||||
// backend.Local implementation.
|
||||
func (b *Local) LocalRun(op *backend.Operation) (*backend.LocalRun, statemgr.Full, tfdiags.Diagnostics) {
|
||||
func (b *Local) LocalRun(ctx context.Context, op *backend.Operation) (*backend.LocalRun, statemgr.Full, tfdiags.Diagnostics) {
|
||||
// Make sure the type is invalid. We use this as a way to know not
|
||||
// to ask for input/validate. We're modifying this through a pointer,
|
||||
// so we're mutating an object that belongs to the caller here, which
|
||||
@ -37,11 +37,12 @@ func (b *Local) LocalRun(op *backend.Operation) (*backend.LocalRun, statemgr.Ful
|
||||
|
||||
op.StateLocker = op.StateLocker.WithContext(context.Background())
|
||||
|
||||
lr, _, stateMgr, diags := b.localRun(op)
|
||||
lr, _, stateMgr, diags := b.localRun(ctx, op)
|
||||
return lr, stateMgr, diags
|
||||
}
|
||||
|
||||
func (b *Local) localRun(op *backend.Operation) (*backend.LocalRun, *configload.Snapshot, statemgr.Full, tfdiags.Diagnostics) {
|
||||
//nolint:funlen // Historical function predates our complexity rules
|
||||
func (b *Local) localRun(ctx context.Context, op *backend.Operation) (*backend.LocalRun, *configload.Snapshot, statemgr.Full, tfdiags.Diagnostics) {
|
||||
var diags tfdiags.Diagnostics
|
||||
|
||||
// Get the latest state.
|
||||
@ -134,7 +135,7 @@ func (b *Local) localRun(op *backend.Operation) (*backend.LocalRun, *configload.
|
||||
// If validation is enabled, validate
|
||||
if b.OpValidation {
|
||||
log.Printf("[TRACE] backend/local: running validation operation")
|
||||
validateDiags := ret.Core.Validate(ret.Config)
|
||||
validateDiags := ret.Core.Validate(ctx, ret.Config)
|
||||
diags = diags.Append(validateDiags)
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@
|
||||
package local
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@ -49,7 +50,7 @@ func TestLocalRun(t *testing.T) {
|
||||
StateLocker: stateLocker,
|
||||
}
|
||||
|
||||
_, _, diags := b.LocalRun(op)
|
||||
_, _, diags := b.LocalRun(context.Background(), op)
|
||||
if diags.HasErrors() {
|
||||
t.Fatalf("unexpected error: %s", diags.Err().Error())
|
||||
}
|
||||
@ -80,7 +81,7 @@ func TestLocalRun_error(t *testing.T) {
|
||||
StateLocker: stateLocker,
|
||||
}
|
||||
|
||||
_, _, diags := b.LocalRun(op)
|
||||
_, _, diags := b.LocalRun(context.Background(), op)
|
||||
if !diags.HasErrors() {
|
||||
t.Fatal("unexpected success")
|
||||
}
|
||||
@ -115,7 +116,7 @@ func TestLocalRun_cloudPlan(t *testing.T) {
|
||||
StateLocker: stateLocker,
|
||||
}
|
||||
|
||||
_, _, diags := b.LocalRun(op)
|
||||
_, _, diags := b.LocalRun(context.Background(), op)
|
||||
if !diags.HasErrors() {
|
||||
t.Fatal("unexpected success")
|
||||
}
|
||||
@ -201,7 +202,7 @@ func TestLocalRun_stalePlan(t *testing.T) {
|
||||
StateLocker: stateLocker,
|
||||
}
|
||||
|
||||
_, _, diags := b.LocalRun(op)
|
||||
_, _, diags := b.LocalRun(context.Background(), op)
|
||||
if !diags.HasErrors() {
|
||||
t.Fatal("unexpected success")
|
||||
}
|
||||
|
@ -88,7 +88,7 @@ func (b *Local) opPlan(
|
||||
}
|
||||
|
||||
// Get our context
|
||||
lr, configSnap, opState, ctxDiags := b.localRun(op)
|
||||
lr, configSnap, opState, ctxDiags := b.localRun(ctx, op)
|
||||
diags = diags.Append(ctxDiags)
|
||||
if ctxDiags.HasErrors() {
|
||||
op.ReportResult(runningOp, diags)
|
||||
|
@ -59,7 +59,7 @@ func (b *Local) opRefresh(
|
||||
op.PlanRefresh = true
|
||||
|
||||
// Get our context
|
||||
lr, _, opState, contextDiags := b.localRun(op)
|
||||
lr, _, opState, contextDiags := b.localRun(ctx, op)
|
||||
diags = diags.Append(contextDiags)
|
||||
if contextDiags.HasErrors() {
|
||||
op.ReportResult(runningOp, diags)
|
||||
|
@ -23,7 +23,9 @@ import (
|
||||
)
|
||||
|
||||
// Context implements backend.Local.
|
||||
func (b *Remote) LocalRun(op *backend.Operation) (*backend.LocalRun, statemgr.Full, tfdiags.Diagnostics) {
|
||||
//
|
||||
//nolint:funlen,nestif // Historical function predates our complexity rules
|
||||
func (b *Remote) LocalRun(_ context.Context, op *backend.Operation) (*backend.LocalRun, statemgr.Full, tfdiags.Diagnostics) {
|
||||
var diags tfdiags.Diagnostics
|
||||
ret := &backend.LocalRun{
|
||||
PlanOpts: &tofu.PlanOpts{
|
||||
|
@ -214,7 +214,7 @@ func TestRemoteContextWithVars(t *testing.T) {
|
||||
}
|
||||
b.client.Variables.Create(context.TODO(), workspaceID, *v)
|
||||
|
||||
_, _, diags := b.LocalRun(op)
|
||||
_, _, diags := b.LocalRun(context.Background(), op)
|
||||
|
||||
if test.WantError != "" {
|
||||
if !diags.HasErrors() {
|
||||
@ -435,7 +435,7 @@ func TestRemoteVariablesDoNotOverride(t *testing.T) {
|
||||
b.client.Variables.Create(context.TODO(), workspaceID, *v)
|
||||
}
|
||||
|
||||
lr, _, diags := b.LocalRun(op)
|
||||
lr, _, diags := b.LocalRun(context.Background(), op)
|
||||
|
||||
if diags.HasErrors() {
|
||||
t.Fatalf("unexpected error\ngot: %s\nwant: <no error>", diags.Err().Error())
|
||||
|
@ -23,7 +23,9 @@ import (
|
||||
)
|
||||
|
||||
// LocalRun implements backend.Local
|
||||
func (b *Cloud) LocalRun(op *backend.Operation) (*backend.LocalRun, statemgr.Full, tfdiags.Diagnostics) {
|
||||
//
|
||||
//nolint:funlen,nestif // Historical function predates our complexity rules
|
||||
func (b *Cloud) LocalRun(_ context.Context, op *backend.Operation) (*backend.LocalRun, statemgr.Full, tfdiags.Diagnostics) {
|
||||
var diags tfdiags.Diagnostics
|
||||
ret := &backend.LocalRun{
|
||||
PlanOpts: &tofu.PlanOpts{
|
||||
|
@ -213,7 +213,7 @@ func TestRemoteContextWithVars(t *testing.T) {
|
||||
}
|
||||
b.client.Variables.Create(context.TODO(), workspaceID, *v)
|
||||
|
||||
_, _, diags := b.LocalRun(op)
|
||||
_, _, diags := b.LocalRun(context.Background(), op)
|
||||
|
||||
if test.WantError != "" {
|
||||
if !diags.HasErrors() {
|
||||
@ -434,7 +434,7 @@ func TestRemoteVariablesDoNotOverride(t *testing.T) {
|
||||
b.client.Variables.Create(context.TODO(), workspaceID, *v)
|
||||
}
|
||||
|
||||
lr, _, diags := b.LocalRun(op)
|
||||
lr, _, diags := b.LocalRun(context.Background(), op)
|
||||
|
||||
if diags.HasErrors() {
|
||||
t.Fatalf("unexpected error\ngot: %s\nwant: <no error>", diags.Err().Error())
|
||||
|
@ -114,7 +114,7 @@ func (c *ConsoleCommand) Run(args []string) int {
|
||||
}
|
||||
|
||||
// Get the context
|
||||
lr, _, ctxDiags := local.LocalRun(opReq)
|
||||
lr, _, ctxDiags := local.LocalRun(ctx, opReq)
|
||||
diags = diags.Append(ctxDiags)
|
||||
if ctxDiags.HasErrors() {
|
||||
c.showDiagnostics(diags)
|
||||
|
@ -33,6 +33,8 @@ func (c *GraphCommand) Run(args []string) int {
|
||||
var verbose bool
|
||||
var planPath string
|
||||
|
||||
ctx := c.CommandContext()
|
||||
|
||||
args = c.Meta.process(args)
|
||||
cmdFlags := c.Meta.defaultFlagSet("graph")
|
||||
c.Meta.varFlagSet(cmdFlags)
|
||||
@ -160,7 +162,7 @@ func (c *GraphCommand) Run(args []string) int {
|
||||
}
|
||||
|
||||
// Get the context
|
||||
lr, _, ctxDiags := local.LocalRun(opReq)
|
||||
lr, _, ctxDiags := local.LocalRun(ctx, opReq)
|
||||
diags = diags.Append(ctxDiags)
|
||||
if ctxDiags.HasErrors() {
|
||||
c.showDiagnostics(diags)
|
||||
|
@ -227,7 +227,7 @@ func (c *ImportCommand) Run(args []string) int {
|
||||
}
|
||||
|
||||
// Get the context
|
||||
lr, state, ctxDiags := local.LocalRun(opReq)
|
||||
lr, state, ctxDiags := local.LocalRun(ctx, opReq)
|
||||
diags = diags.Append(ctxDiags)
|
||||
if ctxDiags.HasErrors() {
|
||||
c.showDiagnostics(diags)
|
||||
|
@ -30,6 +30,8 @@ func (c *ProvidersSchemaCommand) Synopsis() string {
|
||||
}
|
||||
|
||||
func (c *ProvidersSchemaCommand) Run(args []string) int {
|
||||
ctx := c.CommandContext()
|
||||
|
||||
args = c.Meta.process(args)
|
||||
cmdFlags := c.Meta.defaultFlagSet("providers schema")
|
||||
c.Meta.varFlagSet(cmdFlags)
|
||||
@ -111,7 +113,7 @@ func (c *ProvidersSchemaCommand) Run(args []string) int {
|
||||
}
|
||||
|
||||
// Get the context
|
||||
lr, _, ctxDiags := local.LocalRun(opReq)
|
||||
lr, _, ctxDiags := local.LocalRun(ctx, opReq)
|
||||
diags = diags.Append(ctxDiags)
|
||||
if ctxDiags.HasErrors() {
|
||||
c.showDiagnostics(diags)
|
||||
|
@ -31,6 +31,8 @@ type StateShowCommand struct {
|
||||
}
|
||||
|
||||
func (c *StateShowCommand) Run(args []string) int {
|
||||
ctx := c.CommandContext()
|
||||
|
||||
args = c.Meta.process(args)
|
||||
cmdFlags := c.Meta.defaultFlagSet("state show")
|
||||
c.Meta.varFlagSet(cmdFlags)
|
||||
@ -112,7 +114,7 @@ func (c *StateShowCommand) Run(args []string) int {
|
||||
}
|
||||
|
||||
// Get the context (required to get the schemas)
|
||||
lr, _, ctxDiags := local.LocalRun(opReq)
|
||||
lr, _, ctxDiags := local.LocalRun(ctx, opReq)
|
||||
if ctxDiags.HasErrors() {
|
||||
c.View.Diagnostics(ctxDiags)
|
||||
return 1
|
||||
|
@ -523,7 +523,7 @@ func (runner *TestFileRunner) ExecuteTestRun(ctx context.Context, run *moduletes
|
||||
return state, false
|
||||
}
|
||||
|
||||
validateDiags := runner.validate(config, run, file)
|
||||
validateDiags := runner.validate(ctx, config, run, file)
|
||||
run.Diagnostics = run.Diagnostics.Append(validateDiags)
|
||||
if validateDiags.HasErrors() {
|
||||
run.Status = moduletest.Error
|
||||
@ -656,7 +656,7 @@ func (runner *TestFileRunner) ExecuteTestRun(ctx context.Context, run *moduletes
|
||||
return updated, true
|
||||
}
|
||||
|
||||
func (runner *TestFileRunner) validate(config *configs.Config, run *moduletest.Run, file *moduletest.File) tfdiags.Diagnostics {
|
||||
func (runner *TestFileRunner) validate(ctx context.Context, config *configs.Config, run *moduletest.Run, file *moduletest.File) tfdiags.Diagnostics {
|
||||
log.Printf("[TRACE] TestFileRunner: called validate for %s/%s", file.Name, run.Name)
|
||||
|
||||
var diags tfdiags.Diagnostics
|
||||
@ -667,7 +667,7 @@ func (runner *TestFileRunner) validate(config *configs.Config, run *moduletest.R
|
||||
return diags
|
||||
}
|
||||
|
||||
runningCtx, done := context.WithCancel(context.Background())
|
||||
runningCtx, done := context.WithCancel(context.WithoutCancel(ctx))
|
||||
|
||||
var validateDiags tfdiags.Diagnostics
|
||||
panicHandler := logging.PanicHandlerWithTraceFn()
|
||||
@ -676,7 +676,7 @@ func (runner *TestFileRunner) validate(config *configs.Config, run *moduletest.R
|
||||
defer done()
|
||||
|
||||
log.Printf("[DEBUG] TestFileRunner: starting validate for %s/%s", file.Name, run.Name)
|
||||
validateDiags = tfCtx.Validate(config)
|
||||
validateDiags = tfCtx.Validate(ctx, config)
|
||||
log.Printf("[DEBUG] TestFileRunner: completed validate for %s/%s", file.Name, run.Name)
|
||||
}()
|
||||
waitDiags, cancelled := runner.wait(tfCtx, runningCtx, run, file, nil)
|
||||
|
@ -6,6 +6,7 @@
|
||||
package command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
@ -24,6 +25,8 @@ type ValidateCommand struct {
|
||||
}
|
||||
|
||||
func (c *ValidateCommand) Run(rawArgs []string) int {
|
||||
ctx := c.CommandContext()
|
||||
|
||||
// Parse and apply global view arguments
|
||||
common, rawArgs := arguments.ParseView(rawArgs)
|
||||
c.View.Configure(common)
|
||||
@ -59,7 +62,7 @@ func (c *ValidateCommand) Run(rawArgs []string) int {
|
||||
// Inject variables from args into meta for static evaluation
|
||||
c.GatherVariables(args.Vars)
|
||||
|
||||
validateDiags := c.validate(dir, args.TestDirectory, args.NoTests)
|
||||
validateDiags := c.validate(ctx, dir, args.TestDirectory, args.NoTests)
|
||||
diags = diags.Append(validateDiags)
|
||||
|
||||
// Validating with dev overrides in effect means that the result might
|
||||
@ -88,7 +91,7 @@ func (c *ValidateCommand) GatherVariables(args *arguments.Vars) {
|
||||
c.Meta.variableArgs = rawFlags{items: &items}
|
||||
}
|
||||
|
||||
func (c *ValidateCommand) validate(dir, testDir string, noTests bool) tfdiags.Diagnostics {
|
||||
func (c *ValidateCommand) validate(ctx context.Context, dir, testDir string, noTests bool) tfdiags.Diagnostics {
|
||||
var diags tfdiags.Diagnostics
|
||||
var cfg *configs.Config
|
||||
|
||||
@ -116,7 +119,7 @@ func (c *ValidateCommand) validate(dir, testDir string, noTests bool) tfdiags.Di
|
||||
return diags
|
||||
}
|
||||
|
||||
return diags.Append(tfCtx.Validate(cfg))
|
||||
return diags.Append(tfCtx.Validate(ctx, cfg))
|
||||
}
|
||||
|
||||
diags = diags.Append(validate(cfg))
|
||||
|
@ -3252,7 +3252,7 @@ func TestContext2Apply_excludedDestroy(t *testing.T) {
|
||||
})
|
||||
|
||||
// First plan and apply a create operation
|
||||
if diags := ctx.Validate(m); diags.HasErrors() {
|
||||
if diags := ctx.Validate(context.Background(), m); diags.HasErrors() {
|
||||
t.Fatalf("validate errors: %s", diags.Err())
|
||||
}
|
||||
|
||||
@ -3316,7 +3316,7 @@ func TestContext2Apply_excludedDestroyDependent(t *testing.T) {
|
||||
})
|
||||
|
||||
// First plan and apply a create operation
|
||||
if diags := ctx.Validate(m); diags.HasErrors() {
|
||||
if diags := ctx.Validate(context.Background(), m); diags.HasErrors() {
|
||||
t.Fatalf("validate errors: %s", diags.Err())
|
||||
}
|
||||
|
||||
|
@ -7227,7 +7227,7 @@ func TestContext2Apply_targetedDestroy(t *testing.T) {
|
||||
})
|
||||
|
||||
// First plan and apply a create operation
|
||||
if diags := ctx.Validate(m); diags.HasErrors() {
|
||||
if diags := ctx.Validate(context.Background(), m); diags.HasErrors() {
|
||||
t.Fatalf("validate errors: %s", diags.Err())
|
||||
}
|
||||
|
||||
@ -7839,7 +7839,7 @@ func TestContext2Apply_vars(t *testing.T) {
|
||||
ctx := testContext2(t, opts)
|
||||
m := fixture.Config
|
||||
|
||||
diags := ctx.Validate(m)
|
||||
diags := ctx.Validate(context.Background(), m)
|
||||
if len(diags) != 0 {
|
||||
t.Fatalf("bad: %s", diags.ErrWithWarnings())
|
||||
}
|
||||
@ -7902,7 +7902,7 @@ func TestContext2Apply_varsEnv(t *testing.T) {
|
||||
ctx := testContext2(t, opts)
|
||||
m := fixture.Config
|
||||
|
||||
diags := ctx.Validate(m)
|
||||
diags := ctx.Validate(context.Background(), m)
|
||||
if len(diags) != 0 {
|
||||
t.Fatalf("bad: %s", diags.ErrWithWarnings())
|
||||
}
|
||||
@ -9511,7 +9511,7 @@ func TestContext2Apply_invalidIndexRef(t *testing.T) {
|
||||
addrs.NewDefaultProvider("test"): testProviderFuncFixed(p),
|
||||
},
|
||||
})
|
||||
diags := c.Validate(m)
|
||||
diags := c.Validate(context.Background(), m)
|
||||
if diags.HasErrors() {
|
||||
t.Fatalf("unexpected validation failure: %s", diags.Err())
|
||||
}
|
||||
|
@ -362,7 +362,7 @@ variable "obfmod" {
|
||||
},
|
||||
})
|
||||
|
||||
diags := ctx.Validate(m)
|
||||
diags := ctx.Validate(context.Background(), m)
|
||||
if diags.HasErrors() {
|
||||
t.Fatal(diags.Err())
|
||||
}
|
||||
@ -443,7 +443,7 @@ variable "obfmod" {
|
||||
},
|
||||
})
|
||||
|
||||
diags := ctx.Validate(m)
|
||||
diags := ctx.Validate(context.Background(), m)
|
||||
if diags.HasErrors() {
|
||||
t.Fatal(diags.Err())
|
||||
}
|
||||
@ -536,7 +536,7 @@ variable "obfmod" {
|
||||
},
|
||||
})
|
||||
|
||||
diags := ctx.Validate(m)
|
||||
diags := ctx.Validate(context.Background(), m)
|
||||
if diags.HasErrors() {
|
||||
t.Fatal(diags.Err())
|
||||
}
|
||||
@ -728,7 +728,7 @@ variable "obfmod" {
|
||||
},
|
||||
})
|
||||
|
||||
diags := ctx.Validate(m)
|
||||
diags := ctx.Validate(context.Background(), m)
|
||||
if diags.HasErrors() {
|
||||
t.Fatal(diags.Err())
|
||||
}
|
||||
|
@ -1858,7 +1858,7 @@ func TestContext2Plan_computedInFunction(t *testing.T) {
|
||||
},
|
||||
})
|
||||
|
||||
diags := ctx.Validate(m)
|
||||
diags := ctx.Validate(context.Background(), m)
|
||||
assertNoErrors(t, diags)
|
||||
|
||||
_, diags = ctx.Plan(context.Background(), m, states.NewState(), DefaultPlanOpts)
|
||||
@ -5715,7 +5715,7 @@ func TestContext2Plan_resourceNestedCount(t *testing.T) {
|
||||
},
|
||||
})
|
||||
|
||||
diags := ctx.Validate(m)
|
||||
diags := ctx.Validate(context.Background(), m)
|
||||
if diags.HasErrors() {
|
||||
t.Fatalf("validate errors: %s", diags.Err())
|
||||
}
|
||||
@ -5799,7 +5799,7 @@ func TestContext2Plan_selfRef(t *testing.T) {
|
||||
},
|
||||
})
|
||||
|
||||
diags := c.Validate(m)
|
||||
diags := c.Validate(context.Background(), m)
|
||||
if diags.HasErrors() {
|
||||
t.Fatalf("unexpected validation failure: %s", diags.Err())
|
||||
}
|
||||
@ -5835,7 +5835,7 @@ func TestContext2Plan_selfRefMulti(t *testing.T) {
|
||||
},
|
||||
})
|
||||
|
||||
diags := c.Validate(m)
|
||||
diags := c.Validate(context.Background(), m)
|
||||
if diags.HasErrors() {
|
||||
t.Fatalf("unexpected validation failure: %s", diags.Err())
|
||||
}
|
||||
@ -5871,7 +5871,7 @@ func TestContext2Plan_selfRefMultiAll(t *testing.T) {
|
||||
},
|
||||
})
|
||||
|
||||
diags := c.Validate(m)
|
||||
diags := c.Validate(context.Background(), m)
|
||||
if diags.HasErrors() {
|
||||
t.Fatalf("unexpected validation failure: %s", diags.Err())
|
||||
}
|
||||
|
@ -1501,7 +1501,7 @@ func TestContext2Validate(t *testing.T) {
|
||||
},
|
||||
})
|
||||
|
||||
diags := c.Validate(m)
|
||||
diags := c.Validate(context.Background(), m)
|
||||
if len(diags) != 0 {
|
||||
t.Fatalf("unexpected error: %#v", diags.ErrWithWarnings())
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ func TestNewContextRequiredVersion(t *testing.T) {
|
||||
t.Fatalf("unexpected NewContext errors: %s", diags.Err())
|
||||
}
|
||||
|
||||
diags = c.Validate(mod)
|
||||
diags = c.Validate(context.Background(), mod)
|
||||
if diags.HasErrors() != tc.Err {
|
||||
t.Fatalf("err: %s", diags.Err())
|
||||
}
|
||||
@ -166,7 +166,7 @@ terraform {}
|
||||
t.Fatalf("unexpected NewContext errors: %s", diags.Err())
|
||||
}
|
||||
|
||||
diags = c.Validate(mod)
|
||||
diags = c.Validate(context.Background(), mod)
|
||||
if diags.HasErrors() != tc.Err {
|
||||
t.Fatalf("err: %s", diags.Err())
|
||||
}
|
||||
@ -211,7 +211,7 @@ resource "implicit_thing" "b" {
|
||||
// require doing some pretty weird things that aren't common enough to
|
||||
// be worth the complexity to check for them.
|
||||
|
||||
validateDiags := ctx.Validate(cfg)
|
||||
validateDiags := ctx.Validate(context.Background(), cfg)
|
||||
_, planDiags := ctx.Plan(context.Background(), cfg, nil, DefaultPlanOpts)
|
||||
|
||||
tests := map[string]tfdiags.Diagnostics{
|
||||
|
@ -6,6 +6,7 @@
|
||||
package tofu
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log"
|
||||
|
||||
"github.com/opentofu/opentofu/internal/addrs"
|
||||
@ -26,7 +27,7 @@ import (
|
||||
// such as root module input variables. However, the Plan function includes
|
||||
// all of the same checks as Validate, in addition to the other work it does
|
||||
// to consider the previous run state and the planning options.
|
||||
func (c *Context) Validate(config *configs.Config) tfdiags.Diagnostics {
|
||||
func (c *Context) Validate(ctx context.Context, config *configs.Config) tfdiags.Diagnostics {
|
||||
defer c.acquireRun("validate")()
|
||||
|
||||
var diags tfdiags.Diagnostics
|
||||
|
@ -39,7 +39,7 @@ func TestContext2Validate_badCount(t *testing.T) {
|
||||
},
|
||||
})
|
||||
|
||||
diags := c.Validate(m)
|
||||
diags := c.Validate(context.Background(), m)
|
||||
if !diags.HasErrors() {
|
||||
t.Fatalf("succeeded; want error")
|
||||
}
|
||||
@ -62,7 +62,7 @@ func TestContext2Validate_badResource_reference(t *testing.T) {
|
||||
},
|
||||
})
|
||||
|
||||
diags := c.Validate(m)
|
||||
diags := c.Validate(context.Background(), m)
|
||||
if !diags.HasErrors() {
|
||||
t.Fatalf("succeeded; want error")
|
||||
}
|
||||
@ -88,7 +88,7 @@ func TestContext2Validate_badVar(t *testing.T) {
|
||||
},
|
||||
})
|
||||
|
||||
diags := c.Validate(m)
|
||||
diags := c.Validate(context.Background(), m)
|
||||
if !diags.HasErrors() {
|
||||
t.Fatalf("succeeded; want error")
|
||||
}
|
||||
@ -165,7 +165,7 @@ func TestContext2Validate_computedVar(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
diags := c.Validate(m)
|
||||
diags := c.Validate(context.Background(), m)
|
||||
if diags.HasErrors() {
|
||||
t.Fatalf("unexpected error: %s", diags.Err())
|
||||
}
|
||||
@ -205,7 +205,7 @@ func TestContext2Validate_computedInFunction(t *testing.T) {
|
||||
},
|
||||
})
|
||||
|
||||
diags := c.Validate(m)
|
||||
diags := c.Validate(context.Background(), m)
|
||||
if diags.HasErrors() {
|
||||
t.Fatalf("unexpected error: %s", diags.Err())
|
||||
}
|
||||
@ -243,7 +243,7 @@ func TestContext2Validate_countComputed(t *testing.T) {
|
||||
},
|
||||
})
|
||||
|
||||
diags := c.Validate(m)
|
||||
diags := c.Validate(context.Background(), m)
|
||||
if diags.HasErrors() {
|
||||
t.Fatalf("unexpected error: %s", diags.Err())
|
||||
}
|
||||
@ -267,7 +267,7 @@ func TestContext2Validate_countNegative(t *testing.T) {
|
||||
},
|
||||
})
|
||||
|
||||
diags := c.Validate(m)
|
||||
diags := c.Validate(context.Background(), m)
|
||||
if !diags.HasErrors() {
|
||||
t.Fatalf("succeeded; want error")
|
||||
}
|
||||
@ -293,7 +293,7 @@ func TestContext2Validate_countVariable(t *testing.T) {
|
||||
},
|
||||
})
|
||||
|
||||
diags := c.Validate(m)
|
||||
diags := c.Validate(context.Background(), m)
|
||||
if diags.HasErrors() {
|
||||
t.Fatalf("unexpected error: %s", diags.Err())
|
||||
}
|
||||
@ -347,7 +347,7 @@ func TestContext2Validate_moduleBadOutput(t *testing.T) {
|
||||
},
|
||||
})
|
||||
|
||||
diags := c.Validate(m)
|
||||
diags := c.Validate(context.Background(), m)
|
||||
if !diags.HasErrors() {
|
||||
t.Fatalf("succeeded; want error")
|
||||
}
|
||||
@ -373,7 +373,7 @@ func TestContext2Validate_moduleGood(t *testing.T) {
|
||||
},
|
||||
})
|
||||
|
||||
diags := c.Validate(m)
|
||||
diags := c.Validate(context.Background(), m)
|
||||
if diags.HasErrors() {
|
||||
t.Fatalf("unexpected error: %s", diags.Err())
|
||||
}
|
||||
@ -402,7 +402,7 @@ func TestContext2Validate_moduleBadResource(t *testing.T) {
|
||||
Diagnostics: tfdiags.Diagnostics{}.Append(fmt.Errorf("bad")),
|
||||
}
|
||||
|
||||
diags := c.Validate(m)
|
||||
diags := c.Validate(context.Background(), m)
|
||||
if !diags.HasErrors() {
|
||||
t.Fatalf("succeeded; want error")
|
||||
}
|
||||
@ -429,7 +429,7 @@ func TestContext2Validate_moduleDepsShouldNotCycle(t *testing.T) {
|
||||
},
|
||||
})
|
||||
|
||||
diags := ctx.Validate(m)
|
||||
diags := ctx.Validate(context.Background(), m)
|
||||
if diags.HasErrors() {
|
||||
t.Fatalf("unexpected error: %s", diags.Err())
|
||||
}
|
||||
@ -470,7 +470,7 @@ func TestContext2Validate_moduleProviderVar(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
diags := c.Validate(m)
|
||||
diags := c.Validate(context.Background(), m)
|
||||
if diags.HasErrors() {
|
||||
t.Fatalf("unexpected error: %s", diags.Err())
|
||||
}
|
||||
@ -511,7 +511,7 @@ func TestContext2Validate_moduleProviderInheritUnused(t *testing.T) {
|
||||
return
|
||||
}
|
||||
|
||||
diags := c.Validate(m)
|
||||
diags := c.Validate(context.Background(), m)
|
||||
if diags.HasErrors() {
|
||||
t.Fatalf("unexpected error: %s", diags.Err())
|
||||
}
|
||||
@ -550,7 +550,7 @@ func TestContext2Validate_orphans(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
diags := c.Validate(m)
|
||||
diags := c.Validate(context.Background(), m)
|
||||
if diags.HasErrors() {
|
||||
t.Fatalf("unexpected error: %s", diags.Err())
|
||||
}
|
||||
@ -586,7 +586,7 @@ func TestContext2Validate_providerConfig_bad(t *testing.T) {
|
||||
Diagnostics: tfdiags.Diagnostics{}.Append(fmt.Errorf("bad")),
|
||||
}
|
||||
|
||||
diags := c.Validate(m)
|
||||
diags := c.Validate(context.Background(), m)
|
||||
if len(diags) != 1 {
|
||||
t.Fatalf("wrong number of diagnostics %d; want %d", len(diags), 1)
|
||||
}
|
||||
@ -625,7 +625,7 @@ func TestContext2Validate_providerConfig_skippedEmpty(t *testing.T) {
|
||||
Diagnostics: tfdiags.Diagnostics{}.Append(fmt.Errorf("should not be called")),
|
||||
}
|
||||
|
||||
diags := c.Validate(m)
|
||||
diags := c.Validate(context.Background(), m)
|
||||
if diags.HasErrors() {
|
||||
t.Fatalf("unexpected error: %s", diags.Err())
|
||||
}
|
||||
@ -657,7 +657,7 @@ func TestContext2Validate_providerConfig_good(t *testing.T) {
|
||||
},
|
||||
})
|
||||
|
||||
diags := c.Validate(m)
|
||||
diags := c.Validate(context.Background(), m)
|
||||
if diags.HasErrors() {
|
||||
t.Fatalf("unexpected error: %s", diags.Err())
|
||||
}
|
||||
@ -692,7 +692,7 @@ func TestContext2Validate_requiredProviderConfig(t *testing.T) {
|
||||
},
|
||||
})
|
||||
|
||||
diags := c.Validate(m)
|
||||
diags := c.Validate(context.Background(), m)
|
||||
if diags.HasErrors() {
|
||||
t.Fatalf("unexpected error: %s", diags.Err())
|
||||
}
|
||||
@ -728,7 +728,7 @@ func TestContext2Validate_provisionerConfig_bad(t *testing.T) {
|
||||
Diagnostics: tfdiags.Diagnostics{}.Append(fmt.Errorf("bad")),
|
||||
}
|
||||
|
||||
diags := c.Validate(m)
|
||||
diags := c.Validate(context.Background(), m)
|
||||
if !diags.HasErrors() {
|
||||
t.Fatalf("succeeded; want error")
|
||||
}
|
||||
@ -760,7 +760,7 @@ func TestContext2Validate_badResourceConnection(t *testing.T) {
|
||||
},
|
||||
})
|
||||
|
||||
diags := c.Validate(m)
|
||||
diags := c.Validate(context.Background(), m)
|
||||
t.Log(diags.Err())
|
||||
if !diags.HasErrors() {
|
||||
t.Fatalf("succeeded; want error")
|
||||
@ -793,7 +793,7 @@ func TestContext2Validate_badProvisionerConnection(t *testing.T) {
|
||||
},
|
||||
})
|
||||
|
||||
diags := c.Validate(m)
|
||||
diags := c.Validate(context.Background(), m)
|
||||
t.Log(diags.Err())
|
||||
if !diags.HasErrors() {
|
||||
t.Fatalf("succeeded; want error")
|
||||
@ -842,7 +842,7 @@ func TestContext2Validate_provisionerConfig_good(t *testing.T) {
|
||||
},
|
||||
})
|
||||
|
||||
diags := c.Validate(m)
|
||||
diags := c.Validate(context.Background(), m)
|
||||
if diags.HasErrors() {
|
||||
t.Fatalf("unexpected error: %s", diags.Err())
|
||||
}
|
||||
@ -908,7 +908,7 @@ func TestContext2Validate_resourceConfig_bad(t *testing.T) {
|
||||
Diagnostics: tfdiags.Diagnostics{}.Append(fmt.Errorf("bad")),
|
||||
}
|
||||
|
||||
diags := c.Validate(m)
|
||||
diags := c.Validate(context.Background(), m)
|
||||
if !diags.HasErrors() {
|
||||
t.Fatalf("succeeded; want error")
|
||||
}
|
||||
@ -934,7 +934,7 @@ func TestContext2Validate_resourceConfig_good(t *testing.T) {
|
||||
},
|
||||
})
|
||||
|
||||
diags := c.Validate(m)
|
||||
diags := c.Validate(context.Background(), m)
|
||||
if diags.HasErrors() {
|
||||
t.Fatalf("unexpected error: %s", diags.Err())
|
||||
}
|
||||
@ -972,7 +972,7 @@ func TestContext2Validate_tainted(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
diags := c.Validate(m)
|
||||
diags := c.Validate(context.Background(), m)
|
||||
if diags.HasErrors() {
|
||||
t.Fatalf("unexpected error: %s", diags.Err())
|
||||
}
|
||||
@ -1009,7 +1009,7 @@ func TestContext2Validate_targetedDestroy(t *testing.T) {
|
||||
},
|
||||
})
|
||||
|
||||
diags := ctx.Validate(m)
|
||||
diags := ctx.Validate(context.Background(), m)
|
||||
if diags.HasErrors() {
|
||||
t.Fatalf("unexpected error: %s", diags.Err())
|
||||
}
|
||||
@ -1041,7 +1041,7 @@ func TestContext2Validate_varRefUnknown(t *testing.T) {
|
||||
return providers.ValidateResourceConfigResponse{}
|
||||
}
|
||||
|
||||
c.Validate(m)
|
||||
c.Validate(context.Background(), m)
|
||||
|
||||
// Input variables are always unknown during the validate walk, because
|
||||
// we're checking for validity of all possible input values. Validity
|
||||
@ -1077,7 +1077,7 @@ func TestContext2Validate_interpolateVar(t *testing.T) {
|
||||
UIInput: input,
|
||||
})
|
||||
|
||||
diags := ctx.Validate(m)
|
||||
diags := ctx.Validate(context.Background(), m)
|
||||
if diags.HasErrors() {
|
||||
t.Fatalf("unexpected error: %s", diags.Err())
|
||||
}
|
||||
@ -1109,7 +1109,7 @@ func TestContext2Validate_interpolateComputedModuleVarDef(t *testing.T) {
|
||||
UIInput: input,
|
||||
})
|
||||
|
||||
diags := ctx.Validate(m)
|
||||
diags := ctx.Validate(context.Background(), m)
|
||||
if diags.HasErrors() {
|
||||
t.Fatalf("unexpected error: %s", diags.Err())
|
||||
}
|
||||
@ -1129,7 +1129,7 @@ func TestContext2Validate_interpolateMap(t *testing.T) {
|
||||
UIInput: input,
|
||||
})
|
||||
|
||||
diags := ctx.Validate(m)
|
||||
diags := ctx.Validate(context.Background(), m)
|
||||
if diags.HasErrors() {
|
||||
t.Fatalf("unexpected error: %s", diags.Err())
|
||||
}
|
||||
@ -1179,7 +1179,7 @@ resource "aws_instance" "foo" {
|
||||
},
|
||||
})
|
||||
|
||||
diags := ctx.Validate(m)
|
||||
diags := ctx.Validate(context.Background(), m)
|
||||
if diags.HasErrors() {
|
||||
t.Fatal(diags.Err())
|
||||
}
|
||||
@ -1210,7 +1210,7 @@ output "out" {
|
||||
},
|
||||
})
|
||||
|
||||
diags := ctx.Validate(m)
|
||||
diags := ctx.Validate(context.Background(), m)
|
||||
if !diags.HasErrors() {
|
||||
t.Fatal("succeeded; want errors")
|
||||
}
|
||||
@ -1246,7 +1246,7 @@ resource "aws_instance" "foo" {
|
||||
},
|
||||
})
|
||||
|
||||
diags := ctx.Validate(m)
|
||||
diags := ctx.Validate(context.Background(), m)
|
||||
if !diags.HasErrors() {
|
||||
t.Fatal("succeeded; want errors")
|
||||
}
|
||||
@ -1281,7 +1281,7 @@ output "root" {
|
||||
|
||||
ctx := testContext2(t, &ContextOpts{})
|
||||
|
||||
diags := ctx.Validate(m)
|
||||
diags := ctx.Validate(context.Background(), m)
|
||||
if diags.HasErrors() {
|
||||
t.Fatal(diags.Err())
|
||||
}
|
||||
@ -1304,7 +1304,7 @@ output "out" {
|
||||
},
|
||||
})
|
||||
|
||||
diags := ctx.Validate(m)
|
||||
diags := ctx.Validate(context.Background(), m)
|
||||
if !diags.HasErrors() {
|
||||
t.Fatal("succeeded; want errors")
|
||||
}
|
||||
@ -1334,7 +1334,7 @@ output "out" {
|
||||
},
|
||||
})
|
||||
|
||||
diags := ctx.Validate(m)
|
||||
diags := ctx.Validate(context.Background(), m)
|
||||
if !diags.HasErrors() {
|
||||
t.Fatal("succeeded; want errors")
|
||||
}
|
||||
@ -1364,7 +1364,7 @@ output "out" {
|
||||
},
|
||||
})
|
||||
|
||||
diags := ctx.Validate(m)
|
||||
diags := ctx.Validate(context.Background(), m)
|
||||
if !diags.HasErrors() {
|
||||
t.Fatal("succeeded; want errors")
|
||||
}
|
||||
@ -1393,7 +1393,7 @@ resource "test_instance" "bar" {
|
||||
},
|
||||
})
|
||||
|
||||
diags := ctx.Validate(m)
|
||||
diags := ctx.Validate(context.Background(), m)
|
||||
if !diags.HasErrors() {
|
||||
t.Fatal("succeeded; want errors")
|
||||
}
|
||||
@ -1425,7 +1425,7 @@ resource "test_instance" "bar" {
|
||||
},
|
||||
})
|
||||
|
||||
diags := ctx.Validate(m)
|
||||
diags := ctx.Validate(context.Background(), m)
|
||||
if !diags.HasErrors() {
|
||||
t.Fatal("succeeded; want errors")
|
||||
}
|
||||
@ -1449,7 +1449,7 @@ func TestContext2Validate_variableCustomValidationsFail(t *testing.T) {
|
||||
},
|
||||
})
|
||||
|
||||
diags := ctx.Validate(m)
|
||||
diags := ctx.Validate(context.Background(), m)
|
||||
if !diags.HasErrors() {
|
||||
t.Fatal("succeeded; want errors")
|
||||
}
|
||||
@ -1483,7 +1483,7 @@ variable "test" {
|
||||
},
|
||||
})
|
||||
|
||||
diags := ctx.Validate(m)
|
||||
diags := ctx.Validate(context.Background(), m)
|
||||
if diags.HasErrors() {
|
||||
t.Fatalf("unexpected error\ngot: %s", diags.Err().Error())
|
||||
}
|
||||
@ -1544,7 +1544,7 @@ resource "aws_instance" "foo" {
|
||||
},
|
||||
})
|
||||
|
||||
diags := ctx.Validate(m)
|
||||
diags := ctx.Validate(context.Background(), m)
|
||||
if diags.HasErrors() {
|
||||
t.Fatal(diags.ErrWithWarnings())
|
||||
}
|
||||
@ -1571,7 +1571,7 @@ resource "aws_instance" "foo" {
|
||||
},
|
||||
})
|
||||
|
||||
diags := ctx.Validate(m)
|
||||
diags := ctx.Validate(context.Background(), m)
|
||||
if !diags.HasErrors() {
|
||||
t.Fatal("succeeded; want errors")
|
||||
}
|
||||
@ -1601,7 +1601,7 @@ resource "aws_instance" "foo" {
|
||||
},
|
||||
})
|
||||
|
||||
diags := ctx.Validate(m)
|
||||
diags := ctx.Validate(context.Background(), m)
|
||||
if !diags.HasErrors() {
|
||||
t.Fatal("succeeded; want errors")
|
||||
}
|
||||
@ -1682,7 +1682,7 @@ output "out" {
|
||||
},
|
||||
})
|
||||
|
||||
diags := ctx.Validate(m)
|
||||
diags := ctx.Validate(context.Background(), m)
|
||||
if diags.HasErrors() {
|
||||
t.Fatal(diags.ErrWithWarnings())
|
||||
}
|
||||
@ -1709,7 +1709,7 @@ output "out" {
|
||||
`,
|
||||
})
|
||||
|
||||
diags := testContext2(t, &ContextOpts{}).Validate(m)
|
||||
diags := testContext2(t, &ContextOpts{}).Validate(context.Background(), m)
|
||||
if !diags.HasErrors() {
|
||||
t.Fatal("succeeded; want errors")
|
||||
}
|
||||
@ -1747,7 +1747,7 @@ output "out" {
|
||||
`,
|
||||
})
|
||||
|
||||
diags := testContext2(t, &ContextOpts{}).Validate(m)
|
||||
diags := testContext2(t, &ContextOpts{}).Validate(context.Background(), m)
|
||||
if !diags.HasErrors() {
|
||||
t.Fatal("succeeded; want errors")
|
||||
}
|
||||
@ -1795,7 +1795,7 @@ resource "test_instance" "a" {
|
||||
addrs.NewDefaultProvider("test"): testProviderFuncFixed(p),
|
||||
},
|
||||
})
|
||||
diags := ctx.Validate(m)
|
||||
diags := ctx.Validate(context.Background(), m)
|
||||
if diags.HasErrors() {
|
||||
t.Fatal(diags.Err())
|
||||
}
|
||||
@ -1845,7 +1845,7 @@ func TestContext2Validate_sensitiveProvisionerConfig(t *testing.T) {
|
||||
return pr.ValidateProvisionerConfigResponse
|
||||
}
|
||||
|
||||
diags := c.Validate(m)
|
||||
diags := c.Validate(context.Background(), m)
|
||||
if diags.HasErrors() {
|
||||
t.Fatalf("unexpected error: %s", diags.Err())
|
||||
}
|
||||
@ -1939,7 +1939,7 @@ resource "test_instance" "c" {
|
||||
},
|
||||
})
|
||||
|
||||
diags := ctx.Validate(m)
|
||||
diags := ctx.Validate(context.Background(), m)
|
||||
if diags.HasErrors() {
|
||||
t.Fatal(diags.ErrWithWarnings())
|
||||
}
|
||||
@ -2006,7 +2006,7 @@ resource "test_object" "t" {
|
||||
},
|
||||
})
|
||||
|
||||
diags := ctx.Validate(m)
|
||||
diags := ctx.Validate(context.Background(), m)
|
||||
if diags.HasErrors() {
|
||||
t.Fatal(diags.ErrWithWarnings())
|
||||
}
|
||||
@ -2063,7 +2063,7 @@ output "out" {
|
||||
},
|
||||
})
|
||||
|
||||
diags := ctx.Validate(m)
|
||||
diags := ctx.Validate(context.Background(), m)
|
||||
if diags.HasErrors() {
|
||||
t.Fatal(diags.ErrWithWarnings())
|
||||
}
|
||||
@ -2096,7 +2096,7 @@ func TestContext2Validate_nonNullableVariableDefaultValidation(t *testing.T) {
|
||||
|
||||
ctx := testContext2(t, &ContextOpts{})
|
||||
|
||||
diags := ctx.Validate(m)
|
||||
diags := ctx.Validate(context.Background(), m)
|
||||
if diags.HasErrors() {
|
||||
t.Fatal(diags.ErrWithWarnings())
|
||||
}
|
||||
@ -2139,7 +2139,7 @@ resource "aws_instance" "test" {
|
||||
},
|
||||
})
|
||||
|
||||
diags := ctx.Validate(m)
|
||||
diags := ctx.Validate(context.Background(), m)
|
||||
if diags.HasErrors() {
|
||||
t.Fatal(diags.ErrWithWarnings())
|
||||
}
|
||||
@ -2182,7 +2182,7 @@ resource "aws_instance" "test" {
|
||||
},
|
||||
})
|
||||
|
||||
diags := ctx.Validate(m)
|
||||
diags := ctx.Validate(context.Background(), m)
|
||||
if !diags.HasErrors() {
|
||||
t.Fatalf("succeeded; want error")
|
||||
}
|
||||
@ -2228,7 +2228,7 @@ resource "aws_instance" "test" {
|
||||
},
|
||||
})
|
||||
|
||||
diags := ctx.Validate(m)
|
||||
diags := ctx.Validate(context.Background(), m)
|
||||
if !diags.HasErrors() {
|
||||
t.Fatalf("succeeded; want error")
|
||||
}
|
||||
@ -2269,7 +2269,7 @@ resource "aws_instance" "test" {
|
||||
},
|
||||
})
|
||||
|
||||
diags := ctx.Validate(m)
|
||||
diags := ctx.Validate(context.Background(), m)
|
||||
if diags.HasErrors() {
|
||||
t.Fatal(diags.ErrWithWarnings())
|
||||
}
|
||||
@ -2318,7 +2318,7 @@ resource "aws_instance" "test" {
|
||||
},
|
||||
})
|
||||
|
||||
diags := ctx.Validate(m)
|
||||
diags := ctx.Validate(context.Background(), m)
|
||||
if !diags.HasErrors() {
|
||||
t.Fatalf("succeeded; want error")
|
||||
}
|
||||
@ -2359,7 +2359,7 @@ resource "aws_instance" "test" {
|
||||
},
|
||||
})
|
||||
|
||||
diags := ctx.Validate(m)
|
||||
diags := ctx.Validate(context.Background(), m)
|
||||
if !diags.HasErrors() {
|
||||
t.Fatalf("succeeded; want error")
|
||||
}
|
||||
@ -2405,7 +2405,7 @@ resource "aws_instance" "test" {
|
||||
},
|
||||
})
|
||||
|
||||
diags := ctx.Validate(m)
|
||||
diags := ctx.Validate(context.Background(), m)
|
||||
if diags.HasErrors() {
|
||||
t.Fatal(diags.ErrWithWarnings())
|
||||
}
|
||||
@ -2448,7 +2448,7 @@ resource "aws_instance" "test" {
|
||||
},
|
||||
})
|
||||
|
||||
diags := ctx.Validate(m)
|
||||
diags := ctx.Validate(context.Background(), m)
|
||||
if diags.HasErrors() {
|
||||
t.Fatal(diags.ErrWithWarnings())
|
||||
}
|
||||
@ -2482,7 +2482,7 @@ locals {
|
||||
},
|
||||
})
|
||||
|
||||
diags := ctx.Validate(m)
|
||||
diags := ctx.Validate(context.Background(), m)
|
||||
warn := diags.ErrWithWarnings().Error()
|
||||
if !strings.Contains(warn, `The attribute "foo" is deprecated`) {
|
||||
t.Fatalf("expected deprecated warning, got: %q\n", warn)
|
||||
|
Loading…
Reference in New Issue
Block a user