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

Handle filter_current_dashboard on update #1662

Merged
merged 15 commits into from
Mar 15, 2022

Conversation

mbazhlekova
Copy link
Contributor

@mbazhlekova mbazhlekova commented Feb 18, 2022

Description

This PR handles filter_current_dashboard properly on dashboard update. Before it was only handled on dashboard create.

Fixes #1494

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My commit message follows conventional commits
  • My code is formatted to Go standards
  • I have performed a self-review of my own code
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes. Go here for instructions on running tests locally.

How to test this change?

Please describe how to test your changes. Include any relevant steps in the UI, HCL file(s), commands, etc

  1. Create a dashboard resource with the following HCL file
resource "newrelic_one_dashboard" "default" {
  name        = "Ticket 1494"
  description = "Managed via Terraform"

  page {
    name        = "Simple Page"
    description = "Simple Page"

    # Pie charts
    widget_pie {
      title                    = "Filter Example"
      row                      = 1
      column                   = 1
      width                    = 5
      height                   = 5
      linked_entity_guids      = null
      filter_current_dashboard = true
      nrql_query {
        query = "FROM K8sClusterSample select uniqueCount(hostname) FACET clusterName limit max since 5 minutes ago"
      }
    }

    widget_pie {
      title                    = "Target Example"
      row                      = 1
      column                   = 6
      width                    = 7
      height                   = 5
      linked_entity_guids      = null
      filter_current_dashboard = false
      nrql_query {
        query = "FROM K8sClusterSample select uniqueCount(hostname) FACET instanceType limit max since 5 minutes ago"
      }
    }
  }
}
  1. Run terraform plan and terraform apply
  2. Navigate to created dashboard in New Relic
  3. Go to edit the Filter Example widget and verify that Filter the current dashboard is selected
  4. Go back to Terraform and set filter_current_dashboard to false
  5. Run terraform plan and terraform apply again
  6. Go to edit the Filter Example widget and verify that Filter the current dashboard is no longer selected

@mbazhlekova mbazhlekova force-pushed the fix-filter-current-dashboard branch from 1ed5d57 to 119aa55 Compare March 4, 2022 23:16
@mbazhlekova mbazhlekova force-pushed the fix-filter-current-dashboard branch from 119aa55 to 566eff7 Compare March 4, 2022 23:18
@mbazhlekova mbazhlekova changed the title WIP handle filter_current_dashboard on read Handle filter_current_dashboard on update Mar 4, 2022
@mbazhlekova mbazhlekova marked this pull request as ready for review March 7, 2022 17:21
@ChandraIragavarapu
Copy link
Contributor

ChandraIragavarapu commented Mar 15, 2022

looks good.
Discussed with the team and few improvement points to be consider in future:

  1. Use proper index looping counters instead of single char like i,j...
  2. Use functions when we have complex logic. For example in file 'structures_newrelic_one_dashboard.go' around line 904

@mbazhlekova mbazhlekova merged commit e24088a into main Mar 15, 2022
@mbazhlekova mbazhlekova deleted the fix-filter-current-dashboard branch March 15, 2022 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

filter_current_dashboard of newrelic_one_dashboard is not handled properly
2 participants