Class: Neetob::CLI::Heroku::MaintenanceWindow

Inherits:
Base
  • Object
show all
Defined in:
lib/neetob/cli/heroku/maintenance_window.rb

Constant Summary

Constants inherited from Base

Base::NEETO_DEPLOY_DOCS

Constants inherited from Base

Base::NEETO_APPS_LIST_LINK

Instance Attribute Summary collapse

Attributes inherited from Base

#ui

Instance Method Summary collapse

Methods inherited from Base

#process

Methods included from Utils

#camel_case_to_slug, #is_upper?, #symbolize_keys

Constructor Details

#initialize(app) ⇒ MaintenanceWindow

Returns a new instance of MaintenanceWindow.



11
12
13
14
# File 'lib/neetob/cli/heroku/maintenance_window.rb', line 11

def initialize(app)
  super()
  @app = app
end

Instance Attribute Details

#appObject

Returns the value of attribute app.



9
10
11
# File 'lib/neetob/cli/heroku/maintenance_window.rb', line 9

def app
  @app
end

Instance Method Details

#runObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/neetob/cli/heroku/maintenance_window.rb', line 16

def run
  redis_maintenance_modes =
    `heroku redis:info -a #{app} |
      awk '/^===/ {addon=$2} /Maintenance window:/ {print addon ":", $3, $4, $5, $6, $7}'`
  redis_succeeded = $?.success?
  pg_maintenance_modes =
    `heroku pg:info -a #{app} |
      awk '/^===/ {url=$2; gsub(",", "", url)} /Maintenance window:/ {print url ":", $3, $4, $5, $6, $7}'`
  pg_succeeded = $?.success?

  unless redis_succeeded || pg_succeeded
    ui.error("There is a problem in accessing the app with name \"#{app}\" in your account.")
    ui.error("Please check the specified app name and ensure you're authorized to view that app.")
  end

  unless redis_maintenance_modes.empty?
    ui.success("Redis maintenance windows:")
    ui.info(redis_maintenance_modes)
  end

  unless pg_maintenance_modes.empty?
    ui.success("PostgreSQL maintenance windows:")
    ui.info(pg_maintenance_modes)
  end
end