-
Notifications
You must be signed in to change notification settings - Fork 9.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
enable use of provider functions in the Terraform language #34394
Commits on Dec 20, 2023
-
lang: Expose built-in functions under core:: namespace
This essentially doubles up the registrations for all of the built-in functions to have both non-namespaced and core::-namespaced versions of each function. This is in preparation for later commits introducing other namespaces, such as a provider:: namespace which could hold functions that were contributed by providers that are currently in scope.
Configuration menu - View commit details
-
Copy full SHA for d1df979 - Browse repository at this point
Copy the full SHA d1df979View commit details -
add special cases for jsonfunction
The jsonfunction package has special cases for some internal functions, and wee need to add the namespaced equivalents to those lists.
Configuration menu - View commit details
-
Copy full SHA for d7a1ebb - Browse repository at this point
Copy the full SHA d7a1ebbView commit details -
lang: Scope accepts "External Functions"
This is intended as a bridge to functions defined outside of the core language, which will live in other namespaces in order to avoid ambiguity with any built-in functions. For now we only accept provider-contributed external functions. The lang package doesn't really know anything special about providers, so its only responsibility here is to enforce the naming scheme that any provider-contributed functions always live under the namespace prefix "provider::NAME::", where NAME is a name decided by whatever codepath instantiated the state as a unique identifier for a particular provider. This commit also includes updates to the core package to make it possible to pass in ExternalFuncs in principle, although in practice we don't yet have any codepaths which do so, and so this is effectively a no-op commit.
Configuration menu - View commit details
-
Copy full SHA for 17d7f7f - Browse repository at this point
Copy the full SHA 17d7f7fView commit details -
cache providers used for functions
We need to be able to reuse providers which are used for function calls, so cache them in the EvalContext. This does require a way to close the provider however, which we can do via the normal root module close node since it already does the same for provisioners. Update the `CloseProvisioners` method to be a more general `ClosePlugins` method, and use that to call Close on the cached providers too.
Configuration menu - View commit details
-
Copy full SHA for 33be99d - Browse repository at this point
Copy the full SHA 33be99dView commit details -
Configuration menu - View commit details
-
Copy full SHA for b07f66a - Browse repository at this point
Copy the full SHA b07f66aView commit details -
Configuration menu - View commit details
-
Copy full SHA for bc559c1 - Browse repository at this point
Copy the full SHA bc559c1View commit details -
core: Minimal working implementation of provider-contributed functions
This establishes all of the wiring necessary for a provider's declared functions to appear in the hcl.EvalContext when we evaluate expressions inside a module that depends on a provider that contributes functions. This does not yet make any attempts to guarantee that the provider-contributed functions correctly honor the contracts such as behaving as pure functions. Properly checking this is important because if a function doesn't uphold Terraform's expectations then it will cause confusing errors reported downstream, incorrectly blaming other components for the inconsistency.
Configuration menu - View commit details
-
Copy full SHA for 8b76d50 - Browse repository at this point
Copy the full SHA 8b76d50View commit details -
Configuration menu - View commit details
-
Copy full SHA for d122b2c - Browse repository at this point
Copy the full SHA d122b2cView commit details -
check function descriptions directly
Now that we dynamically add scoped versions to the global functions we can't check the static Descriptions list. This should be OK since the function descriptions are taken directly from Descriptions list, and if any other scoped functions were added in the future, they may not be coming from the current global set of functions anyway.
Configuration menu - View commit details
-
Copy full SHA for 1644c2f - Browse repository at this point
Copy the full SHA 1644c2fView commit details
Commits on Dec 21, 2023
-
Configuration menu - View commit details
-
Copy full SHA for 2618855 - Browse repository at this point
Copy the full SHA 2618855View commit details