opentofu/internal/cloud
Nick Fagerlund b43daeaa8d Cloud backend: accept version constraints from workspaces
The cloud backend (and remote before it) previously expected a TFC workspace's
`terraform-version` attribute to be either the magic string `"latest"` or an
explicit semver value. But a workspace might have a version constraint instead
(like `~> 1.1.0`), in which case the version check would blow up.

This commit checks whether `terraform-version` is a valid version constraint
before erroring out, and if so, returns success if the local version meets the
constraint.

Because it's not practical to deeply introspect the slice of version space
defined by a constraint, this check is slightly less robust than the version
comparisons below it:

- It can give a false OK on open-ended constraints like `>= 1.1.0`. Say you're
  running 1.3.0, it changed the state format, and the TFE instance admin has
  not yet added any 1.3.x Terraform versions; your workspace will now break.

- It will give a false not-OK when using different minor versions within a range
  that we know to be compatible, e.g. remote constraint of `~> 0.15.0` and local
  version of 1.1.0.

- This would be totally useless with the pre-0.14 versions of Terraform, where
  patch releases could change state format... but we're not going back in time
  to add this feature to them anyway.

Still, in the most common likely case (`~> x.y.z`), it'll complain at you (with
an error you can choose to override) if you're not using the same minor version,
and that seems proportionate, useful, and expected.
2021-10-28 19:29:13 -05:00
..
e2e e2e test for cloud run variables 2021-10-28 19:29:12 -05:00
testdata Run apply -refresh-state instead of refresh 2021-10-28 19:29:12 -05:00
backend_apply_test.go Remove prefix from the cloud backend config 2021-10-28 19:29:12 -05:00
backend_apply.go Add run variables to cloud plan operations from non-file sources 2021-10-28 19:29:12 -05:00
backend_cli.go Initial commit of 'cloud' package 2021-10-28 19:29:09 -05:00
backend_colorize.go Initial commit of 'cloud' package 2021-10-28 19:29:09 -05:00
backend_common.go Add run variables to cloud plan operations from non-file sources 2021-10-28 19:29:12 -05:00
backend_context_test.go Rename cloud.testBackendDefault -> cloud.testBackendWithName 2021-10-28 19:29:11 -05:00
backend_context.go Remove prefix from the cloud backend config 2021-10-28 19:29:12 -05:00
backend_plan_test.go Remove prefix from the cloud backend config 2021-10-28 19:29:12 -05:00
backend_plan.go Run apply -refresh-state instead of refresh 2021-10-28 19:29:12 -05:00
backend_refresh_test.go Run apply -refresh-state instead of refresh 2021-10-28 19:29:12 -05:00
backend_state_test.go Rename cloud.testBackendDefault -> cloud.testBackendWithName 2021-10-28 19:29:11 -05:00
backend_state.go Initial commit of 'cloud' package 2021-10-28 19:29:09 -05:00
backend_test.go Remove prefix from the cloud backend config 2021-10-28 19:29:12 -05:00
backend.go Cloud backend: accept version constraints from workspaces 2021-10-28 19:29:13 -05:00
cloud_variables_test.go Add run variables to cloud plan operations from non-file sources 2021-10-28 19:29:12 -05:00
cloud_variables.go Add run variables to cloud plan operations from non-file sources 2021-10-28 19:29:12 -05:00
errors.go Remove prefix from the cloud backend config 2021-10-28 19:29:12 -05:00
remote_test.go Initial commit of 'cloud' package 2021-10-28 19:29:09 -05:00
testing.go Remove prefix from the cloud backend config 2021-10-28 19:29:12 -05:00
tfe_client_mock.go Add auto-approve logic, e2e tests 2021-10-28 19:29:11 -05:00
versioning.go cloud: Set minimum TFE version 2021-10-28 19:29:12 -05:00