-
Notifications
You must be signed in to change notification settings - Fork 24
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
chore: add recipients sweeper #516
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
141469a
chore: add recipients sweeper
jharley 7de40c2
always run sweeps
jharley 8965c16
Merge branch 'main' into jharley.test-sweepers
jharley 9745e37
use proper syntax for always
jharley d2a5236
tidy
jharley 7cb0f99
remove unneeded file
jharley File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,6 +84,16 @@ jobs: | |
TF_ACC_TERRAFORM_VERSION: ${{ env.TERRAFORM_VERSION }} | ||
run: go test -v -coverprofile=tf-coverage.txt -covermode=atomic ./internal/... ./honeycombio/... | ||
|
||
- name: Cleanup Dangling Resources | ||
if: ${{ always() }} | ||
timeout-minutes: 5 | ||
env: | ||
HONEYCOMB_API_KEY: ${{ secrets.HONEYCOMB_API_KEY }} | ||
HONEYCOMB_KEY_ID: ${{ secrets.HONEYCOMB_KEY_ID }} | ||
HONEYCOMB_KEY_SECRET: ${{ secrets.HONEYCOMB_KEY_SECRET }} | ||
HONEYCOMB_DATASET: testacc | ||
run: make sweep | ||
|
||
- name: Generate Coverage Report | ||
uses: codecov/[email protected] | ||
with: | ||
|
@@ -142,6 +152,17 @@ jobs: | |
TF_ACC_TERRAFORM_VERSION: ${{ env.TERRAFORM_VERSION }} | ||
run: go test -v -coverprofile=tf-coverage.txt -covermode=atomic ./internal/... ./honeycombio/... | ||
|
||
- name: Cleanup Dangling Resources | ||
if: ${{ always() }} | ||
timeout-minutes: 5 | ||
env: | ||
HONEYCOMB_API_ENDPOINT: https://api.eu1.honeycomb.io | ||
HONEYCOMB_API_KEY: ${{ secrets.HONEYCOMB_API_KEY_EU }} | ||
HONEYCOMB_KEY_ID: ${{ secrets.HONEYCOMB_KEY_ID_EU }} | ||
HONEYCOMB_KEY_SECRET: ${{ secrets.HONEYCOMB_KEY_SECRET_EU }} | ||
HONEYCOMB_DATASET: testacc | ||
run: make sweep | ||
|
||
- name: Generate Coverage Report | ||
uses: codecov/[email protected] | ||
with: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,7 +35,7 @@ linters: | |
- unconvert | ||
- unparam | ||
- unused | ||
- vet | ||
- govet | ||
|
||
run: | ||
# Prevent false positive timeouts in CI | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,17 @@ | ||
.PHONY: build testacc lint sweep | ||
default: testacc | ||
|
||
build: | ||
go build -o terraform-provider-honeycombio | ||
|
||
testacc: | ||
TF_ACC=1 go test -v ./... | ||
|
||
fmt: | ||
goimports -l -w . | ||
go mod tidy | ||
terraform fmt --recursive | ||
|
||
# Terraform 0.13+ only: build the repository and install the provider in one of | ||
# the local mirror directories following the new fileystem layout. Additionally, | ||
# we have to specify a version. | ||
# | ||
# https://www.terraform.io/docs/commands/cli-config.html#implied-local-mirror-directories | ||
# https://www.terraform.io/upgrade-guides/0-13.html#new-filesystem-layout-for-local-copies-of-providers | ||
|
||
version = 99.0.0 | ||
os_arch = $(shell go env GOOS)_$(shell go env GOARCH) | ||
provider_path = registry.terraform.io/honeycombio/honeycombio/$(version)/$(os_arch)/ | ||
|
||
install_macos: | ||
go build -o terraform-provider-honeycombio_$(version) | ||
|
||
mkdir -p ~/Library/Application\ Support/io.terraform/plugins/$(provider_path) | ||
cp terraform-provider-honeycombio_$(version) ~/Library/Application\ Support/io.terraform/plugins/$(provider_path) | ||
lint: | ||
golangci-lint run | ||
|
||
uninstall_macos: | ||
rm -r ~/Library/Application\ Support/io.terraform/plugins/registry.terraform.io/honeycombio | ||
sweep: | ||
# the sweep flag requires a string to be passed, but it is not used | ||
@echo "WARNING: This will destroy resources. Use only in development teams." | ||
go test ./internal/provider -v -timeout 5m -sweep=env | ||
|
||
.PHONY: build testacc install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,7 +26,7 @@ func TestRecipientsEmail(t *testing.T) { | |
data := &client.Recipient{ | ||
Type: client.RecipientTypeEmail, | ||
Details: client.RecipientDetails{ | ||
EmailAddress: test.RandomString(8) + "@example.com", | ||
EmailAddress: test.RandomEmail(), | ||
}, | ||
} | ||
now := time.Now() | ||
|
@@ -56,7 +56,7 @@ func TestRecipientsEmail(t *testing.T) { | |
}) | ||
|
||
t.Run("Update", func(t *testing.T) { | ||
rcpt.Details.EmailAddress = "[email protected]" | ||
rcpt.Details.EmailAddress = test.RandomEmail() | ||
now := time.Now() | ||
result, err := c.Recipients.Update(ctx, rcpt) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,7 @@ import ( | |
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
|
||
honeycombio "github.com/honeycombio/terraform-provider-honeycombio/client" | ||
"github.com/honeycombio/terraform-provider-honeycombio/internal/helper/test" | ||
) | ||
|
||
func TestAccDataSourceHoneycombioRecipient_basic(t *testing.T) { | ||
|
@@ -21,53 +22,53 @@ func TestAccDataSourceHoneycombioRecipient_basic(t *testing.T) { | |
{ | ||
Type: honeycombio.RecipientTypeEmail, | ||
Details: honeycombio.RecipientDetails{ | ||
EmailAddress: "[email protected]", | ||
EmailAddress: test.RandomEmail(), | ||
}, | ||
}, | ||
{ | ||
Type: honeycombio.RecipientTypeEmail, | ||
Details: honeycombio.RecipientDetails{ | ||
EmailAddress: "[email protected]", | ||
EmailAddress: test.RandomEmail(), | ||
}, | ||
}, | ||
{ | ||
Type: honeycombio.RecipientTypeSlack, | ||
Details: honeycombio.RecipientDetails{ | ||
SlackChannel: "#acctest", | ||
SlackChannel: test.RandomStringWithPrefix("#test.", 12), | ||
}, | ||
}, | ||
{ | ||
Type: honeycombio.RecipientTypeSlack, | ||
Details: honeycombio.RecipientDetails{ | ||
SlackChannel: "#tmp-acctest", | ||
SlackChannel: test.RandomStringWithPrefix("#test.", 12), | ||
}, | ||
}, | ||
{ | ||
Type: honeycombio.RecipientTypePagerDuty, | ||
Details: honeycombio.RecipientDetails{ | ||
PDIntegrationKey: "6f05176bf1c7a1adb6ee516521770ec4", | ||
PDIntegrationName: "My Important Service", | ||
PDIntegrationKey: test.RandomString(32), | ||
PDIntegrationName: test.RandomStringWithPrefix("test.", 20), | ||
}, | ||
}, | ||
{ | ||
Type: honeycombio.RecipientTypePagerDuty, | ||
Details: honeycombio.RecipientDetails{ | ||
PDIntegrationKey: "6f05176bf1b7a1adb6ee516521770ac0", | ||
PDIntegrationName: "My Other Important Service", | ||
PDIntegrationKey: test.RandomString(32), | ||
PDIntegrationName: test.RandomStringWithPrefix("test.", 20), | ||
}, | ||
}, | ||
{ | ||
Type: honeycombio.RecipientTypeWebhook, | ||
Details: honeycombio.RecipientDetails{ | ||
WebhookName: "My Notifications Hook", | ||
WebhookSecret: "s0s3kret!", | ||
WebhookName: test.RandomStringWithPrefix("test.", 16), | ||
WebhookSecret: test.RandomString(20), | ||
WebhookURL: "https://my.webhook.dev.corp.io", | ||
}, | ||
}, | ||
{ | ||
Type: honeycombio.RecipientTypeMSTeams, | ||
Details: honeycombio.RecipientDetails{ | ||
WebhookName: "My Teams Channel", | ||
WebhookName: test.RandomStringWithPrefix("test.", 16), | ||
WebhookURL: "https://outlook.office.com/webhook/12345", | ||
}, | ||
}, | ||
|
@@ -92,57 +93,57 @@ func TestAccDataSourceHoneycombioRecipient_basic(t *testing.T) { | |
ProtoV5ProviderFactories: testAccProtoV5ProviderFactory, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccRecipientWithDeprecatedTarget("email", "[email protected]"), | ||
Check: resource.TestCheckResourceAttr("data.honeycombio_recipient.test", "address", "[email protected]"), | ||
Config: testAccRecipientWithDeprecatedTarget("email", testRecipients[0].Details.EmailAddress), | ||
Check: resource.TestCheckResourceAttr("data.honeycombio_recipient.test", "address", testRecipients[0].Details.EmailAddress), | ||
}, | ||
{ | ||
Config: testAccRecipientWithDeprecatedTarget("slack", "#acctest"), | ||
Check: resource.TestCheckResourceAttr("data.honeycombio_recipient.test", "channel", "#acctest"), | ||
Config: testAccRecipientWithDeprecatedTarget("slack", testRecipients[2].Details.SlackChannel), | ||
Check: resource.TestCheckResourceAttr("data.honeycombio_recipient.test", "channel", testRecipients[2].Details.SlackChannel), | ||
}, | ||
{ | ||
Config: testAccRecipientWithDeprecatedTarget("email", "[email protected]"), | ||
ExpectError: regexp.MustCompile("your recipient query returned no results."), | ||
}, | ||
{ | ||
Config: testAccRecipientWithFilterValue("email", "address", "[email protected]"), | ||
Check: resource.TestCheckResourceAttr("data.honeycombio_recipient.test", "address", "[email protected]"), | ||
Config: testAccRecipientWithFilterValue("email", "address", testRecipients[1].Details.EmailAddress), | ||
Check: resource.TestCheckResourceAttr("data.honeycombio_recipient.test", "address", testRecipients[1].Details.EmailAddress), | ||
}, | ||
{ | ||
Config: testAccRecipientWithFilterValue("email", "address", "[email protected]"), | ||
ExpectError: regexp.MustCompile("your recipient query returned no results."), | ||
}, | ||
{ | ||
Config: testAccRecipientWithFilterValue("pagerduty", "integration_name", "My Important Service"), | ||
Config: testAccRecipientWithFilterValue("pagerduty", "integration_name", testRecipients[4].Details.PDIntegrationName), | ||
Check: resource.ComposeAggregateTestCheckFunc( | ||
resource.TestCheckResourceAttr("data.honeycombio_recipient.test", "integration_name", "My Important Service"), | ||
resource.TestCheckResourceAttr("data.honeycombio_recipient.test", "integration_key", "6f05176bf1c7a1adb6ee516521770ec4"), | ||
resource.TestCheckResourceAttr("data.honeycombio_recipient.test", "integration_name", testRecipients[4].Details.PDIntegrationName), | ||
resource.TestCheckResourceAttr("data.honeycombio_recipient.test", "integration_key", testRecipients[4].Details.PDIntegrationKey), | ||
), | ||
}, | ||
{ | ||
Config: testAccRecipientWithFilterRegex("webhook", "url", ".*dev.corp.io"), | ||
Check: resource.ComposeAggregateTestCheckFunc( | ||
resource.TestCheckResourceAttr("data.honeycombio_recipient.test", "name", "My Notifications Hook"), | ||
resource.TestCheckResourceAttr("data.honeycombio_recipient.test", "secret", "s0s3kret!"), | ||
resource.TestCheckResourceAttr("data.honeycombio_recipient.test", "name", testRecipients[6].Details.WebhookName), | ||
resource.TestCheckResourceAttr("data.honeycombio_recipient.test", "secret", testRecipients[6].Details.WebhookSecret), | ||
resource.TestCheckResourceAttr("data.honeycombio_recipient.test", "url", "https://my.webhook.dev.corp.io"), | ||
), | ||
}, | ||
{ | ||
Config: testAccRecipientWithFilterValue("msteams", "name", "My Teams Channel"), | ||
Config: testAccRecipientWithFilterValue("msteams", "name", testRecipients[7].Details.WebhookName), | ||
Check: resource.ComposeAggregateTestCheckFunc( | ||
resource.TestCheckResourceAttr("data.honeycombio_recipient.test", "name", "My Teams Channel"), | ||
resource.TestCheckResourceAttr("data.honeycombio_recipient.test", "name", testRecipients[7].Details.WebhookName), | ||
resource.TestCheckResourceAttr("data.honeycombio_recipient.test", "url", "https://outlook.office.com/webhook/12345"), | ||
), | ||
}, | ||
{ | ||
Config: testAccRecipientWithFilterValue("slack", "channel", "#tmp-acctest"), | ||
Check: resource.TestCheckResourceAttr("data.honeycombio_recipient.test", "channel", "#tmp-acctest"), | ||
Config: testAccRecipientWithFilterValue("slack", "channel", testRecipients[3].Details.SlackChannel), | ||
Check: resource.TestCheckResourceAttr("data.honeycombio_recipient.test", "channel", testRecipients[3].Details.SlackChannel), | ||
}, | ||
{ | ||
Config: testAccRecipientWithFilterRegex("email", "address", "^acctest*"), | ||
Config: testAccRecipientWithFilterRegex("email", "address", ".*@example.com"), | ||
ExpectError: regexp.MustCompile("your recipient query returned more than one result. Please try a more specific search criteria."), | ||
}, | ||
{ | ||
Config: testAccRecipientWithFilterRegex("pagerduty", "integration_name", "^.*Important Service$"), | ||
Config: testAccRecipientWithFilterRegex("pagerduty", "integration_name", ".*"), | ||
ExpectError: regexp.MustCompile("your recipient query returned more than one result. Please try a more specific search criteria."), | ||
}, | ||
}, | ||
|
@@ -154,8 +155,7 @@ func testAccRecipientWithDeprecatedTarget(recipientType, target string) string { | |
data "honeycombio_recipient" "test" { | ||
type = "%s" | ||
target = "%s" | ||
} | ||
`, recipientType, target) | ||
}`, recipientType, target) | ||
} | ||
|
||
func testAccRecipientWithFilterValue(recipientType, filterName, filterValue string) string { | ||
|
@@ -167,8 +167,7 @@ data "honeycombio_recipient" "test" { | |
name = "%s" | ||
value = "%s" | ||
} | ||
} | ||
`, recipientType, filterName, filterValue) | ||
}`, recipientType, filterName, filterValue) | ||
} | ||
|
||
func testAccRecipientWithFilterRegex(recipientType, filterName, filterRegex string) string { | ||
|
@@ -180,6 +179,5 @@ data "honeycombio_recipient" "test" { | |
name = "%s" | ||
value_regex = "%s" | ||
} | ||
} | ||
`, recipientType, filterName, filterRegex) | ||
}`, recipientType, filterName, filterRegex) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vet
linter is deprecated