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

feat: add templates.mobile_app to OnCall Integration resource #1814

Merged
merged 5 commits into from
Sep 25, 2024

Conversation

joeyorlando
Copy link
Contributor

@joeyorlando joeyorlando commented Sep 24, 2024

Closes #1665

Local Testing

Create

terraform {
  required_providers {
    grafana = {
      source  = "grafana/grafana"
      version = "1.0.0"
    }
  }
}

provider "grafana" {
  alias               = "oncall"
  oncall_access_token = "<redacted>"
  oncall_url          = "http://localhost:8080"
}

resource "grafana_oncall_integration" "my-integration" {
  provider = grafana.oncall
  name     = "my integration"
  type     = "grafana"
  default_route {}

  templates {
    mobile_app {
        title = "foo bar baz"
        message = "hello world"
    }
  }
}
❯ terraform apply -auto-approve

...

grafana_oncall_integration.test-acc-integration: Refreshing state... [id=CHR8DFBTWLT1I]
grafana_oncall_integration.test-acc-integration2: Refreshing state... [id=CJB1TH28FTW46]

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:

  # grafana_oncall_integration.my-integration will be created
  + resource "grafana_oncall_integration" "my-integration" {
      + id   = (known after apply)
      + link = (known after apply)
      + name = "my integration"
      + type = "grafana"

      + default_route {
          + id = (known after apply)
        }

      + templates {
          + mobile_app {
              + message = "hello world"
              + title   = "foo bar baz"
            }
        }
    }

Plan: 1 to add, 0 to change, 0 to destroy.
grafana_oncall_integration.my-integration: Creating...
grafana_oncall_integration.my-integration: Creation complete after 1s [id=CBZVSQLZYCMVI]

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

Screenshot 2024-09-24 at 11 02 24 AM

Update

resource "grafana_oncall_integration" "my-integration" {
  provider = grafana.oncall
  name     = "my integration"
  type     = "grafana"
  default_route {}

  templates {
    mobile_app {
        title = "foo bar baz1"
        message = "hello world2"
    }
  }
}
❯ terraform apply -auto-approve

...

grafana_oncall_integration.my-integration: Refreshing state... [id=CBZVSQLZYCMVI]

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:

  # grafana_oncall_integration.my-integration will be updated in-place
  ~ resource "grafana_oncall_integration" "my-integration" {
        id   = "CBZVSQLZYCMVI"
        name = "my integration"
        # (2 unchanged attributes hidden)

      ~ templates {
          ~ mobile_app {
              ~ message = "hello world" -> "hello world2"
              ~ title   = "foo bar baz" -> "foo bar baz1"
            }
        }

        # (1 unchanged block hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.
grafana_oncall_integration.my-integration: Modifying... [id=CBZVSQLZYCMVI]
grafana_oncall_integration.my-integration: Modifications complete after 1s [id=CBZVSQLZYCMVI]

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

Screenshot 2024-09-24 at 11 03 38 AM

Update (remove template)

resource "grafana_oncall_integration" "my-integration" {
  provider = grafana.oncall
  name     = "my integration"
  type     = "grafana"
  default_route {}

  templates {
    # mobile_app {
    #     title = "foo bar baz1"
    #     message = "hello world2"
    # }
  }
}
❯ terraform apply -auto-approve

...

grafana_oncall_integration.my-integration: Refreshing state... [id=CBZVSQLZYCMVI]

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:

  # grafana_oncall_integration.my-integration will be updated in-place
  ~ resource "grafana_oncall_integration" "my-integration" {
        id   = "CBZVSQLZYCMVI"
        name = "my integration"
        # (2 unchanged attributes hidden)

      ~ templates {
          - mobile_app {
              - message = "hello world2" -> null
              - title   = "foo bar baz1" -> null
            }
        }

        # (1 unchanged block hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.
grafana_oncall_integration.my-integration: Modifying... [id=CBZVSQLZYCMVI]
grafana_oncall_integration.my-integration: Modifications complete after 0s [id=CBZVSQLZYCMVI]

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

Screenshot 2024-09-24 at 11 05 19 AM

@joeyorlando joeyorlando requested review from a team as code owners September 24, 2024 14:15
Copy link

In order to lower resource usage and have a faster runtime, PRs will not run Cloud tests automatically.
To do so, a Grafana Labs employee must trigger the cloud acceptance tests workflow manually.

@Duologic
Copy link
Member

The failing acceptance test is unrelated to this PR, I'd say we merge it.

=== NAME  TestAccSLO_recreate
    resource_slo_test.go:147: Step 2/3 error: Expected a non-empty plan, but got an empty plan
2024/09/24 16:42:14 [DEBUG] GET ***api/plugins/grafana-slo-app/resources/v1/slo
2024/09/24 16:42:14 [DEBUG] DELETE ***api/plugins/grafana-slo-app/resources/v1/slo/cujb254umedpubmd9e7yj
2024/09/24 16:42:14 [DEBUG] GET ***api/plugins/grafana-slo-app/resources/v1/slo/b680qkp4buhdrw540dhn3
2024/09/24 16:42:15 [DEBUG] GET ***api/plugins/grafana-slo-app/resources/v1/slo/cujb254umedpubmd9e7yj
2024/09/24 16:42:15 [DEBUG] GET ***api/plugins/grafana-slo-app/resources/v1/slo
2024/09/24 16:42:15 [DEBUG] GET ***api/plugins/grafana-slo-app/resources/v1/slo/5d7fsr69d63k6au5fqh67
--- FAIL: TestAccSLO_recreate (12.28s)

@Duologic Duologic merged commit 273994b into main Sep 25, 2024
25 of 26 checks passed
@Duologic Duologic deleted the jorlando/add-mobile-app-oncall-integration-templates branch September 25, 2024 07:23
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.

[Feature Request]: Provide the ability to configure push notifications in Grafana OnCall
2 participants