Skip to content

Commit

Permalink
Merge pull request #530 from imjaroiswebdev/issue-526-v2-5-1-plugin-c…
Browse files Browse the repository at this point in the history
…rashing

add input validation and drift detection during deletion for `service_dependency`
  • Loading branch information
Scott McAllister authored Jul 11, 2022
2 parents e052263 + b649442 commit 447d228
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
16 changes: 16 additions & 0 deletions pagerduty/resource_pagerduty_service_dependency.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ func resourcePagerDutyServiceDependency() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validateValueFunc([]string{
"business_service",
"service",
}),
},
},
},
Expand All @@ -60,6 +64,12 @@ func resourcePagerDutyServiceDependency() *schema.Resource {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validateValueFunc([]string{
"business_service",
"business_service_reference",
"service",
"technical_service_reference",
}),
},
},
},
Expand Down Expand Up @@ -189,6 +199,12 @@ func resourcePagerDutyServiceDependencyDisassociate(d *schema.ResourceData, meta
time.Sleep(5 * time.Second)
return retryErr
}
// If the dependency is not found, then chances are it had been deleted
// outside Terraform or be part of a stale state. So it's needed to be cleared
// from the state.
if foundDep == nil {
return nil
}

// convertType is needed because the PagerDuty API returns the 'reference' values in responses but wants the other
// values in requests
Expand Down
9 changes: 7 additions & 2 deletions website/docs/r/service_dependency.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,13 @@ resource "pagerduty_service_dependency" "bar" {
The following arguments are supported:

* `dependency` - (Required) The relationship between the `supporting_service` and `dependent_service`. One and only one dependency block must be defined.
* `supporting_service` - (Required) The service that supports the dependent service.
* `dependent_service` - (Required) The service that dependents on the supporting service.
* `supporting_service` - (Required) The service that supports the dependent service. Dependency supporting service documented below.
* `dependent_service` - (Required) The service that dependents on the supporting service. Dependency dependent service documented below.

Dependency supporting and dependent service supports the following:

* `id` - (Required) The ID of the service dependency.
* `type` - (Required) Can be `business_service`, `service`, `business_service_reference` or `technical_service_reference`.

## Attributes Reference

Expand Down

0 comments on commit 447d228

Please sign in to comment.