Commit Graph

34 Commits

Author SHA1 Message Date
Martin Atkins
99a0c6eb6f Automatically translate dependency lock file entries when switching from OpenTofu's predecessor (#2791)
Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-05-19 07:25:14 -04:00
Andrei Ciobanu
22dc9b2137 Add new CLI arg to control what warnings should be shown for deprecated outputs/variables (#2705)
Signed-off-by: yottta <andrei.ciobanu@opentofu.org>
Signed-off-by: Andrei Ciobanu <andrei.ciobanu@opentofu.org>
2025-05-08 17:01:40 +03:00
Christian Mesh
d0ee5a36a5 Provider plugin cache locking (#1878)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2025-04-25 09:39:17 -04:00
Martin Atkins
4b8246c3ef e2etest: Install module packages with "oci" source address scheme
Following the lead of similar earlier work on testing the installation of
provider packages from OCI repositories, this new test exercises the new
OCI-based module source address syntax in an end-to-end fashion by directly
running "tofu init".

For the reasons described inline, this test uses a local test server as its
target OCI Registry and therefore needs to rely on a Go standard library
feature for overriding the trusted TLS certs which only works on Unix
systems other than macOS, and therefore this test will only run when the
e2etest suite is run on Linux systems. This matches the same compromise we
previously made for the provider installation flavor of this test, with
the same assumption that our module installer isn't doing anything
particularly platform-specific and that we're doing this in e2etest only
because that's an effective way to test that "package main" is wiring all
of the internal components together correctly.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-04-23 16:34:57 -07:00
Martin Atkins
c8cbd95c1f e2etest: Verify support for provider installation from oci_mirror
Most of the OCI registry interactions are unit tested in the most relevant
packages, but the overall system will only work correctly if all of the
components are correctly wired together by "package main", and that's one
part of the system that needs to be tested concretely rather than via
test doubles.

Therefore this adds an end-to-end test in our existing e2etest package
that runs "tofu init" with a CLI configuration that forces using an OCI
mirror with a TLS server provided locally by our test program. It exercises
the main happy path of provider installation in the same way that an
end-user would interact with it, to help avoid accidentally regressing
the interactions between these packages in future versions.

Unfortunately the technique this test uses to force the OpenTofu CLI
binary to trust the test server doesn't work on macOS or Windows and so
for now this test is Linux-specific. That's certainly non-ideal, but
pragmatic since we'll be relying mainly on the platform-agnostic unit tests
to cover this behavior, and we're unlikely to ever stop running the
e2etests on Linux as part of our pull request checks so even those
developing on macOS or Windows can still notice if this test becomes
broken before merging a change.

Signed-off-by: Martin Atkins <mart@degeneration.co.uk>
2025-03-26 09:52:07 -07:00
Andrei Ciobanu
dfe2876931 Add a new warning when a provider cannot be downloaded and it was requested by an implicit usage (#2479)
Signed-off-by: yottta <andrei.ciobanu@opentofu.org>
Co-authored-by: AbstractionFactory <179820029+abstractionfactory@users.noreply.github.com>
2025-02-12 18:40:54 +02: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
0d1e6cd5f0 Handle static variable secret flag (#2045)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2024-10-03 10:46:58 -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
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
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
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
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
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
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
Siddhartha Sonker
de30707b6b Fix for tofu init failure when test have spaces in their name (#1489)
Signed-off-by: siddharthasonker95 <158144589+siddharthasonker95@users.noreply.github.com>
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
Co-authored-by: Christian Mesh <christianmesh1@gmail.com>
2024-04-25 11:11:38 -04:00
Christian Mesh
54e3b66dc1 Provider Defined Functions direct e2e test (#1476)
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-04-22 13:15:59 +01:00
Christian Mesh
d7e96665f6 Add unencrypted Method for migrations (#1458)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2024-04-12 09:38:21 -04:00
Christian Mesh
abb7bc4c52 Encryption e2e tests (#1389)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
2024-03-13 13:06:03 -04:00
Christian Mesh
abd324ea7c Revert "Fixes #898: Replace hashicorp and terraform references" (#995) 2023-12-11 15:10:03 -05:00
Janos
15bef1428a Fixes #898: Replace hashicorp and terraform references (#973)
Signed-off-by: Janos Bonic <86970079+janosdebugs@users.noreply.github.com>
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
Co-authored-by: Christian Mesh <christianmesh1@gmail.com>
2023-12-08 08:03:09 -05:00
Thiago Padilha
a3150d6b31 Avoid mutating input config in node_resource_validate (#850)
Signed-off-by: Thiago Padilha <thiago@padilha.cc>
2023-11-10 13:51:39 +01:00
RLRabinowitz
e0ecd2ebb3 Use registry.opentofu.org as the default registry (#379)
Signed-off-by: RLRabinowitz <rlrabinowitz2@gmail.com>
2023-10-03 10:49:38 +03:00
Yaron Yarimi
487d9bc6a4 Rename multiple packages to OpenTofu (addrs, backend, command) (#506) 2023-09-21 15:38:46 +03:00
RLRabinowitz
23cd2c91c1 Remove terraform from E2E test names 2023-08-28 17:29:07 +03:00
RLRabinowitz
3dd8fc9943 Remove terraform mention from TF file names 2023-08-28 17:10:28 +03:00
Reda Khaled
100c44b6c3 bugfix: issue-28274, terraform providers mirror command should honor terraform lock file 2023-02-25 00:16:46 +01:00
James Bardin
d0d6501c1f s/trigger/triggers_replace/
Rename `triggers` to be more descriptive, making it similar to
`replace_triggered_by`.
2022-12-05 15:23:57 -05:00
James Bardin
58e15c7f0e add terraform_data e2e test 2022-12-05 15:23:57 -05:00
Martin Atkins
d0a35c60a7 providercache: Ignore lock-mismatching global cache entries
When we originally introduced the trust-on-first-use checksum locking
mechanism in v0.14, we had to make some tricky decisions about how it
should interact with the pre-existing optional read-through global cache
of provider packages:

The global cache essentially conflicts with the checksum locking because
if the needed provider is already in the cache then Terraform skips
installing the provider from upstream and therefore misses the opportunity
to capture the signed checksums published by the provider developer. We
can't use the signed checksums to verify a cache entry because the origin
registry protocol is still using the legacy ziphash scheme and that is
only usable for the original zipped provider packages and not for the
unpacked-layout cache directory. Therefore we decided to prioritize the
existing cache directory behavior at the expense of the lock file behavior,
making Terraform produce an incomplete lock file in that case.

Now that we've had some real-world experience with the lock file mechanism,
we can see that the chosen compromise was not ideal because it causes
"terraform init" to behave significantly differently in its lock file
update behavior depending on whether or not a particular provider is
already cached. By robbing Terraform of its opportunity to fetch the
official checksums, Terraform must generate a lock file that is inherently
non-portable, which is problematic for any team which works with the same
Terraform configuration on multiple different platforms.

This change addresses that problem by essentially flipping the decision so
that we'll prioritize the lock file behavior over the provider cache
behavior. Now a global cache entry is eligible for use if and only if the
lock file already contains a checksum that matches the cache entry. This
means that the first time a particular configuration sees a new provider
it will always be fetched from the configured installation source
(typically the origin registry) and record the checksums from that source.

On subsequent installs of the same provider version already locked,
Terraform will then consider the cache entry to be eligible and skip
re-downloading the same package.

This intentionally makes the global cache mechanism subordinate to the
lock file mechanism: the lock file must be populated in order for the
global cache to be effective. For those who have many separate
configurations which all refer to the same provider version, they will
need to re-download the provider once for each configuration in order to
gather the information needed to populate the lock file, whereas before
they would have only downloaded it for the _first_ configuration using
that provider.

This should therefore remove the most significant cause of folks ending
up with incomplete lock files that don't work for colleagues using other
platforms, and the expense of bypassing the cache for the first use of
each new package with each new configuration. This tradeoff seems
reasonable because otherwise such users would inevitably need to run
"terraform providers lock" separately anyway, and that command _always_
bypasses the cache. Although this change does decrease the hit rate of the
cache, if we subtract the never-cached downloads caused by
"terraform providers lock" then this is a net benefit overall, and does
the right thing by default without the need to run a separate command.
2022-11-04 16:18:15 -07:00
James Bardin
553b8c6de5 expand module subdir globs 2022-08-17 16:27:58 -04:00
Martin Atkins
01b22f4b76 command/e2etest: TestProviderTampering
We have various mechanisms that aim to ensure that the installed provider
plugins are consistent with the lock file and that the lock file is
consistent with the provider requirements, and we do have existing unit
tests for them, but all of those cases mock our fake out at least part of
the process and in the past that's caused us to miss usability
regressions, where we still catch the error but do so at the wrong layer
and thus generate error message lacking useful additional context.

Here we'll add some new end-to-end tests to supplement the existing unit
tests, making sure things work as expected when we assemble the system
together as we would in a release. These tests cover a number of different
ways in which the plugin selections can grow inconsistent.

These new tests all run only when we're in a context where we're allowed
to access the network, because they exercise the real plugin installer
codepath. We could technically build this to use a local filesystem mirror
or other such override to avoid that, but the point here is to make sure
we see the expected behavior in the main case, and so it's worth the
small additional cost of downloading the null provider from the real
registry.
2021-10-05 10:59:59 -07:00
Martin Atkins
ffe056bacb Move command/ to internal/command/
This is part of a general effort to move all of Terraform's non-library
package surface under internal in order to reinforce that these are for
internal use within Terraform only.

If you were previously importing packages under this prefix into an
external codebase, you could pin to an earlier release tag as an interim
solution until you've make a plan to achieve the same functionality some
other way.
2021-05-17 14:09:07 -07:00