Class: Escobar::Heroku::PipelinePromotionTargets

Inherits:
Object
  • Object
show all
Defined in:
lib/escobar/heroku/pipeline_promotion_targets.rb

Overview

Class reperesenting a Heroku Pipeline Promotion Targets

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pipeline, promotion) ⇒ PipelinePromotionTargets

Returns a new instance of PipelinePromotionTargets.



7
8
9
10
11
12
13
# File 'lib/escobar/heroku/pipeline_promotion_targets.rb', line 7

def initialize(pipeline, promotion)
  @id       = promotion["id"]
  @name     = pipeline.name
  @client   = pipeline.client
  @pipeline = pipeline
  @retries  = 30
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



5
6
7
# File 'lib/escobar/heroku/pipeline_promotion_targets.rb', line 5

def client
  @client
end

#idObject (readonly)

Returns the value of attribute id.



5
6
7
# File 'lib/escobar/heroku/pipeline_promotion_targets.rb', line 5

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/escobar/heroku/pipeline_promotion_targets.rb', line 5

def name
  @name
end

#pipelineObject (readonly)

Returns the value of attribute pipeline.



5
6
7
# File 'lib/escobar/heroku/pipeline_promotion_targets.rb', line 5

def pipeline
  @pipeline
end

#promotionObject (readonly)

Returns the value of attribute promotion.



5
6
7
# File 'lib/escobar/heroku/pipeline_promotion_targets.rb', line 5

def promotion
  @promotion
end

Instance Method Details

#app_idObject



19
20
21
# File 'lib/escobar/heroku/pipeline_promotion_targets.rb', line 19

def app_id
  promotion["source"]["app"]["id"]
end

#infoObject



37
38
39
# File 'lib/escobar/heroku/pipeline_promotion_targets.rb', line 37

def info
  @info ||= client.heroku.get(targets_path)
end

#refObject



29
30
31
# File 'lib/escobar/heroku/pipeline_promotion_targets.rb', line 29

def ref
  @ref ||= source_release.ref
end

#release_idObject



15
16
17
# File 'lib/escobar/heroku/pipeline_promotion_targets.rb', line 15

def release_id
  promotion["source"]["release"]["id"]
end

#releasesObject



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/escobar/heroku/pipeline_promotion_targets.rb', line 41

def releases
  info.map do |target|
    target_app_id     = target["app"]["id"]
    target_release_id = target["release"]["id"]
    Escobar::Heroku::Release.new(
      client, target_app_id, nil, target_release_id
    )
  end
rescue NoMethodError
  raise(ArgumentError, info.to_json) unless retry?
  sleep 0.5
  @retries -= 1
  @info = nil
  retry
end

#retry?Boolean

Returns:

  • (Boolean)


57
58
59
# File 'lib/escobar/heroku/pipeline_promotion_targets.rb', line 57

def retry?
  @retries.positive?
end

#source_releaseObject



23
24
25
26
27
# File 'lib/escobar/heroku/pipeline_promotion_targets.rb', line 23

def source_release
  @release ||= Escobar::Heroku::Release.new(
    client, app_id, nil, release_id
  )
end

#targets_pathObject



33
34
35
# File 'lib/escobar/heroku/pipeline_promotion_targets.rb', line 33

def targets_path
  "/pipeline-promotions/#{id}/promotion-targets"
end