Class: PactBroker::Webhooks::EventListener
Constant Summary
Constants included
from Services
Services::SERVICE_FACTORIES
Instance Method Summary
collapse
Methods included from Logging
included, #log_error, #log_with_tag, #measure_info
Methods included from Services
#badge_service, #branch_service, #certificate_service, #contract_service, #deployed_version_service, #environment_service, #get_service, #group_service, #index_service, #integration_service, #label_service, #matrix_service, #metrics_service, #pact_service, #pacticipant_service, #register_default_services, #register_service, #released_version_service, #tag_service, #verification_service, #version_service, #webhook_service, #webhook_trigger_service
Constructor Details
#initialize(webhook_options) ⇒ EventListener
Returns a new instance of EventListener.
13
14
15
16
17
18
|
# File 'lib/pact_broker/webhooks/event_listener.rb', line 13
def initialize(webhook_options)
@webhook_options = webhook_options
@base_webhook_context = webhook_options[:webhook_execution_configuration].webhook_context
@detected_events = []
end
|
Instance Method Details
#contract_content_changed(params) ⇒ Object
28
29
30
31
|
# File 'lib/pact_broker/webhooks/event_listener.rb', line 28
def contract_content_changed(params)
main_branch_verification = verification_service.find_latest_from_main_branch_for_pact(params.fetch(:pact))
handle_event_for_webhook(PactBroker::Webhooks::WebhookEvent::CONTRACT_CONTENT_CHANGED, { verification: main_branch_verification }.compact.merge(params))
end
|
#contract_content_unchanged(params) ⇒ Object
33
34
35
36
37
38
39
40
|
# File 'lib/pact_broker/webhooks/event_listener.rb', line 33
def contract_content_unchanged(params)
detected_events << PactBroker::Events::Event.new(
"contract_content_unchanged",
params[:event_comment],
[]
)
log_detected_event
end
|
#contract_published(params) ⇒ Object
#log_detected_event ⇒ Object
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/pact_broker/webhooks/event_listener.rb', line 54
def log_detected_event
event = detected_events.last
logger.debug("Event detected", event_name: event.name, event_comment: event.)
if event.triggered_webhooks&.any?
triggered_webhook_descriptions = event.triggered_webhooks.collect{ |tw| { event_name: event.name, webhook_uuid: tw.webhook_uuid, triggered_webhook_uuid: tw.uuid, webhook_description: tw.webhook.description } }
logger.info("Triggered webhooks for #{event.name}", triggered_webhooks: triggered_webhook_descriptions)
else
logger.debug "No enabled webhooks found for event #{event.name}"
end
end
|
#provider_verification_failed(params) ⇒ Object
#provider_verification_published(params) ⇒ Object
#provider_verification_succeeded(params) ⇒ Object
#schedule_triggered_webhooks ⇒ Object
65
66
67
|
# File 'lib/pact_broker/webhooks/event_listener.rb', line 65
def schedule_triggered_webhooks
webhook_trigger_service.schedule_webhooks(detected_events.flat_map(&:triggered_webhooks), webhook_options)
end
|