class Escobar::Heroku::PipelinePromotionTargets

Class reperesenting a Heroku Pipeline Promotion Targets

Attributes

client[R]
id[R]
name[R]
pipeline[R]
promotion[R]

Public Class Methods

new(pipeline, promotion) click to toggle source
# 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

Public Instance Methods

app_id() click to toggle source
# File lib/escobar/heroku/pipeline_promotion_targets.rb, line 19
def app_id
  promotion["source"]["app"]["id"]
end
info() click to toggle source
# File lib/escobar/heroku/pipeline_promotion_targets.rb, line 37
def info
  @info ||= client.heroku.get(targets_path)
end
ref() click to toggle source
# File lib/escobar/heroku/pipeline_promotion_targets.rb, line 29
def ref
  @ref ||= source_release.ref
end
release_id() click to toggle source
# File lib/escobar/heroku/pipeline_promotion_targets.rb, line 15
def release_id
  promotion["source"]["release"]["id"]
end
releases() click to toggle source
# 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?() click to toggle source
# File lib/escobar/heroku/pipeline_promotion_targets.rb, line 57
def retry?
  @retries.positive?
end
source_release() click to toggle source
# 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_path() click to toggle source
# File lib/escobar/heroku/pipeline_promotion_targets.rb, line 33
def targets_path
  "/pipeline-promotions/#{id}/promotion-targets"
end