Commit Graph

686 Commits

Author SHA1 Message Date
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
Martin Atkins
35bedc479f command: Meta.RunOperation takes a context.Context
This is part of an ongoing effort to plumb a properly-connected series of
contexts through all of the layers where we might want to generate
telemetry (or similar) in future.

This is _just enough_ to connect the top-level context created by package
main with the various child contexts created by the local backend, so
that they could in principle access the root span that package main
generates.

This is not yet sufficient to propagate the context all the way into the
language runtime. More plumbing to follow in later commits!

This intentionally does not introduce any new OpenTelemetry-specific
context: the goal is only to get the context chain in place so that we
can use it for telemetry delivery in future.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2024-11-19 10:15:21 -08:00
adenhuen
0e189b33f8
test: ensure test vars are not used in tf plan (#2128)
Signed-off-by: Aden Huen <aden.huen@gmail.com>
Signed-off-by: adenhuen <aden.huen@gmail.com>
Signed-off-by: Ados <aden.huen@gmail.com>
Co-authored-by: Oleksandr Levchenkov <ollevche@gmail.com>
2024-11-12 17:23:54 +02: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
Martin Atkins
6707ef6ca3
Fix regression of backend reinit detection when backend schema has required arguments (#2119)
Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2024-11-04 14:23:32 -05:00
boaz0
810df00376
Fix exit command in console interactive mode (#2086)
Signed-off-by: Boaz Shuster <boaz.shuster.github@gmail.com>
2024-10-29 12:13:44 +02:00
Andy Hayes
7215ee2ed8
Adds warning if tests don't provide valid variable (#2057)
Signed-off-by: Andrew Hayes <andrew.hayes@harness.io>
2024-10-15 09:20:11 +01:00
Martin Atkins
8b0b5b271b command/init: Support static eval for backend config migration check
The "backendConfigNeedsMigration" helper evaluates the backend
configuration inline to compare it with the object previously saved in the
.terraform/terraform.tfstate file.

However, this wasn't updated to use the new "static eval" functionality
and so was treating any references to variables or function calls as
invalid, causing a spurious "backend configuration changed" error when
re-initializing the working directory with identical backend configuration
settings.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2024-10-09 09:27:11 -07:00
Andy Hayes
de69070b02
Adds prompt for missing static variables (#2047)
Signed-off-by: Andrew Hayes <andrew.hayes@harness.io>
2024-10-07 18:30:42 +01:00
Christian Mesh
0d1e6cd5f0
Handle static variable secret flag (#2045)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2024-10-03 10:46:58 -04:00
Christian Mesh
c8633519b9
Make sure test vars are only processed during test commands (#2039)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2024-10-02 14:11:42 -04:00
Will Yardley
00e17ff51c
test: use regex for expected value in TestUiHookPreApply_periodicTimer (#2035)
Signed-off-by: William Yardley <wyardley@users.noreply.github.com>
2024-10-02 13:16:40 +03:00
Ioannis Polyzos
0cc4301cd5
Add test cases for GetCommand to cover invalid args scenarios (#1940)
Signed-off-by: Ioannis Polyzos <git@ipolyzos.com>
2024-09-27 10:22:47 -04:00
Andy Hayes
20187d859f
Prevents providers mirror from crashing with bad lock file (#1985)
Signed-off-by: Andrew Hayes <andrew.hayes@harness.io>
2024-09-25 09:01:17 -04:00
Oleksandr Levchenkov
485be411c0
remove unused arg in test runner start (#2019)
Signed-off-by: ollevche <ollevche@gmail.com>
2024-09-25 09:00:13 -04:00
Christian Mesh
12ed264597
Warning and Error consolidation CLI options (#1894)
Signed-off-by: Hefeweizen <jmales@gmail.com>
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
Signed-off-by: Syasusu <syasusu@163.com>
Co-authored-by: Hefeweizen <jmales@gmail.com>
Co-authored-by: Syasusu <syasusu@163.com>
2024-09-23 07:31:06 -04:00
Alexandru Trendler
48abc52e46
bug: add error handling for missing state lock config in S3, HTTP and OSS backends (#1977)
Signed-off-by: g0dfl3sh <alex1trendler@gmail.com>
Signed-off-by: Alexandru Trendler <117138249+g0dfl3sh@users.noreply.github.com>
Co-authored-by: Oleksandr Levchenkov <ollevche@gmail.com>
2024-09-20 18:29:36 +02:00
Burak Şen
854c49e04b
Fix all unknown block not outputted (#1948)
Signed-off-by: buraksenn <buraksenb@gmail.com>
2024-09-17 09:49:33 -04:00
Burak Şen
2091c96984
Fix setops not used in block set renderer (#1950)
Signed-off-by: buraksenn <buraksenb@gmail.com>
2024-09-17 09:36:35 -04:00
Viktor Szépe
bb63574f09
Fix typos (#1954)
Signed-off-by: Viktor Szépe <viktor@szepe.net>
2024-09-17 12:04:30 +02: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
Burak Şen
7a02fad996
Fix repetitive diagnosis output in init response (#1890)
Signed-off-by: buraksenn <buraksenb@gmail.com>
2024-09-05 07:36:18 -04: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
Christian Mesh
ed612a35ac
Fix extra file generated in tests of #1554 (#1880)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2024-08-02 07:33:13 -04:00
Christian Mesh
ce24a6b961
Better var file type detection (#1881)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2024-08-02 07:29:40 -04:00
Andrew Hayes
131c2cadda
Adds multi line support to console (#1875)
Signed-off-by: Andrew Hayes <andrew.hayes@harness.io>
2024-08-02 10:21:44 +01: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
e23aacb440
Avoid copies on calls to parser.Sources() (#1811)
Signed-off-by: Jon Johnson <jon.johnson@chainguard.dev>
2024-07-29 16:15:51 -04:00
Christian Mesh
eb69100dbd
Add missing [options] to help text where applicable (#1855)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2024-07-24 09:27:07 -04:00
Siddhartha Sonker
579d74c409
Add -show-sensitive flag to tofu plan, apply, state-show and output commands (#1554)
Signed-off-by: siddharthasonker95 <158144589+siddharthasonker95@users.noreply.github.com>
2024-07-22 10:58:57 +01:00
James Humphries
cc91bf25f5
use dynamic types when handling variables during plan and show static evaluation (#1826)
Signed-off-by: James Humphries <james@james-humphries.co.uk>
2024-07-17 11:46:24 -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
Christian Mesh
ee75b40d14
Update help text for static variable support (#1804)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2024-07-11 11:00:18 -04:00
Christian Mesh
0a53bab15d
Fix tofu validate with static variables (#1788)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2024-07-11 10:16:20 -04:00
Christian Mesh
5f1509d8c7
Remove encryption diags from autocomplete (#1793)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2024-07-10 10:07:11 -04:00
Oleksandr Levchenkov
76e2d7c4fc
fix: providers block shouldn't be merged with file mocks in tofu test (#1791)
Signed-off-by: ollevche <ollevche@gmail.com>
Signed-off-by: Oleksandr Levchenkov <ollevche@gmail.com>
Co-authored-by: Arel Rabinowitz <30493345+RLRabinowitz@users.noreply.github.com>
2024-07-10 16:18:09 +03:00
Christian Mesh
dcaa01e1ca
Include .tofu in tofu fmt (#1790)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2024-07-10 09:06:08 -04: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
Christian Mesh
2c5c8a5f72
Fix plan static variable injection (#1771)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
Signed-off-by: James Humphries <james@james-humphries.co.uk>
Co-authored-by: James Humphries <james@james-humphries.co.uk>
2024-07-09 07:17:45 -04:00
Andrew Hayes
7e706fa1a7
Adds provider function to tofu scheme/metadata commands (#1753)
Signed-off-by: Andrew Hayes <andrew.hayes@harness.io>
2024-07-01 16:41:27 +01:00
Oleksandr Levchenkov
19b5287b8f
allow static evaluations in encryption configuration (#1728)
Signed-off-by: ollevche <ollevche@gmail.com>
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
Signed-off-by: Oleksandr Levchenkov <ollevche@gmail.com>
Co-authored-by: Christian Mesh <christianmesh1@gmail.com>
2024-06-24 10:18:16 -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
chenzj
1ecb2dcae3
Fixes: show insensitive plan details when resource in set with sensitive value (#1313)
Signed-off-by: Zejun Chen <tibazq@gmail.com>
Signed-off-by: chenzj <tibazq@gmail.com>
Co-authored-by: Oleksandr Levchenkov <ollevche@gmail.com>
2024-06-20 14:06:33 -04:00
Arel Rabinowitz
5667df4969
Change link for missing module or missing provider (#1724)
Signed-off-by: RLRabinowitz <rlrabinowitz2@gmail.com>
2024-06-16 11:46:37 -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