Skip to content

Commit

Permalink
Merge branch 'PagerDuty:master' into insecure-tls
Browse files Browse the repository at this point in the history
  • Loading branch information
dazoakley authored Jun 13, 2024
2 parents 6a36a3c + 20015d0 commit 1402750
Show file tree
Hide file tree
Showing 6 changed files with 145 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: release --rm-dist
args: release --clean
env:
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ release:
name: "terraform-provider-pagerduty"
draft: true
changelog:
skip: true
disable: true
24 changes: 24 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
## 3.13.1 (June 12, 2024)

FEATURES:

* `resource/pagerduty_user_handoff_notification_rule`: Add support for user handoff notification rules ([#875](https://github.com/PagerDuty/terraform-provider-pagerduty/pull/875))

BUG FIXES:

* `resource/pagerduty_extension`: Allow resource extension's endpoint_url to be imported as null ([#880](https://github.com/PagerDuty/terraform-provider-pagerduty/pull/880))

IMPROVEMENTS:

* `PagerDuty/pagerduty`: migrate goreleaser deprecated config attributes ([#882](https://github.com/PagerDuty/terraform-provider-pagerduty/pull/882))

## 3.13.0 (June 12, 2024) - Not released because of failed release process

FEATURES:

* `resource/pagerduty_user_handoff_notification_rule`: Add support for user handoff notification rules ([#875](https://github.com/PagerDuty/terraform-provider-pagerduty/pull/875))

BUG FIXES:

* `resource/pagerduty_extension`: Allow resource extension's endpoint_url to be imported as null ([#880](https://github.com/PagerDuty/terraform-provider-pagerduty/pull/880))

## 3.12.2 (May 20, 2024)

IMPROVEMENTS:
Expand Down
26 changes: 26 additions & 0 deletions pagerdutyplugin/import_pagerduty_extension_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,29 @@ func TestAccPagerDutyExtension_import(t *testing.T) {
},
})
}

func TestAccPagerDutyExtension_import_WithoutEndpointURL(t *testing.T) {
extension_name := fmt.Sprintf("tf-%s", acctest.RandString(5))
name := fmt.Sprintf("tf-%s", acctest.RandString(5))
url := "https://example.com/receive_a_pagerduty_webhook"

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
ProtoV5ProviderFactories: testAccProtoV5ProviderFactories(),
CheckDestroy: testAccCheckPagerDutyExtensionDestroy,
Steps: []resource.TestStep{
{
Config: testAccCheckPagerDutyExtensionConfig(name, extension_name, url, "false", "any"),
},
{
Config: testAccCheckPagerDutyExtensionConfig_NoEndpointURL(name, extension_name, "false", "any"),
},
{
ResourceName: "pagerduty_extension.foo",
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{"config"},
},
},
})
}
37 changes: 31 additions & 6 deletions pagerdutyplugin/resource_pagerduty_extension.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,36 @@ func (r *resourceExtension) Metadata(_ context.Context, _ resource.MetadataReque
func (r *resourceExtension) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) {
resp.Schema = schema.Schema{
Attributes: map[string]schema.Attribute{
"name": schema.StringAttribute{Optional: true, Computed: true},
"id": schema.StringAttribute{Computed: true},
"html_url": schema.StringAttribute{Computed: true},
"type": schema.StringAttribute{Optional: true, Computed: true},
"endpoint_url": schema.StringAttribute{Optional: true, Sensitive: true},
"summary": schema.StringAttribute{Computed: true},
"name": schema.StringAttribute{Optional: true, Computed: true},
"id": schema.StringAttribute{
Computed: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},
},
"html_url": schema.StringAttribute{
Computed: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},
},
"type": schema.StringAttribute{
Optional: true, Computed: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},
},
"endpoint_url": schema.StringAttribute{
Optional: true,
Computed: true,
Sensitive: true,
},
"summary": schema.StringAttribute{
Computed: true,
PlanModifiers: []planmodifier.String{
stringplanmodifier.UseStateForUnknown(),
},
},
"extension_objects": schema.SetAttribute{
Required: true,
ElementType: types.StringType,
Expand Down Expand Up @@ -317,6 +341,7 @@ func flattenExtension(response *pagerduty.Extension, accessToken *string, diags
ID: types.StringValue(response.ID),
Name: types.StringValue(response.Name),
HTMLURL: types.StringValue(response.HTMLURL),
Type: types.StringValue(response.Type),
Summary: types.StringValue(response.Summary),
EndpointURL: types.StringValue(response.EndpointURL),
Config: flattenExtensionConfig(response.Config, accessToken, diags),
Expand Down
62 changes: 62 additions & 0 deletions pagerdutyplugin/resource_pagerduty_extension_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,65 @@ EOF
`, name, extension_name, url, restrict, notify_types)
}

func testAccCheckPagerDutyExtensionConfig_NoEndpointURL(name, extension_name, notify_types, restrict string) string {
return fmt.Sprintf(`
resource "pagerduty_user" "foo" {
name = "%[1]v"
email = "%[1]v@foo.test"
color = "green"
role = "user"
job_title = "foo"
description = "foo"
}
resource "pagerduty_escalation_policy" "foo" {
name = "%[1]v"
description = "bar"
num_loops = 2
rule {
escalation_delay_in_minutes = 10
target {
type = "user_reference"
id = pagerduty_user.foo.id
}
}
}
resource "pagerduty_service" "foo" {
name = "%[1]v"
description = "foo"
auto_resolve_timeout = 1800
acknowledgement_timeout = 1800
escalation_policy = pagerduty_escalation_policy.foo.id
incident_urgency_rule {
type = "constant"
urgency = "high"
}
}
data "pagerduty_extension_schema" "foo" {
name = "Generic V2 Webhook"
}
resource "pagerduty_extension" "foo"{
name = "%s"
endpoint_url = null # sensitive
extension_schema = data.pagerduty_extension_schema.foo.id
extension_objects = [pagerduty_service.foo.id]
config = <<EOF
{
"restrict": "%v",
"notify_types": {
"resolve": %[4]v,
"acknowledge": %[4]v,
"assignments": %[4]v
}
}
EOF
}
`, name, extension_name, restrict, notify_types)
}

0 comments on commit 1402750

Please sign in to comment.