Skip to content
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

azurerm_portal_dashboard - update dashboard name validation #16406

Merged
merged 12 commits into from
May 26, 2022

Conversation

neil-yechenwei
Copy link
Contributor

@neil-yechenwei neil-yechenwei commented Apr 15, 2022

fixes #16376

--- PASS: TestAccPortalDashboard_basic (232.15s)
--- PASS: TestAccPortalDashboard_hiddenTitle (234.44s)
--- PASS: TestAccPortalDashboard_complete (234.69s)
--- PASS: TestAccDataSourcePortalDashboard_complete (194.95s)
--- PASS: TestAccDataSourcePortalDashboard_basic (208.89s)
--- PASS: TestAccDataSourcePortalDashboard_displayName (212.52s)

Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@tombuildsstuff tombuildsstuff added this to the v3.3.0 milestone Apr 19, 2022
Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @neil-yechenwei

Testing this, unfortunately it appears this doesn't work:

Error: creating/updating Dashboard: (Name “hellllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllo” / Resource Group “acctestRG-220419094823499740") portal.DashboardsClient#CreateOrUpdate: Failure responding to request: StatusCode=400 -- Original Error: autorest/azure: error response cannot be parsed: {“{\“error\“:{\“code\“:377,\“message\“:\“The dashboard name ‘hellllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllo’ has length ‘259’ which exceeds the length limit ‘160’.\“}}” ‘\x00’ ‘\x00’} error: json: cannot unmarshal number into Go struct field RequestError.error of type string

The name used here is the ARM name which has a number of limitations, as mentioned in the product documentation it's possible to specify a tag of hidden-title to override this (which doesn't have this 160 character limit).

As such there's three things needed here:

  1. Update the validation logic to support 160 characters
  2. Add an acceptance test to confirm that
  3. Add a display_name filter to azurerm_portal_dashboard to allow users to lookup a dashboard by either name or display_name (making name optional - but having a check in the Read function to ensure that either one of them is set / a dashboard is found)

Would you be able to take a look?

Thanks!

@tombuildsstuff tombuildsstuff removed this from the v3.3.0 milestone Apr 19, 2022
@github-actions github-actions bot added size/M and removed size/XS labels Apr 19, 2022
@neil-yechenwei
Copy link
Contributor Author

neil-yechenwei commented Apr 19, 2022

@tombuildsstuff , for items 1 and 2, I've updated code. For item 3, maybe I can file a new issue to track this new feature request. Does it make sense?

@tombuildsstuff
Copy link
Contributor

@neil-yechenwei 3 should be a part of this PR too, as requested above - else this isn't really solving #16376.

@neil-yechenwei
Copy link
Contributor Author

neil-yechenwei commented Apr 19, 2022

@tombuildsstuff , ok. I will implement it in data source azurerm_portal_dashboard.

@neil-yechenwei
Copy link
Contributor Author

neil-yechenwei commented Apr 20, 2022

@tombuildsstuff , while testing against 3, I think of one thing. The tag value of hidden-title isn't globally unique. So it would be duplicate with others so that we would get multiple dashboards while filtering by the display_name. Hence, maybe we cannot filter the resource by display_name in data source azurerm_portal_dashboard. Does it make sense?

@tombuildsstuff
Copy link
Contributor

@neil-yechenwei in which case we can raise an error that there isn't a single match, like we do in other data sources which allow filtering in this manner

@neil-yechenwei
Copy link
Contributor Author

@tombuildsstuff , thanks for your suggestion. I've updated code. Please take another look. Thanks.

Copy link
Contributor

@tombuildsstuff tombuildsstuff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi @neil-yechenwei

Thanks for pushing those changes, I've taken a look through and left some comments inline - if we can fix those up then we can take another look.

Thanks!

}

id := parse.NewDashboardID(subscriptionId, resourceGroup, name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

both the resourceGroup and the name here will be empty when we're filtering by display name - making this ID invalid?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As resourceGroup is required property, so it won't be empty.

For name, while filtering by display_name, name would be empty. So I updated code to use *dashboard.Name since this property always has value when the resource is retrieved.

@neil-yechenwei
Copy link
Contributor Author

@tombuildsstuff , thanks for your suggestion. I've updated code. Please take another look. Thanks.

@neil-yechenwei
Copy link
Contributor Author

@katbyte , thanks for your comment. I've updated PR. Please take another look. Thanks in advance.

Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @neil-yechenwei - LGTM 🚜

@katbyte katbyte merged commit 0d16bf8 into hashicorp:main May 26, 2022
@github-actions github-actions bot added this to the v3.8.0 milestone May 26, 2022
katbyte added a commit that referenced this pull request May 26, 2022
@github-actions
Copy link

This functionality has been released in v3.8.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active contributions.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

data "azurerm_portal_dashboard" - Error: "name" may not exceed 64 characters in length
3 participants