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
Allow configured providers to provide additional functions. #1491
Conversation
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
Reminder for the PR assignee: If this is a user-visible change, please update the changelog as part of the PR. |
Please link the relevant issue that this PR handles using one of the following words
|
a559989
to
fb9c3b4
Compare
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall I like it. I'm tempted to say that we should have some sort of ProviderFunctionFromString(input string) ProviderFunction
method that parses the addr, and then from there we can have a IsCore()
method.
That could help the readability of the code.
LGTM so far, once the TODOs are done I'll be happy to review again. (Also we could do with some more tests)
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
WIP review: looking good! |
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
This is because we need to attach provider schemas before we can properly look for provider functions required by resources Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
Please link the relevant issue that this PR handles using one of the following words
|
Please link the relevant issue that this PR handles using one of the following words
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks ok, but I can't really judge the completeness of the code as I'm not familiar with most parts of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left a couple nit comments.
LGTM overall!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall it looks good to me. I have some concerns around the performance of the graph transformation stuff, but I would need to benchmark and run it to see how performant it is.
My comments are mostly small nitpicks, which I would prefer are addressed, but I'll leave that up to others to decide based on timings.
Nice work! 👍
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
c9ed866
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
Signed-off-by: Christian Mesh <christianmesh1@gmail.com>
Prior to this change a single unconfigured lazy provider instance was used per provider type to supply functions. This used the functions provided by GetSchema only.
With this change, provider function calls are detected and supplied via GraphNodeReferencer and are used in the ProviderFunctionTransformer to add dependencies between referencers and the providers that supply their functions.
With that information EvalContextBuiltin can now assume that all providers that require configuration have been configured by the time a particular scope is requested. It can then use it's initialized providers to supply all requested functions.
At a high level, it allows providers to dynamically register functions based on their configurations.
main.lua
main.tf
Output:
This requires some enhancements to the HCL library and is currently pointing at my personal fork, with a PR into the main HCL repository: hashicorp/hcl#676. As this may take some time for the HCL Team to review, I will likely move the forked code under the OpenTofu umbrella before this is merged [done].
This PR will be accompanied by a simple provider framework for implementing function providers similar to the example above.
Related to #1326
Target Release
1.7.0