Skip to content

Conversation

wafuwafu13
Copy link
Contributor

@wafuwafu13 wafuwafu13 commented Nov 30, 2022

Output from acceptance testing:

$ make testacc TESTS=TestAccDataSourceMackerelDashboard              
TF_ACC=1 go test -v ./mackerel/... -run TestAccDataSourceMackerelDashboard -timeout 120m
=== RUN   TestAccDataSourceMackerelDashboardGraph
=== PAUSE TestAccDataSourceMackerelDashboardGraph
=== RUN   TestAccDataSourceMackerelDashboardValue
=== PAUSE TestAccDataSourceMackerelDashboardValue
=== RUN   TestAccDataSourceMackerelDashboardMarkdown
=== PAUSE TestAccDataSourceMackerelDashboardMarkdown
=== RUN   TestAccDataSourceMackerelDashboardAlertStatus
=== PAUSE TestAccDataSourceMackerelDashboardAlertStatus
=== CONT  TestAccDataSourceMackerelDashboardGraph
=== CONT  TestAccDataSourceMackerelDashboardMarkdown
=== CONT  TestAccDataSourceMackerelDashboardAlertStatus
=== CONT  TestAccDataSourceMackerelDashboardValue
--- PASS: TestAccDataSourceMackerelDashboardMarkdown (5.20s)
--- PASS: TestAccDataSourceMackerelDashboardGraph (5.48s)
--- PASS: TestAccDataSourceMackerelDashboardAlertStatus (6.57s)
--- PASS: TestAccDataSourceMackerelDashboardValue (6.66s)
PASS
ok      github.com/mackerelio-labs/terraform-provider-mackerel/mackerel 6.989s

$ make testacc TESTS=TestAccMackerelDashboard           
TF_ACC=1 go test -v ./mackerel/... -run TestAccMackerelDashboard -timeout 120m
=== RUN   TestAccMackerelDashboardGraph
=== PAUSE TestAccMackerelDashboardGraph
=== RUN   TestAccMackerelDashboardValue
=== PAUSE TestAccMackerelDashboardValue
=== RUN   TestAccMackerelDashboardMarkdown
=== PAUSE TestAccMackerelDashboardMarkdown
=== RUN   TestAccMackerelDashboardAlertStatus
=== PAUSE TestAccMackerelDashboardAlertStatus
=== CONT  TestAccMackerelDashboardGraph
=== CONT  TestAccMackerelDashboardMarkdown
=== CONT  TestAccMackerelDashboardAlertStatus
=== CONT  TestAccMackerelDashboardValue
--- PASS: TestAccMackerelDashboardMarkdown (8.60s)
--- PASS: TestAccMackerelDashboardAlertStatus (10.37s)
--- PASS: TestAccMackerelDashboardValue (10.55s)
--- PASS: TestAccMackerelDashboardGraph (10.67s)
PASS
ok      github.com/mackerelio-labs/terraform-provider-mackerel/mackerel   11.008s

log:

~/Desktop/terraform-provider-mackerel
$ make local-install
go build -o terraform-provider-mackerel
mkdir -p ~/.terraform.d/plugins/registry.terraform.io/mackerelio-labs/mackerel/99.9.9/darwin_amd64
mv terraform-provider-mackerel ~/.terraform.d/plugins/registry.terraform.io/mackerelio-labs/mackerel/99.9.9/darwin_amd64
terraform {
  required_providers {
    mackerel = {
      source  = "mackerelio-labs/mackerel"
      version = "99.9.9"
    }
  }
}

