pactflow / terraform-provider-pact

Terraform provider for Pact Broker (and Pactflow)
https://pactflow.io
MIT License
23 stars 4 forks source link

Support for provider_verification_failed event #9

Closed lukaszczechowski closed 3 years ago

lukaszczechowski commented 3 years ago

Would it be possible to include support for _provider_verificationfailed event as described in Webhook docs?

I'm not sure but I believe that the client used under the hood supports this kind of event and it is only a matter of extending the following list: https://github.com/pactflow/terraform/blob/dda87a391c9780948fca285a9d6337dc17f27344/resource_webhook.go#L18

mefellows commented 3 years ago

Yep, I'll get this out tomorrow! Thanks.

mefellows commented 3 years ago

Release on the way (v0.1.0).

lukaszczechowski commented 3 years ago

Thanks @mefellows for (lighting fast) delivering of a fix :) I've got one remark though. The following method is implemented in a way which requires the input array s to be initially sorted.

func stringContains(s []string, searchterm string) bool {
    i := sort.SearchStrings(s, searchterm)
    return i < len(s) && s[i] == searchterm
}

Currently, if you use the new type of the event (provider_verification_failed) it won't be validated because returned index i doesn't match the index of the input array s. As a quick fix I propose to reorder the allowedEvents array:

var allowedEvents = []string{
    "contract_content_changed",
    "contract_published",
    "provider_verification_failed",
    "provider_verification_published",
    "provider_verification_succeeded",
}
mefellows commented 3 years ago

Ah! Good pickup, apologies for that.

I've just pushed out a minor fix to address that issue (it will now sort the input array too).