Class: Escobar::Heroku::PipelinePromotionRequest
- Inherits:
-
Object
- Object
- Escobar::Heroku::PipelinePromotionRequest
- Defined in:
- lib/escobar/heroku/pipeline_promotion_request.rb
Overview
Class reperesenting a request for Pipeline Promotion
Defined Under Namespace
Classes: Error, MissingContextsError
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
-
#custom_payload ⇒ Object
Returns the value of attribute custom_payload.
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#forced ⇒ Object
Returns the value of attribute forced.
-
#github_deployment_url ⇒ Object
readonly
Returns the value of attribute github_deployment_url.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#pipeline ⇒ Object
readonly
Returns the value of attribute pipeline.
-
#second_factor ⇒ Object
Returns the value of attribute second_factor.
-
#sha ⇒ Object
readonly
Returns the value of attribute sha.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#targets ⇒ Object
readonly
Returns the value of attribute targets.
Instance Method Summary collapse
- #create(environment, forced, custom_payload) ⇒ Object
- #create_in_api ⇒ Object
- #handle_2fa_failure ⇒ Object
- #handle_github_deployment_statuses_for(releases) ⇒ Object
-
#initialize(client, pipeline, source, targets, second_factor) ⇒ PipelinePromotionRequest
constructor
A new instance of PipelinePromotionRequest.
Constructor Details
#initialize(client, pipeline, source, targets, second_factor) ⇒ PipelinePromotionRequest
Returns a new instance of PipelinePromotionRequest.
10 11 12 13 14 15 16 17 |
# File 'lib/escobar/heroku/pipeline_promotion_request.rb', line 10 def initialize(client, pipeline, source, targets, second_factor) @id = pipeline.id @client = client @pipeline = pipeline @source = source @targets = targets || [] @second_factor = second_factor end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
5 6 7 |
# File 'lib/escobar/heroku/pipeline_promotion_request.rb', line 5 def client @client end |
#custom_payload ⇒ Object
Returns the value of attribute custom_payload.
8 9 10 |
# File 'lib/escobar/heroku/pipeline_promotion_request.rb', line 8 def custom_payload @custom_payload end |
#environment ⇒ Object
Returns the value of attribute environment.
8 9 10 |
# File 'lib/escobar/heroku/pipeline_promotion_request.rb', line 8 def environment @environment end |
#forced ⇒ Object
Returns the value of attribute forced.
8 9 10 |
# File 'lib/escobar/heroku/pipeline_promotion_request.rb', line 8 def forced @forced end |
#github_deployment_url ⇒ Object (readonly)
Returns the value of attribute github_deployment_url.
6 7 8 |
# File 'lib/escobar/heroku/pipeline_promotion_request.rb', line 6 def github_deployment_url @github_deployment_url end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/escobar/heroku/pipeline_promotion_request.rb', line 5 def id @id end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
5 6 7 |
# File 'lib/escobar/heroku/pipeline_promotion_request.rb', line 5 def name @name end |
#pipeline ⇒ Object (readonly)
Returns the value of attribute pipeline.
5 6 7 |
# File 'lib/escobar/heroku/pipeline_promotion_request.rb', line 5 def pipeline @pipeline end |
#second_factor ⇒ Object
Returns the value of attribute second_factor.
8 9 10 |
# File 'lib/escobar/heroku/pipeline_promotion_request.rb', line 8 def second_factor @second_factor end |
#sha ⇒ Object (readonly)
Returns the value of attribute sha.
6 7 8 |
# File 'lib/escobar/heroku/pipeline_promotion_request.rb', line 6 def sha @sha end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
5 6 7 |
# File 'lib/escobar/heroku/pipeline_promotion_request.rb', line 5 def source @source end |
#targets ⇒ Object (readonly)
Returns the value of attribute targets.
5 6 7 |
# File 'lib/escobar/heroku/pipeline_promotion_request.rb', line 5 def targets @targets end |
Instance Method Details
#create(environment, forced, custom_payload) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/escobar/heroku/pipeline_promotion_request.rb', line 19 def create(environment, forced, custom_payload) raise ArgumentError, "No target applications" if targets.empty? @environment = environment @forced = forced @custom_payload = custom_payload fill_promotion_target_urls create_in_api end |
#create_in_api ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/escobar/heroku/pipeline_promotion_request.rb', line 29 def create_in_api promotion = Escobar::Heroku::PipelinePromotion.new( client, pipeline, source, targets, second_factor ) releases = promotion.create handle_github_deployment_statuses_for(releases) releases rescue PipelinePromotion::RequiresTwoFactorError handle_2fa_failure raise end |
#handle_2fa_failure ⇒ Object
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/escobar/heroku/pipeline_promotion_request.rb', line 42 def handle_2fa_failure target_urls.values.each do |target_url| create_github_deployment_status( target_url, nil, "error", "Missing second factor" ) end end |
#handle_github_deployment_statuses_for(releases) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/escobar/heroku/pipeline_promotion_request.rb', line 53 def handle_github_deployment_statuses_for(releases) releases.each do |release| release.sha = release.ref release.github_url = target_urls[release.app.id] release.pipeline_name = pipeline.name create_github_deployment_status( release.github_url, release.dashboard_release_output_url, "pending", "Promotion releasing.." ) end end |