Skip to content

Commit

Permalink
feat: add support for creating webhooks with event contract_requiring…
Browse files Browse the repository at this point in the history
…_verification_published (feature toggled off)
  • Loading branch information
bethesque committed Aug 16, 2021
1 parent 2282622 commit 4d4bc4b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lib/pact_broker/client/cli/webhook_commands.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ def self.shared_options_for_webhook_commands
method_option :provider_verification_published, type: :boolean, desc: "Trigger this webhook when a provider verification result is published"
method_option :provider_verification_failed, type: :boolean, desc: "Trigger this webhook when a failed provider verification result is published"
method_option :provider_verification_succeeded, type: :boolean, desc: "Trigger this webhook when a successful provider verification result is published"
if ENV.fetch("PACT_BROKER_FEATURES", "").include?("contract_requiring_verification_published")
method_option :contract_requiring_verification_published, type: :boolean, desc: "Trigger this webhook when a contract is published that requires verification"
end
method_option :team_uuid, banner: "UUID", desc: "UUID of the Pactflow team to which the webhook should be assigned (Pactflow only)"
shared_authentication_options
end
Expand Down Expand Up @@ -62,12 +65,14 @@ def parse_webhook_events
events << 'provider_verification_published' if options.provider_verification_published
events << 'provider_verification_succeeded' if options.provider_verification_succeeded
events << 'provider_verification_failed' if options.provider_verification_failed
events << 'contract_requiring_verification_published' if options.contract_requiring_verification_published
events
end

def parse_webhook_options(webhook_url)
events = parse_webhook_events

# TODO update for contract_requiring_verification_published when released
if events.size == 0
raise WebhookCreationError.new("You must specify at least one of --contract-content-changed, --contract-published, --provider-verification-published, --provider-verification-succeeded or --provider-verification-failed")
end
Expand Down

0 comments on commit 4d4bc4b

Please sign in to comment.