-
Notifications
You must be signed in to change notification settings - Fork 393
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
[datadog_app_builder_app_json] APPS-2248 & APPS-2144 App Builder Terraform Provider #2723
base: master
Are you sure you want to change the base?
Conversation
c37ed5c
to
8006937
Compare
0e763b7
to
422a9c9
Compare
This stack of pull requests is managed by Graphite. Learn more about stacking. |
e7878b0
to
25dde39
Compare
ce431ec
to
19f3d2b
Compare
07cf33b
to
02d8ac5
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.
great work!
@@ -409,6 +411,16 @@ func defaultConfigureFunc(p *FrameworkProvider, request *provider.ConfigureReque | |||
ddClientConfig.SetUnstableOperationEnabled("v2.DeleteAWSAccount", true) | |||
ddClientConfig.SetUnstableOperationEnabled("v2.GetAWSAccount", true) | |||
|
|||
// Enable unstable operations for the App Builder API |
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.
before public release let's make sure the endpoints are on v2
resp, httpResp, err := r.Api.CreateApp(r.Auth, *createRequest) | ||
if err != nil { | ||
if httpResp != nil { | ||
// error body may have useful info for the user |
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.
just an observation from my testing - you should make sure your API doesn't expose any internal errors or they will show up in TF errors as well
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 some suggestions from the Docs and approved the PR.
0391be0
to
6807aa8
Compare
58c3dac
to
96dded8
Compare
} | ||
|
||
func appJSONEqual(s1, s2 string) (bool, error) { | ||
s1, err := normalizeAppBuilderAppJSONString(s1) |
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.
🔵 Code Quality Violation
Avoid modifying function parameters (...read more)
Assigning new values to function parameters exhibits several bad coding practices and should be avoided for several reasons:
- Redefining parameters: The code redefines a parameter within the function body by assigning a new value. This is considered a bad practice because it can lead to confusion and make the code harder to understand. Modifying a function parameter in this manner breaks the expected behavior and can cause unexpected side effects. It is generally best to treat function parameters as read-only values and avoid reassigning them.
- Shadowing variables: The code further exacerbates the issue by using the short variable declaration
:=
to define a new variable within the function body. This shadows the original parameter, making it inaccessible within the function. Shadowing variables can cause confusion and make the code harder to reason about. It is better to use distinct variable names to maintain clarity and avoid any unintended side effects.
To write more maintainable and understandable code, it is advisable to adhere to the following practices:
- Avoid redefining function parameters.
- Use descriptive and unambiguous variable names.
- Avoid shadowing variables.
- Maintain consistency in variable references.
By following these best practices, the code becomes more readable and easier to manage and avoids introducing unnecessary complexity and confusion.
Motivation
app_json
inputaction_query_ids_to_connection_ids
mapReferences
Testing
Wait Before Merging
datadog-api-client-go
to latest version to include above changesRELEASING.md
: https://github.com/DataDog/terraform-provider-datadog/blob/master/RELEASING.mdOpen Questions
UPDATE: name will be
datadog_app_builder_app
b/c we decided offline we'll just keep this one resource and add extra TF optional fields if customer feedback suggests it is necessaryRESOLVED: name will bedatadog_app_builder_app_json
Currently, this resource is calleddatadog_app
. The plan is, in the future, updating this resource with extra structs in order to build an app in TF with TF syntax, strongly typing structs likequeries
andcomponents
.Alternatively, what about creating a separate resource? This would help with making the code cleaner and disambiguate the two use cases. For instance, this resource would instead bedatadog_app_json
similar to how dashboards has adatadog_dashboard_json
, and the non-json usage would be calleddatadog_app
, like how dashboards also hasdatadog_dashboard
.