-
Notifications
You must be signed in to change notification settings - Fork 247
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
feat(Dashboard json): Add parameter for query accounts #2454
base: main
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## main #2454 +/- ##
==========================================
+ Coverage 33.87% 33.92% +0.04%
==========================================
Files 91 91
Lines 24884 24948 +64
==========================================
+ Hits 8429 8463 +34
- Misses 16300 16321 +21
- Partials 155 164 +9
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
Hi @alvaroaleman - thank you for the contribution! Sorry, we've been able to get this after quite some time as the team has lately been occupied with multiple priority items. I have a few things to mention -
a) Great work on the addition of a test case to b) A few lint failures are currently being thrown by the lint test running in the CI. You would find the cause of this shown in the changes tab of this PR. Would you be able to take a look and correct them accordingly? Also, as a tip, running c) It would also be helpful if you can pull the latest changes from Looking forward to your response (and more changes) 😄 thanks! |
This comment was marked as outdated.
This comment was marked as outdated.
@pranav-new-relic Let me try to give a practical example to illustrate the issue:
(I just handwrote this, its probably has some syntax issues but I think it illustrates the problem). Please let me know if this is sufficient. I will look into an acceptance test and linting in the meanwhile. |
Hey @alvaroaleman - this illustration looks great, thanks for sharing! However, we're finding it a bit difficult to understand the exact limitation (when the limit of five accounts is exceeded) via the variables and the template file. Would you mind attaching an example that we would be able to reproduce (the JSON with a few sample widgets, the template file that is written and the variables)? This would help us plan the impact of these changes accordingly too, as the team is planning to check if we've received enhancement requests similar to this in the past. Thank you! |
@pranav-new-relic you can literally use the json file from the testdata and insert the template expressions, I did it for you below (notice
|
e8d7ded
to
2fc97ef
Compare
This unfortunately does not work:
I've added an acceptance test, please let me know what you think. |
2fc97ef
to
4ea505e
Compare
Thanks for your prompt responses and code corrections, @alvaroaleman. The changes look good to me. As a practice, when we take contributions, we make sure we invest time in getting the submission reviewed multi-fold (with more eyes from the team) and testing the change out thoroughly to ensure this does not result in a breaking change. Though most of your code addition is new and wouldn't cause a breaking change :) we'd be extra cautious while pushing changes like these out. Given a few immediate priorities of the team, we shall be able to push this process a bit at a time, and shall be done with this by early/mid-next week. We'd reach out to you further if my colleagues find the need to have anything else in the code to be addressed, but in the meanwhile, would appreciate your patience with this. On that note, thank you for your submission - this is a really wholesome PR with good error handling and tests, as I must have mentioned previously 😄 |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
return fmt.Errorf("dashboard '%s' included original accountID %d", string(serialized), testAccountID) | ||
} | ||
if !bytes.Contains(serialized, []byte(dataAccountID)) { | ||
return fmt.Errorf("dashboard '%s' did not include updated accountID $d", string(serialized), dataAccountID) |
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.
return fmt.Errorf("dashboard '%s' did not include updated accountID $d", string(serialized), dataAccountID) | |
return fmt.Errorf("dashboard '%s' did not include updated accountID %s", string(serialized), dataAccountID) |
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.
Fixed
Hi @alvaroaleman thank you for your contribution! I'm seeing some test failures - |
4ea505e
to
cf8c5a4
Compare
@mbazhlekova where did you see those failures? GitHub showed all checks as success. Is the fix for the incorrect fmt string enough? |
@alvaroaleman I checked out your branch and ran the test suite locally. Unfortunately the repo isn't setup to run integration tests against forks. |
Ah, thanks for doing that. Does it pass now? If not, would you be able to paste the error? |
@alvaroaleman Sure, here are the failures I'm seeing: === FAIL: newrelic TestAccNewRelicOneDashboardJson_CreateWithDataAccounts (7.05s)
=== FAIL: newrelic TestAccNewRelicOneDashboardJson_Create (7.68s)
DONE 2 tests, 2 failures in 8.661s |
Hi @mbazhlekova - thank you for identifying this; sorry, I missed this important catch as I was juggling a couple of things 😅 I also just ran a |
When a dashboard needs to exist for more than the limit of five accounts that can be queried at a time, it has to be duplicated, expect for the `accountIDs`. The only way to do that today with the `newrelic_one_dashboard_json` resource is to template the underlying json. This in turn completely breaks the workflow of "Edit dashboard in UI, export json into terraform", because a post-processing step is needed to insert all the template expressions into the json document. This change aims to fix that by adding a new `data_accounts` parameter into the `newrelic_one_dashboard_json` resource that if set will replace all the `accountIDs` in the json document.
cf8c5a4
to
f2ea80f
Compare
@mbazhlekova thanks for your feedback. I've pushed a new revision which I think fixes the issues you are seeing. Could you please verify? Thank you in advance! |
@alvaroaleman Sure, I just ran the tests again. I'm seeing this failure: === FAIL: newrelic TestAccNewRelicOneDashboardJson_CreateWithDataAccounts (0.82s)
|
Hi @alvaroaleman - I spent quite some time trying to understand why the above error is seen with the acceptance test you've added, and here are my observations - please take a look some time when free 😄 1.
|
if subAccountIDExists := os.Getenv("NEW_RELIC_SUBACCOUNT_ID"); subAccountIDExists == "" { |
I think this could be an optimal method, so we can test it directly on our end too without any changes, with the NEW_RELIC_SUBACCOUNT_ID
we have.
Sounds like a lot of changes - please take your time to read through this - shall be awaiting your changes. Thanks!
Thanks for your feedback! I am out of office this week, will come back to it next. |
23a73db
to
4f7b20e
Compare
When a dashboard needs to exist for more than the limit of five accounts that can be queried at a time, it has to be duplicated, except for the
accountIDs
. The only way to do that today with thenewrelic_one_dashboard_json
resource is to template the underlying json.This in turn completely breaks the workflow of "Edit dashboard in UI, export json into terraform", because a post-processing step is needed to insert all the template expressions into the json document.
This change aims to fix that by adding a new
data_accounts
parameter into thenewrelic_one_dashboard_json
resource that if set will replace all theaccountIDs
in the json document.Type of change
Please delete options that are not relevant.
Checklist:
Please delete options that are not relevant.
How to test this change?
Please describe how to test your changes. Include any relevant steps in the UI, HCL file(s), commands, etc
newrelic_one_dashboard_json
resource with thedata_accounts
parameter set to create a dashboardaccountIDs
are what what indata_accounts
, regardless of what the original JSON contained