resource "mackerel_dashboard" "foo" {
  title = "from terrafrom"
  memo = "This dashboard is managed by Terraform."
  url_path = "foobar"
  graph {
		title = "test graph role"
		role {
			role_fullname = "hatena-mac:hatena-mac"
			name = "loadavg5"
			is_stacked = true
		}
		range {
			relative {
				period = 3600
				offset = 1800
			}
		}
		layout {
			x = 0
			y = 0
			width = 10
			height = 8
		}
	}
  value {
    title = "test value expression"
    metric {
			expression {
				expression = "role(hatena-mac:hatena-mac, loadavg5)"
			}
		}
		fraction_size = 5
		suffix = "test suffix"
    layout {
			x = 12
			y = 0
			width = 7
			height = 5
		}
  }
  markdown {
    title = "test markdown"
    markdown = "# h1"
    layout {
			x = 0
			y = 10
			width = 3
			height = 4
		}
  }
  alert_status {
    title = "test alertStatus"
    role_fullname = "hatena-mac:hatena-mac"
    layout {
			x = 7
			y = 10
			width = 3
			height = 4
		}
  }
}
$ terraform init
$ terraform apply

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # mackerel_dashboard.foo will be created
  + resource "mackerel_dashboard" "foo" {
      + id       = (known after apply)
      + memo     = "This dashboard is managed by Terraform."
      + title    = "from terrafrom"
      + url_path = "foobar"

      + alert_status {
          + role_fullname = "hatena-mac:hatena-mac"
          + title         = "test alertStatus"

          + layout {
              + height = 4
              + width  = 3
              + x      = 7
              + y      = 10
            }
        }

      + graph {
          + title = "test graph role"

          + layout {
              + height = 8
              + width  = 10
              + x      = 0
              + y      = 0
            }

          + range {

              + relative {
                  + offset = 1800
                  + period = 3600
                }
            }

          + role {
              + is_stacked    = true
              + name          = "loadavg5"
              + role_fullname = "hatena-mac:hatena-mac"
            }
        }

      + markdown {
          + markdown = "# h1"
          + title    = "test markdown"

          + layout {
              + height = 4
              + width  = 3
              + x      = 0
              + y      = 10
            }
        }

      + value {
          + fraction_size = 5
          + suffix        = "test suffix"
          + title         = "test value expression"

          + layout {
              + height = 5
              + width  = 7
              + x      = 12
              + y      = 0
            }

          + metric {
              + expression {
                  + expression = "role(hatena-mac:hatena-mac, loadavg5)"
                }
            }
        }
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

mackerel_dashboard.foo: Creating...
mackerel_dashboard.foo: Creation complete after 1s [id=4HGws7s4qpj]

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

スクリーンショット 2022-12-12 12 01 35

$ terraform apply
mackerel_dashboard.foo: Refreshing state... [id=4HGws7s4qpj]

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # mackerel_dashboard.foo will be updated in-place
  ~ resource "mackerel_dashboard" "foo" {
        id       = "4HGws7s4qpj"
        # (3 unchanged attributes hidden)

      ~ markdown {
          ~ markdown = "# h1" -> "# updated!!!!"
            # (1 unchanged attribute hidden)

            # (1 unchanged block hidden)
        }

        # (3 unchanged blocks hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

mackerel_dashboard.foo: Modifying... [id=4HGws7s4qpj]
mackerel_dashboard.foo: Modifications complete after 0s [id=4HGws7s4qpj]

Apply complete! Resources: 0 added, 1 changed, 0 destroyed.

スクリーンショット 2022-12-12 12 03 11

@wafuwafu13 wafuwafu13 marked this pull request as ready for review December 12, 2022 03:10
@Arthur1 Arthur1 self-requested a review December 26, 2022 07:12
Copy link
Member

@Arthur1 Arthur1 left a comment

Choose a reason for hiding this comment

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

Thank you for waiting. I have reviewed this PR, please check it.

Copy link
Member

@Arthur1 Arthur1 left a comment

Choose a reason for hiding this comment

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

Thanks for your correction. The tab indentation is still there.

Copy link
Member

@Arthur1 Arthur1 left a comment

Choose a reason for hiding this comment

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

lgtm

@wafuwafu13 wafuwafu13 merged commit 9dccd4f into mackerelio-labs:main Jan 4, 2023
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.

2 participants