opentofu/lang
Martin Atkins f09b090d97 lang: Allow "resource." prefix as another way to refer to resources
The current way to refer to a managed resource is to use its resource type
name as a top-level symbol in the reference. This is convenient and makes
sense given that managed resources are the primary kind of object in
Terraform.

However, it does mean that an externally-extensible namespace (the set
of all possible resource type names) overlaps with a reserved word
namespace (the special prefixes like "path", "var", etc), and thus
introducing any new reserved prefix in future risks masking an existing
resource type so it can't be used anymore.

We only intend to introduce new reserved symbols as part of future
language editions that each module can opt into separately, and when doing
so we will always research to try to choose a name that doesn't overlap
with commonly-used providers, but not all providers are visible to us and
so there is always a small chance that the name we choose will already be
in use by a third-party provider.

In preparation for that event, this introduces an alternative way to refer
to managed resources that mimics the reference style used for data
resources: resource.type.name . When using this form, the second portion
is _always_ a resource type name and never a reserved word.

There is currently no need to use this because all of the already-reserved
symbol names are effectively blocked from use by existing Terraform
versions that lack this escape hatch. Therefore there's no explicit
documentation about it yet.

The intended use for this is that a module upgrade tool for a future
language edition would detect references to resource types that have now
become reserved words and add the "resource." prefix to keep that
functionality working. Existing modules that aren't opted in to the new
language edition would keep working without that prefix, thus keeping to
compatibility promises.
2021-05-17 11:17:25 -07:00
..
blocktoattr make blocktoattr an hcldec.UnknownBody 2021-04-13 18:42:15 -04:00
funcs lang/funcs: File hashing functions stream data from disk 2021-05-12 09:28:31 -07:00
testdata/functions-test lang/funcs: Update fileset() function to include path as separate first argument, automatically trim the path argument from results, and ensure results are always canonical with forward slash path separators 2019-08-30 20:19:44 -04:00
data_test.go eval Data needs to operate on whole modules 2020-04-12 10:50:31 -04:00
data.go remove GetModuleInstanceOutput 2020-04-14 14:49:10 -04:00
doc.go lang: new package for the runtime parts of the config language 2018-10-16 18:44:26 -07:00
eval_test.go lang: Allow "resource." prefix as another way to refer to resources 2021-05-17 11:17:25 -07:00
eval.go lang: Allow "resource." prefix as another way to refer to resources 2021-05-17 11:17:25 -07:00
functions_test.go lang/funcs: "one" function 2021-04-12 15:32:03 -07:00
functions.go lang/funcs: add (console-only) TypeFunction (#28501) 2021-04-23 10:29:50 -04:00
references.go vendor: switch to HCL 2.0 in the HCL repository 2019-10-02 15:10:21 -07:00
scope.go lang/funcs: add (console-only) TypeFunction (#28501) 2021-04-23 10:29:50 -04:00