Class: Pipedream::Webhook
- Inherits:
-
Object
- Object
- Pipedream::Webhook
- Includes:
- Dsl::Webhook, Evaluate
- Defined in:
- lib/pipedream/webhook.rb
Constant Summary
Constants included from Dsl::Webhook
Instance Method Summary collapse
- #default_properties ⇒ Object
-
#initialize(options = {}) ⇒ Webhook
constructor
A new instance of Webhook.
- #run ⇒ Object
- #set_secret_token! ⇒ Object
Methods included from Evaluate
Methods included from Dsl::Webhook
Methods included from Dsl::Ssm
Constructor Details
#initialize(options = {}) ⇒ Webhook
Returns a new instance of Webhook.
6 7 8 9 10 |
# File 'lib/pipedream/webhook.rb', line 6 def initialize(={}) @options = @webhook_path = [:webhook_path] || get_webhook_path @properties = default_properties end |
Instance Method Details
#default_properties ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/pipedream/webhook.rb', line 29 def default_properties { authentication: 'GITHUB_HMAC', # GITHUB_HMAC, IP and UNAUTHENTICATED authentication_configuration: { secret_token: @secret_token, }, filters: [{ json_path: "$.ref", match_equals: "refs/heads/{Branch}", }], # name: '', # optional register_with_third_party: 'true', # optional target_action: 'Source', target_pipeline: {ref: "Pipeline"}, target_pipeline_version: {"Fn::GetAtt": "Pipeline.Version"}, } end |
#run ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/pipedream/webhook.rb', line 12 def run return unless File.exist?(@webhook_path) old_properties = @properties.clone evaluate(@webhook_path) set_secret_token! return if old_properties == @properties # empty webhook.rb file resource = { webhook: { type: "AWS::CodePipeline::Webhook", properties: @properties } } CfnCamelizer.transform(resource) end |
#set_secret_token! ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/pipedream/webhook.rb', line 47 def set_secret_token! @properties.merge!( authentication_configuration: { secret_token: @secret_token } ) end |