Sha256: 6d7d6e1fdbb0d43269611ec46d293f8bd84a7a61a576268d5126a88e2f3e423c

Contents?: true

Size: 1.31 KB

Versions: 21

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

require_relative "../base"

module Neetob
  class CLI
    module Heroku
      class MaintenanceWindow < Base
        attr_accessor :app

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

        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
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
neetob-0.4.34 lib/neetob/cli/heroku/maintenance_window.rb