Commit Graph

84 Commits

Author SHA1 Message Date
Christian Mesh
ece1bb4f49
Fix data provider iteration destroy (#2270)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2024-12-09 07:56:58 -05:00
Christian Mesh
f6a1d8e2dd
Support References in Variable Validation (#2216)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2024-12-04 14:24:44 -05:00
Martin Atkins
91b43aecd1
tofu: Variable validation diagnostics must mark sensitive values (#2233)
Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2024-12-03 12:40:44 -05:00
Oleksandr Levchenkov
6c8bfa2794
implement override resources for mock providers (#2168)
Signed-off-by: ollevche <ollevche@gmail.com>
2024-12-03 11:24:26 -05:00
Christian Mesh
0903aeff58
Split variable evaluation / validation scope (#2199)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2024-12-02 09:18:07 -05:00
Ronny Orot
cf34b0e6a9
Skip imports on tofu destroy (#2214)
Signed-off-by: Ronny Orot <ronny.orot@gmail.com>
2024-11-25 23:52:03 +02:00
Oleksandr Levchenkov
2758f2cfbf
fix mock provider validation (#2140)
Signed-off-by: ollevche <ollevche@gmail.com>
2024-11-20 16:45:17 +02:00
Martin Atkins
2448204201 tofu: context.Context plumbed into the graph walk driver
Earlier commits arranged for each of our tofu.Context exported methods that
perform graph-based operations to take a context.Context from their
callers, and for the main callers in package command and package backend
to connect those contexts to the top-level context from "package main"
that can potentially have an OpenTelemetry span attached to it.

This propagates those contexts a little deeper into the guts of the
language runtime, getting it as far as the shared logic that drives a
graph walk.

The next step from here would be to change the interfaces
GraphNodeExecutable and GraphNodeDynamicExpandable so that their methods
both take a context.Context, but that would involve a big sprawling
update to every implementation of each of those interfaces and so
we'll save that for a later commit to keep this one relatively clean.

This commit also reaches the first point of ambiguity where our older
conventions call for "ctx" to be the variable name for a tofu.EvalContext
rather than a context.Context. Since "ctx context.Context" is a core idiom
in the Go community, we'll switch to using evalCtx as the variable name
for tofu.EvalContext both here and in our future commits that will
modify the two main graph walk interfaces that make extensive use of the
tofu.EvalContext interface.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2024-11-19 10:15:21 -08:00
Martin Atkins
a8b6342556 tofu: Context.Input 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.Input now passes this through to the UI input implementation,
which was already written to handle cancellation. However, that
implementation currently handles interruption itself by directly watching
for the interrupt signal and so we remove the cancellation from the
context for now to avoid changing how interrupts are handled. Hopefully
in future we can remove the inline SIGINT handling from the UIInput
implementation and use its context-cancellation-handling instead.

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>
2024-11-19 10:15:21 -08:00
Martin Atkins
9cadb097ba 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>
2024-11-19 10:15:21 -08:00
Martin Atkins
6522f73249 tofu: Context.Eval 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.Eval doesn't yet do anything with its new context, but we'll
plumb this deeper in future.

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>
2024-11-19 10:15:21 -08:00
Martin Atkins
8ae790ca06 tofu: Context.Import 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.Import doesn't yet do anything with its new context, but we'll
plumb this deeper in future.

OpenTofu has some historical situational private uses of context.Context
to handle the graceful shutdown behaviors. Those use context.Context as
a private implementation detail rather than public API, and so this commit
leaves them as-is and adds a new "primary context" alongside. Hopefully
in future refactoring we can simplify this to use the primary context also
as the primary cancellation signal, but that's too risky a change to bundle
in with this otherwise-mostly-harmless context plumbing.

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>
2024-11-19 10:15:21 -08:00
Martin Atkins
3b79efa834 tofu: Context.Refresh 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.Refresh is really just a vestigal wrapper around Context.Plan, so
this just passes the given context through to Context.Plan which itself
currently ignores it.

OpenTofu has some historical situational private uses of context.Context
to handle the graceful shutdown behaviors. Those use context.Context as
a private implementation detail rather than public API, and so this commit
leaves them as-is and adds a new "primary context" alongside. Hopefully
in future refactoring we can simplify this to use the primary context also
as the primary cancellation signal, but that's too risky a change to bundle
in with this otherwise-mostly-harmless context plumbing.

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>
2024-11-19 10:15:21 -08:00
Martin Atkins
1134f19467 tofu: Context.Apply 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.Apply does not yet do anything with its new context, but this gets
the context plumbed in enough that we should be able to pass values like
telemetry spans all the way from the top-level in future.

OpenTofu has some historical situational private uses of context.Context
to handle the graceful shutdown behaviors. Those use context.Context as
a private implementation detail rather than public API, and so this commit
leaves them as-is and adds a new "primary context" alongside. Hopefully
in future refactoring we can simplify this to use the primary context also
as the primary cancellation signal, but that's too risky a change to bundle
in with this otherwise-mostly-harmless context plumbing.

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>
2024-11-19 10:15:21 -08:00
Martin Atkins
3d5039f1f3 tofu: Context.Plan 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.Plan does not yet do anything with its new context, but this gets
the context plumbed in enough that we should be able to pass values like
telemetry spans all the way from the top-level in future.

OpenTofu has some historical situational private uses of context.Context
to handle the graceful shutdown behaviors. Those use context.Context as
a private implementation detail rather than public API, and so this commit
leaves them as-is and adds a new "primary context" alongside. Hopefully
in future refactoring we can simplify this to use the primary context also
as the primary cancellation signal, but that's too risky a change to bundle
in with this otherwise-mostly-harmless context plumbing.

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>
2024-11-19 10:15:21 -08:00
Oleksandr Levchenkov
52cc91c87a
upgrade golangci-lint to v1.62 (#2174)
Signed-off-by: ollevche <ollevche@gmail.com>
2024-11-18 19:56:29 +02:00
Christian Mesh
c57e634bc4
Fix destroy/orphan path with provider instances (#2150)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2024-11-07 12:41:13 -05:00
Christian Mesh
30b5088da4
Improve log messages for providers with keys (#2152)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2024-11-07 11:56:21 -05:00
Christian Mesh
fd775f0fe3
Implement Provider for_each (#2105)
Signed-off-by: ollevche <ollevche@gmail.com>
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
Signed-off-by: Ronny Orot <ronny.orot@gmail.com>
Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
Co-authored-by: ollevche <ollevche@gmail.com>
Co-authored-by: Ronny Orot <ronny.orot@gmail.com>
Co-authored-by: Martin Atkins <mart@degeneration.co.uk>
2024-11-05 18:08:23 -05:00
Arel Rabinowitz
3d4bf29c56
Add exclude flag support (#1900)
Signed-off-by: RLRabinowitz <rlrabinowitz2@gmail.com>
2024-11-05 10:16:00 -05:00
Christian Mesh
e802b23200
Partial revert of #1911, support provider for_each in aliases (#2121)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2024-11-05 06:19:52 -05:00
jinjiadu
384dc4cb93
chore: fix some function names (#2108)
Signed-off-by: jinjiadu <jinjiadu@aliyun.com>
2024-10-29 12:07:10 +02:00
Christian Mesh
e3a6bcab96
Fix provider functions in child modules (#2082)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2024-10-23 10:42:38 -04:00
Christian Mesh
7cacb9f066
Fix function refs in variable validation (#2052)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2024-10-17 12:37:54 -04:00
Christian Mesh
d36220e44c
Cleanup and encode existing "bugs" in ProviderTransformer (#2069)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2024-10-16 08:44:40 -04:00
Nathan Baulch
9b7bec31b4
Another batch of minor typos (#1953)
Signed-off-by: Nathan Baulch <nathan.baulch@gmail.com>
2024-09-09 07:51:39 -04:00
Andy Hayes
389f33fdc5
300/provider foreach (#1911)
Signed-off-by: Andrew Hayes <andrew.hayes@harness.io>
2024-09-06 14:33:05 +01:00
Nathan Baulch
ea558d9d4b
Fix typos (#1905)
Signed-off-by: Nathan Baulch <nathan.baulch@gmail.com>
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
Co-authored-by: Christian Mesh <christianmesh1@gmail.com>
2024-08-29 13:20:33 -04:00
Syasusu
1c0cb13bf7
feat: Add support for tofu.workspace which will be resolved in the same way as terraform.workspace (#1305)
Signed-off-by: Syasusu <syasusu@163.com>
2024-08-01 08:14:34 -04:00
Jon Johnson
8f001311ad
Improve ModuleExpansionTransformer performance (#1809)
Signed-off-by: Jon Johnson <jon.johnson@chainguard.dev>
2024-07-29 15:55:37 -04:00
Ronny Orot
884410e63a
Add more tests and refactor import for_each (#1645)
Signed-off-by: Ronny Orot <ronny.orot@gmail.com>
2024-07-26 11:01:47 -04:00
Jon Johnson
a003782fec
Assert that NodeRootVariable implements Execute (#1857)
Signed-off-by: Jon Johnson <jon.johnson@chainguard.dev>
2024-07-26 07:32:33 -04:00
Jon Johnson
7d94797219
Only call StringWithNodeTypes for TRACE logs (#1810)
Signed-off-by: Jon Johnson <jon.johnson@chainguard.dev>
2024-07-24 13:44:20 -04:00
Emre Duzgun
b93acf96a9
Fix more tests on Windows (#1824)
Signed-off-by: eduzgun <emreduz00@gmail.com>
2024-07-17 10:41:12 -04:00
Denis O
864aa9d1d6
Error handling fixes (#1816)
Signed-off-by: Denis O <denis.o@linux.com>
2024-07-15 11:58:43 +02:00
James Humphries
12d9380982
Improve comparison of sensitive marks on resources, and propagate the sensitive_attributes correctly (#1640)
Signed-off-by: James Humphries <james@james-humphries.co.uk>
2024-07-09 08:42:02 -04:00
Oleksandr Levchenkov
9d9a7aab06
add mock providers for testing framework (#1772)
Signed-off-by: ollevche <ollevche@gmail.com>
2024-07-09 14:41:52 +03:00
Andrew Hayes
3ef6d45afe
Adds source context for the 'insufficient feature blocks' error (#1777)
Signed-off-by: Andrew Hayes <andrew.hayes@harness.io>
2024-07-09 09:56:07 +01:00
Christian Mesh
edc654c1de
Hardcode golangci-lint revision to fix build on main (#1759)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2024-07-01 10:47:26 -04:00
Christian Mesh
8f8e0aa4aa
Static Evaluation Base, Module Sources, Backend Config (#1718)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
Signed-off-by: Christian Mesh <cristianmesh1@gmail.com>
Co-authored-by: James Humphries <James@james-humphries.co.uk>
Co-authored-by: Oleksandr Levchenkov <ollevche@gmail.com>
2024-06-24 09:13:07 -04:00
Oleksandr Levchenkov
64fb36dc54
add override implementation for testing framework (#1499)
Signed-off-by: ollevche <ollevche@gmail.com>
Signed-off-by: Oleksandr Levchenkov <ollevche@gmail.com>
Co-authored-by: Janos <86970079+janosdebugs@users.noreply.github.com>
Co-authored-by: Ronny Orot <ronny.orot@gmail.com>
2024-06-06 13:20:41 +03:00
Oleksandr Levchenkov
5a161c8bcc
add automated copyright header check (#1696)
Signed-off-by: ollevche <ollevche@gmail.com>
Signed-off-by: Oleksandr Levchenkov <ollevche@gmail.com>
2024-06-03 16:49:36 +03:00
Christian Mesh
882b942575
Provider functions in variable validations (#1689)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2024-05-28 11:05:34 -04:00
Ronny Orot
cc8d6e07f4
Fix bug in import 'to' parsing in json configurations (#1665)
Signed-off-by: Ronny Orot <ronny.orot@gmail.com>
2024-05-27 11:49:30 +03:00
chenzj
cffe80d300
Better wording on for_each block with unsuitable type value (#1485)
Signed-off-by: Zejun Chen <tibazq@gmail.com>
Signed-off-by: chenzj <tibazq@gmail.com>
2024-05-13 13:57:10 +03:00
Christian Mesh
015b79b139
Allow unconfigured provider functions in test context (#1603)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2024-05-07 09:31:17 -04:00
Siddhartha Sonker
6065bc593f
Fixed tofu test when module has no resource (#1409)
Signed-off-by: siddharthasonker95 <158144589+siddharthasonker95@users.noreply.github.com>
2024-05-06 14:49:42 +02:00
Alex Ott
5407c427bf
Improve performance of AttachResourceConfigTransformer on big graphs (#1558)
Signed-off-by: Alex Ott <alexott@gmail.com>
2024-04-29 11:36:54 -04:00
Christian Mesh
25149e1f6e
Add tests for AttachResourceConfigTransformer (#1570)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2024-04-29 11:36:31 -04:00
1garo
d869923103
Review and order locked struct fields (#1493)
Signed-off-by: 1garo <alevardai427@gmail.com>
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
Co-authored-by: Christian Mesh <christianmesh1@gmail.com>
2024-04-25 10:25:13 -04:00