class RooOnRails::Checks::Heroku::AppExists
Check if a corresponding app exists on Heroku
(for a given environment)
Input context
-
git_repo: the name of the repository
-
heroku.api_client: a connected PlatformAPI client
-
app_name_stem (optional): a name override
Output context:
-
heroku.app.{env}: an app name.
Constants
- ACCEPTABLE_ENV_NAMES
Public Instance Methods
call()
click to toggle source
# File lib/roo_on_rails/checks/heroku/app_exists.rb, line 29 def call all_apps = client.app.list.map { |a| a['name'] } matches = all_apps.select { |a| candidates.include?(a) } if matches.empty? fail! "no apps with matching names detected" end if matches.many? list = candidates.map { |c| bold c }.join(', ') final_fail! "multiple matching apps detected: #{list}" end context.heroku.app![env] = matches.first pass "found app #{bold matches.first}" end
intro()
click to toggle source
# File lib/roo_on_rails/checks/heroku/app_exists.rb, line 25 def intro "Checking if #{bold env} app exist..." end
Private Instance Methods
candidates()
click to toggle source
# File lib/roo_on_rails/checks/heroku/app_exists.rb, line 55 def candidates [ ['deliveroo', 'roo', nil], [name_stem], env_suffixes, ].tap { |a| a.replace a.first.product(*a[1..-1]) }.map { |c| c.compact.join('-') } end
client()
click to toggle source
# File lib/roo_on_rails/checks/heroku/app_exists.rb, line 67 def client context.heroku.api_client end
env_suffixes()
click to toggle source
# File lib/roo_on_rails/checks/heroku/app_exists.rb, line 51 def env_suffixes ACCEPTABLE_ENV_NAMES.fetch(env, [env]) end
name_stem()
click to toggle source
# File lib/roo_on_rails/checks/heroku/app_exists.rb, line 47 def name_stem context.app_name_stem || context.git_repo.delete('.') end