OpsLevel / terraform-provider-opslevel

Terraform provider for OpsLevel.com
https://registry.terraform.io/providers/OpsLevel/opslevel/latest/docs
MIT License
8 stars 5 forks source link

add categories field to scorecard resource #398

Closed davidbloss closed 3 weeks ago

davidbloss commented 3 weeks ago

Issues

Add category ids to scorecard resource

Changelog

Add computed (returned from API) categories field to scorecards. This contains a list of the scorecard's category ids. Today there is always only one id but this leaves room for multiple category ids.

Tophatting

With this Terraform config

resource "opslevel_scorecard" "test" {
  affects_overall_service_levels = true
  name                           = "scorecard with a category"
  owner_id                       = "Z2lkOi8vb3BzbGV2ZWwvVGVhbS8xNzQzNA"
}

output "scorecard_categories" {
  value = opslevel_scorecard.test.categories
}

Create an opslevel_scorecard and output the list of its categories, 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:

  # opslevel_scorecard.test will be created
  + resource "opslevel_scorecard" "test" {
      + affects_overall_service_levels = true
      + aliases                        = (known after apply)
      + categories                     = (known after apply)
      + id                             = (known after apply)
      + name                           = "scorecard with a category"
      + owner_id                       = "Z2lkOi8vb3BzbGV2ZWwvVGVhbS8xNzQzNA"
      + passing_checks                 = (known after apply)
      + service_count                  = (known after apply)
      + total_checks                   = (known after apply)
    }

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

Changes to Outputs:
  + scorecard_categories = (known after apply)
opslevel_scorecard.test: Creating...
opslevel_scorecard.test: Creation complete after 1s [id=Z2lkOi8vb3BzbGV2ZWwvUnVicmljLzE1MDE]

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

Outputs:

scorecard_categories = tolist([
  "Z2lkOi8vb3BzbGV2ZWwvQ2F0ZWdvcnkvODY5OA",
])

Delete the opslevel_scorecard, terraform destroy

opslevel_scorecard.test: Refreshing state... [id=Z2lkOi8vb3BzbGV2ZWwvUnVicmljLzE1MDE]

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

Terraform will perform the following actions:

  # opslevel_scorecard.test will be destroyed
  - resource "opslevel_scorecard" "test" {
      - affects_overall_service_levels = true -> null
      - aliases                        = [
          - "scorecard_with_a_category",
        ] -> null
      - categories                     = [
          - "Z2lkOi8vb3BzbGV2ZWwvQ2F0ZWdvcnkvODY5OA",
        ] -> null
      - id                             = "Z2lkOi8vb3BzbGV2ZWwvUnVicmljLzE1MDE" -> null
      - name                           = "scorecard with a category" -> null
      - owner_id                       = "Z2lkOi8vb3BzbGV2ZWwvVGVhbS8xNzQzNA" -> null
      - passing_checks                 = 0 -> null
      - service_count                  = 5 -> null
      - total_checks                   = 0 -> null
    }

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

Changes to Outputs:
  - scorecard_categories = [
      - "Z2lkOi8vb3BzbGV2ZWwvQ2F0ZWdvcnkvODY5OA",
    ] -> null
opslevel_scorecard.test: Destroying... [id=Z2lkOi8vb3BzbGV2ZWwvUnVicmljLzE1MDE]
opslevel_scorecard.test: Destruction complete after 1s

Destroy complete! Resources: 1 destroyed.