pact-foundation / pact_broker

Enables your consumer driven contracts workflow
http://pactflow.io
MIT License
701 stars 171 forks source link

[Feature Request] Custom default Webhook for new Pacts #336

Closed JoaoGFarias closed 4 years ago

JoaoGFarias commented 4 years ago

Pre issue-raising checklist

I have already (please mark the applicable with an x):

Software versions

Feature Request

Problem

When many teams new create Pacts in an asynchronous manner, it's common to have many Pacts with webhooks in the Create state; and creating all these webhooks in bulk is a pain, even if you have a script to do such job.

Proposed solution

Have a way to configure the Broker instance so that, following the event of a new Pact creation, it will automatically create a webhook defined globally by the users. Additionally, since webhooks messages usually try to relate to the specific Pact, the custom default webhook would need visibility to the pactBroker variables, such as pactbroker.providerName and pactbroker.pactUrl

bethesque commented 4 years ago

Did you know you can create a single global webhook that fires for every pacticipant? It seems to me that this would achieve the goal you're after. Can you explain your use case further, if not?

JoaoGFarias commented 4 years ago

I think this global webhook is exactly what I was looking for.

The problem is that after the contract is created on the Broker, its webhook is in the Create state. So, currently, we are sending two requests per new contract: One to create the webhook and another to add the custom message on the event we want.

This message and event are the same for all our contracts, so the global webhook should be enough. I will try the global option and get back to you.

bethesque commented 4 years ago

You can also automate the creation of the webhook like this:

https://github.com/pactflow/example-provider/blob/master/Makefile#L76