terraform/internal
Martin Atkins 055c432f12 lang/globalref: Global reference analysis utilities
Our existing functionality for dealing with references generally only has
to concern itself with one level of references at a time, and only within
one module, because we use it to draw a dependency graph which then ends
up reflecting the broader context.

However, there are some situations where it's handy to be able to ask
questions about the indirect contributions to a particular expression in
the configuration, particularly for additional hints in the user interface
where we're just providing some extra context rather than changing
behavior.

This new "globalref" package therefore aims to be the home for algorithms
for use-cases like this. It introduces its own special "Reference" type
that wraps addrs.Reference to annotate it also with the usually-implied
context about where the references would be evaluated.

With that building block we can therefore ask questions whose answers
might involve discussing references in multiple packages at once, such as
"which resources directly or indirectly contribute to this expression?",
including indirect hops through input variables or output values which
would therefore change the evaluation context.

The current implementations of this are around mapping references onto the
static configuration expressions that they refer to, which is a pretty
broad and conservative approach that unfortunately therefore loses
accuracy when confronted with complex expressions that might take dynamic
actions on the contents of an object. My hunch is that this'll be good
enough to get some initial small use-cases solved, though there's plenty
room for improvement in accuracy.

It's somewhat ironic that this sort of "what is this value built from?"
question is the use-case I had in mind when I designed the "marks" feature
in cty, yet we've ended up putting it to an unexpected but still valid
use in Terraform for sensitivity analysis and our currently handling of
that isn't really tight enough to permit other concurrent uses of marks
for other use-cases. I expect we can address that later and so maybe we'll
try for a more accurate version of these analyses at a later date, but my
hunch is that this'll be good enough for us to still get some good use out
of it in the near future, particular related to helping understand where
unknown values came from and in tailoring our refresh results in plan
output to deemphasize detected changes that couldn't possibly have
contributed to the proposed plan.
2022-03-04 15:51:36 -05:00
..
addrs addrs: Reference.DisplayString method 2022-03-04 15:51:36 -05:00
backend [cloud] run tasks output formatting 2022-02-24 14:02:37 -05:00
builtin return diagnostics from provisioners 2021-05-19 11:24:54 -04:00
cloud Updated for latest go-tfe run task changes 2022-02-25 15:32:16 -05:00
command Merge pull request #30525 from nozaq/provider-config-default 2022-02-22 16:13:41 -05:00
communicator de-linting 2021-09-01 11:36:21 -04:00
configs configs: Validate pre/postcondition self-refs 2022-02-03 09:37:22 -05:00
copy deprecate helper/copy 2020-10-08 08:42:16 -04:00
dag do not use pointer addr strings as map keys in set 2022-01-05 11:28:47 +00:00
depsfile providercache: Discard lock entries for unused providers 2021-12-17 15:30:21 -08:00
didyoumean didyoumean: move from "helper" to "internal" 2020-10-02 13:35:07 -07:00
e2e Move states/ to internal/states/ 2021-05-17 14:09:07 -07:00
earlyconfig addrs: Expose the registry address parser's error messages 2021-11-30 15:46:16 -08:00
experiments experiments: New "preconditions_postconditions" experiment 2022-01-28 11:00:29 -05:00
getmodules getmodules: Use go-getter v1.5.10 and return to upstream GitGetter 2022-01-03 11:44:16 -08:00
getproviders Fix failing lint check for deprecated x/crypto/openpgp library 2021-11-18 14:59:29 -06:00
grpcwrap Move plugin/ and plugin6/ to internal/plugin{,6}/ 2021-05-17 14:09:07 -07:00
helper/slowmessage remove wrapped streams and readline 2021-10-28 11:51:39 -04:00
httpclient Move httpclient/ to internal/httpclient/ 2021-05-17 14:09:07 -07:00
initwd addrs: Expose the registry address parser's error messages 2021-11-30 15:46:16 -08:00
instances InstancesForModule should not panic 2021-12-17 13:31:41 -05:00
ipaddr lang/funcs: Preserve IP address leading zero behavior from Go 1.16 2021-08-17 15:20:05 -07:00
lang lang/globalref: Global reference analysis utilities 2022-03-04 15:51:36 -05:00
legacy Move states/ to internal/states/ 2021-05-17 14:09:07 -07:00
logging cleanup panic output 2021-12-17 11:57:52 -05:00
modsdir Refactoring of module source addresses and module installation 2021-06-03 08:50:34 -07:00
moduledeps Move plugin/ and plugin6/ to internal/plugin{,6}/ 2021-05-17 14:09:07 -07:00
moduletest Move configs/ to internal/configs/ 2021-05-17 14:09:07 -07:00
plans go.mod: go get google.golang.org/protobuf@v1.27.1 2021-10-11 16:37:39 -07:00
plugin internal/plugin[6]: Add generated mocks 2021-10-28 20:16:26 -05:00
plugin6 Introduce Terraform Plugin Protocol 6.2 with legacy_type_system fields from Protocol 5 (#30375) 2022-01-20 09:57:42 -05:00
provider-simple Move plugin/ and plugin6/ to internal/plugin{,6}/ 2021-05-17 14:09:07 -07:00
provider-simple-v6 Move plugin/ and plugin6/ to internal/plugin{,6}/ 2021-05-17 14:09:07 -07:00
provider-terraform/main Move plugin/ and plugin6/ to internal/plugin{,6}/ 2021-05-17 14:09:07 -07:00
providercache providercache: Discard lock entries for unused providers 2021-12-17 15:30:21 -08:00
providers providers: A type for all schemas for a particular provider 2022-03-04 15:51:36 -05:00
provisioner-local-exec/main Move plugin/ and plugin6/ to internal/plugin{,6}/ 2021-05-17 14:09:07 -07:00
provisioners Move configs/ to internal/configs/ 2021-05-17 14:09:07 -07:00
refactoring refactoring: Implied move statements can be cross-package 2022-01-11 08:43:57 -08:00
registry command: make module installation interruptible 2021-11-11 12:28:10 +00:00
repl lang: Further limit the console-only type function 2022-02-10 06:12:58 -05:00
replacefile Upgrade to Go 1.17 2021-08-17 15:20:05 -07:00
states Relax test to focus on the behavior we care about (encoded == encoded) 2022-01-05 14:38:53 -08:00
terminal remove the use of panicwrap 2021-10-28 11:51:39 -04:00
terraform providers: A type for all schemas for a particular provider 2022-03-04 15:51:36 -05:00
tfdiags Move tfdiags/ to internal/tfdiags/ 2021-05-17 14:09:07 -07:00
tfplugin5 go.mod: go get google.golang.org/protobuf@v1.27.1 2021-10-11 16:37:39 -07:00
tfplugin6 Introduce Terraform Plugin Protocol 6.2 with legacy_type_system fields from Protocol 5 (#30375) 2022-01-20 09:57:42 -05:00
typeexpr internal/typeexpr: staticcheck 2020-12-02 13:59:19 -05:00