Class: Neetob::CLI::Heroku::ConfigVars::Audit

Inherits:
Base
  • Object
show all
Defined in:
lib/neetob/cli/heroku/config_vars/audit.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

#client

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(apps, expected_config_vars_json_file_path = "", sandbox = false) ⇒ Audit

Returns a new instance of Audit.



15
16
17
18
19
20
# File 'lib/neetob/cli/heroku/config_vars/audit.rb', line 15

def initialize(apps, expected_config_vars_json_file_path = "", sandbox = false)
  super()
  @apps = apps
  @expected_config_vars_json_file_path = expected_config_vars_json_file_path
  @sandbox = sandbox
end

Instance Attribute Details

#appsObject

Returns the value of attribute apps.



13
14
15
# File 'lib/neetob/cli/heroku/config_vars/audit.rb', line 13

def apps
  @apps
end

#expected_config_vars_json_file_pathObject

Returns the value of attribute expected_config_vars_json_file_path.



13
14
15
# File 'lib/neetob/cli/heroku/config_vars/audit.rb', line 13

def expected_config_vars_json_file_path
  @expected_config_vars_json_file_path
end

#sandboxObject

Returns the value of attribute sandbox.



13
14
15
# File 'lib/neetob/cli/heroku/config_vars/audit.rb', line 13

def sandbox
  @sandbox
end

Instance Method Details

#runObject



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/neetob/cli/heroku/config_vars/audit.rb', line 22

def run
  matching_apps = find_all_matching_apps_or_repos(apps, :heroku, sandbox)
  table_rows = []
  expected_config = read_json_file(expected_config_vars_json_file_path || default_config_vars_json_file_path)
  return unless expected_config

  matching_apps.each do |app|
    actual_config = `heroku config -a #{app} --json`
    unless $?.success?
      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.")
      next
    end

    actual_config_json = JSON.parse(actual_config)
    table_rows.concat(compare_config_and_build_rows(app, expected_config, actual_config_json))
  end
  table = Terminal::Table.new headings: ["App", "Config var", "Expected", "Result"], rows: table_rows
  ui.success(table)
end