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

added support for DisplaySectionTableOfContents for dashboards #43

Merged
merged 1 commit into from
May 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ
github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ=
github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q=
github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
Expand All @@ -33,6 +34,7 @@ github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/hashicorp/hil v0.0.0-20170627220502-fa9f258a9250 h1:fooK5IvDL/KIsi4LxF/JH68nVdrBSiGNPhS2JAQjtjo=
github.com/hashicorp/hil v0.0.0-20170627220502-fa9f258a9250/go.mod h1:KHvg/R2/dPtaePb16oW4qIyzkMxXOL38xjRN64adsts=
github.com/hashicorp/logutils v1.0.0 h1:dLEQVugN8vlakKOUE3ihGLTZJRB4j+M2cdTm/ORI65Y=
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
github.com/hashicorp/terraform v0.0.0-20170808153846-8b3b678c2fd9 h1:RBqAZm6NV1s0ZqGMJJ9rn5CTO7N4syDZgNuPRb4f2J8=
github.com/hashicorp/terraform v0.0.0-20170808153846-8b3b678c2fd9/go.mod h1:uN1KUiT7Wdg61fPwsGXQwK3c8PmpIVZrt5Vcb1VrSoM=
Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.3.1
v1.3.2
2 changes: 1 addition & 1 deletion wavefront/import_dashboard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ resource "wavefront_dashboard" "foobar" {
name = "Terraform Test Dashboard"
description = "a"
url = "tftestimport"

display_section_table_of_contents = true
section {
name = "section 1"

Expand Down
28 changes: 20 additions & 8 deletions wavefront/resource_dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,10 @@ func resourceDashboard() *schema.Resource {
},
"section": section,
"parameter_details": parameterDetail,
"display_section_table_of_contents": {
Type: schema.TypeBool,
Optional: true,
},
"event_filter_type": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -964,15 +968,21 @@ func buildDashboard(d *schema.ResourceData) (*wavefront.Dashboard, error) {
eventFilterType = e.(string)
}

displayTOC := false
if toc, ok := d.GetOk("display_section_table_of_contents"); ok {
displayTOC = toc.(bool)
}

return &wavefront.Dashboard{
Name: d.Get("name").(string),
ID: d.Get("url").(string),
Tags: tags,
Description: d.Get("description").(string),
Url: d.Get("url").(string),
Sections: *buildSections(&terraformSections),
ParameterDetails: *buildParameterDetails(&terraformParams),
EventFilterType: eventFilterType,
Name: d.Get("name").(string),
ID: d.Get("url").(string),
Tags: tags,
Description: d.Get("description").(string),
Url: d.Get("url").(string),
Sections: *buildSections(&terraformSections),
ParameterDetails: *buildParameterDetails(&terraformParams),
EventFilterType: eventFilterType,
DisplaySectionTableOfContents: displayTOC,
}, nil
}

Expand Down Expand Up @@ -1025,6 +1035,8 @@ func resourceDashboardRead(d *schema.ResourceData, m interface{}) error {
d.Set("description", dash.Description)
d.Set("url", dash.Url)

d.Set("display_section_table_of_contents", dash.DisplaySectionTableOfContents)

sections := []map[string]interface{}{}
for _, wavefrontSection := range dash.Sections {
sections = append(sections, buildTerraformSection(wavefrontSection))
Expand Down
11 changes: 10 additions & 1 deletion wavefront/resource_dashboard_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,8 @@ func TestAccWavefrontDashboard_Basic(t *testing.T) {
testAccCheckWavefrontDashboardExists("wavefront_dashboard.test_dashboard", &record),
testAccCheckWavefrontDashboardAttributes(&record),

resource.TestCheckResourceAttr(
"wavefront_dashboard.test_dashboard", "display_section_table_of_contents", "true"),
// Check against state that the attributes are as we expect
resource.TestCheckResourceAttr(
"wavefront_dashboard.test_dashboard", "name", "Terraform Test Dashboard"),
Expand Down Expand Up @@ -378,6 +380,8 @@ func TestAccWavefrontDashboard_Updated(t *testing.T) {
testAccCheckWavefrontDashboardAttributes(&record),
resource.TestCheckResourceAttr(
"wavefront_dashboard.test_dashboard", "name", "Terraform Test Dashboard"),
resource.TestCheckResourceAttr(
"wavefront_dashboard.test_dashboard", "display_section_table_of_contents", "true"),
),
},
{
Expand All @@ -387,6 +391,8 @@ func TestAccWavefrontDashboard_Updated(t *testing.T) {
testAccCheckWavefrontDashboardAttributesUpdated(&record),
resource.TestCheckResourceAttr(
"wavefront_dashboard.test_dashboard", "name", "Terraform Test Dashboard Updated"),
resource.TestCheckResourceAttr(
"wavefront_dashboard.test_dashboard", "display_section_table_of_contents", "false"),
),
},
},
Expand Down Expand Up @@ -979,7 +985,9 @@ resource "wavefront_dashboard" "test_dashboard" {
name = "Terraform Test Dashboard"
description = "testing, testing"
url = "tftestcreate"
section {
display_section_table_of_contents = true

section{
name = "section 1"
row {
chart {
Expand Down Expand Up @@ -1023,6 +1031,7 @@ resource "wavefront_dashboard" "test_dashboard" {
name = "Terraform Test Dashboard Updated"
description = "testing, testing"
url = "tftestcreate"
display_section_table_of_contents = false
section {
name = "section 1"
row {
Expand Down