-
Notifications
You must be signed in to change notification settings - Fork 101
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 logic to build configuration for multiple Terraform providers support #7189
Add logic to build configuration for multiple Terraform providers support #7189
Conversation
da01510
to
725f211
Compare
725f211
to
12e1e49
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.
Were you able to test these changes end to end locally?
Also, can you rebase with main since some of the code in this pr is duplicate of c0b50a5
aa89820
to
a01464d
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.
PR title and description are out of date. Please update them. Also, it is good practice to write the description in a way that anyone can understand what the PR is about, think about someone looking at the commit in the future to understand what this change is, why it was etc. Same feedback for #7192
a01464d
to
bfc7466
Compare
f3dde3e
to
0a7d6a8
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.
This PR doesn't implement handling secrets, can you please call that out in the description?
Also, the typespec PR contains secrets, should that be split out into a separate PR given that backend isn't implemented?
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 good overall. Couple of comments
for _, configDetails := range config { | ||
configList = append(configList, configDetails.AdditionalProperties) | ||
} |
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.
Should check if AdditionalProperties
is non-empty/non-nil?
for _, configDetails := range config { | |
configList = append(configList, configDetails.AdditionalProperties) | |
} | |
for _, configDetails := range config { | |
if configDetails.AdditionalProperties != nil && len(configDetails.AdditionalProperties) > 0 { | |
configList = append(configList, configDetails.AdditionalProperties) | |
} | |
} |
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.
@kachawla this is allowed here to accomodate 'default provider configuration' where no details are input. Tests are added for this case both in types_test.go and here: https://github.com/radius-project/radius/pull/7189/files#diff-c5c89506f1ba2fe9bd8ecf4eedc856e93714c251c295c32a15d875f5924df3bdR515-R530
a example resulting main.tf.json is here: pkg/recipes/terraform/config/testdata/providers-envrecipedefaultconfig.tf.json
I did a manual test to see provider configuration load successfully.
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.
Sounds good, thank you. During manual testing, in addition to checking that the config was loaded successfully, could you also confirm that terraform apply runs successfully for this scenario?
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.
Also, can you please expand on "default provider configuration"? I'm not sure what we mean by this. Feel free to point me to the right section in the design if it is captured in the doc already.
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.
yes, confirming, terraform apply runs successfully for this scenario.
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.
Why do we want to populate empty config though?
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.
There is no concept of default empty configuration afaik, let's add this nil check unless there is a terraform documentation that mentions otherwise.
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.
added nil check.
per documentation , https://developer.hashicorp.com/terraform/language/providers/configuration#default-provider-configurations
default configuration is a block without alias argument. and if we provide all configurations with an alias, it picks the "implied empty configuration" as the default configuration.
The null input does not seem to be documented but seems to be handled by terraform without throwing errors.
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.
From the doc - "Terraform assumes an empty default configuration for any provider that is not explicitly configured." - this is already handled by Terraform. By adding empty configuration here, we are overriding any non-empty config that a user might have in their module. Unless there is a strong use case for passing empty config, I wouldn't recommend doing this.
ea95250
to
3365e5c
Compare
20cdcb1
to
30a4a2e
Compare
Radius functional test overview
Click here to see the list of tools in the current test run
Test Status⌛ Building Radius and pushing container images for functional tests... |
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.
Asked a question but other than that LGTM
pkg/recipes/terraform/config/testdata/providers-envrecipedefaultconfig.tf.json
Outdated
Show resolved
Hide resolved
for _, configDetails := range config { | ||
configList = append(configList, configDetails.AdditionalProperties) | ||
} |
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.
There is no concept of default empty configuration afaik, let's add this nil check unless there is a terraform documentation that mentions otherwise.
Radius functional test overview
Click here to see the list of tools in the current test run
Test Status⌛ Building Radius and pushing container images for functional tests... |
20e5a9d
to
ed988b7
Compare
Radius functional test overview
Click here to see the list of tools in the current test run
Test Status⌛ Building Radius and pushing container images for functional tests... |
…port (radius-project#7189) # Description Adding logic to build configuration for multiple Terraform provider support. This is constructed from a combination of environment level recipe configuration located under RecipeConfig/Terraform/Providers section and the provider configurations registered with UCP. The environment level recipe configuration for providers takes precedence over UCP provider configurations. [link to PR for design doc](radius-project/design-notes#39) The design document describes a SecretReference type and ability to fetch data from secrets and populate Provider Configuration. This will be implemented in subsequent PRs. ## Type of change - This pull request adds or changes features of Radius and has an approved issue radius-project#6539 Fixes: Part of radius-project#6539
Description
Adding logic to build configuration for multiple Terraform provider support. This is constructed from a combination of environment level recipe configuration located under RecipeConfig/Terraform/Providers section and the provider configurations registered with UCP. The environment level recipe configuration for providers takes precedence over UCP provider configurations.
link to PR for design doc
The design document describes a SecretReference type and ability to fetch data from secrets and populate Provider Configuration. This will be implemented in subsequent PRs.
Type of change
Fixes: Part of #6539