-
Notifications
You must be signed in to change notification settings - Fork 140
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
Add ability for a resource to "use" another resources output automatically #72
Add ability for a resource to "use" another resources output automatically #72
Conversation
Ensure that resource IDs passed into the use field exist and are in the same resource group as the current resource.
Changes CheckResourcesAndGroupNames to be a standalone function that returns error and ResourceToGroup map. Also removed the -c flag from run_examples to remove the deprecation warning.
Added a step in exand that applies any matching output in "use" resources that matches the input of the current resource. In addition, tests have been reorganized to decrease the size of the test_config.go file.
Add tests for: * getResourceByID * useResource * appendAsSlice * getResourceByVarName Various fixes to support tests also made
Adding a few function comments and cleaning up a test config
This commit adds the ability to use multiple resource output lists as a single setting by merging the lists. This is done using the flatten function in terraform and with a new feild in BlueprintConfig with functions to be applied to settings in the main.tf file.
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.
@cboneti It should be ready to review again. The applyFunctions
implementation will probably have to change, but I wanted you to take a look before I acted on 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.
Please see my comments.
Please make sure we are testing the full precedence order for: default values, global vars, use, and then explicit settings.
For simplicity, move applyFunctions into the YamlConfig so it can be directly accessed during and after expand in the same way. This allows a call to expand to produce a YAML that can be used again in create with no differences in the final result. The name was also changed to WrapSettingsWith to be more explanatory and fit better under the Resource struct.
Moves expand() and validate() to the expand.go and validate.go file respectively for clarity and to keep config.go as top-level as possible.
Makes a number of changes in the useResource and applyUseResource function to decrease complexity and increase readabiltiy.
ffab3a7
to
2c9067b
Compare
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.
Questions:
- did you test all the flow as we discussed? explicitly defined, then use, then global, then default?
- did you test expanding?
- did you test creating a config based on the expanded?
Thanks!
pkg/reswriter/tfwriter.go
Outdated
if wrap, ok := res.WrapSettingsWith[setting]; ok { | ||
if len(wrap) != 2 { | ||
return fmt.Errorf( | ||
"invalid length of WrapSettingsWith, expected 2 got %d", len(wrap)) |
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.
I would also say for which resource and which setting, if these are readily available.
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.
Done
* Pass in resource Inputs and Used resource outputs directly to UseResource rather than the ResourceInfo structs * Improve Comment Clarity * Improve error output details
All feedback has been addressed, just waiting on the checks now. |
Implements the "use" field as described in the design document. This field allows a resource to depend on the outputs of another in the same resource group, which means that similar to global variables, any matching outputs names for the used variable will be paired up with a setting in the using resource, assuming none have been explicitly set yet.
There are a lot of opportunities with this in place to shorten our current examples. All available ones have been added already, but I plan to follow-up with another PR that makes output name/setting name changes to make the most of this new feature.
Submission Checklist:
pre-commit install
make tests
change?
guides?