Class: Neetob::CLI::MonthlyAudit::InstancesAndAddons::NeetoDeployOrHeroku::EssentialEnvironmentVariablesSet

Inherits:
Base
  • Object
show all
Defined in:
lib/neetob/cli/monthly_audit/instances_and_addons/neeto_deploy_or_heroku/essential_environment_variables_set.rb

Constant Summary

Constants inherited from Base

Base::NEETO_APPS_LIST_LINK

Instance Attribute Summary

Attributes inherited from Base

#ui

Instance Method Summary collapse

Methods included from Utils

#camel_case_to_slug, #is_upper?, #symbolize_keys

Constructor Details

#initializeEssentialEnvironmentVariablesSet

Returns a new instance of EssentialEnvironmentVariablesSet.



10
11
12
# File 'lib/neetob/cli/monthly_audit/instances_and_addons/neeto_deploy_or_heroku/essential_environment_variables_set.rb', line 10

def initialize
  super()
end

Instance Method Details

#runObject



14
15
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/neetob/cli/monthly_audit/instances_and_addons/neeto_deploy_or_heroku/essential_environment_variables_set.rb', line 14

def run
  ui.success "### 3.1.3. Checking whether all essential environment variables are set"

  apps_data = [["App", "All essential env variables set", "Comments", "Audit Passed"]]
  ui.info("\n", print_to_audit_log: false)

  Neetob::CLI::Sre::Base::APPS_LIST[:neetodeploy].select { |app| app.include?("production") }.each do |app|
    ui.info("Checking essential env variables for #{app}", print_to_audit_log: false)
    essential_env_variables_result = Neetob::CLI::Sre::CheckEssentialEnv.new(app).run
    audit_passed = nil
    comments = nil
    all_essential_env_variables_set = nil
    repo = app.gsub("-production", "")
    if essential_env_variables_result["error"] == "Forbidden"
      audit_passed = "No"
      comments = "You do not have permission to access the config vars for this app."
    else
      all_essential_env_variables_set = essential_env_variables_result[:all_keys_present]
      audit_passed = all_essential_env_variables_set ? "Yes" : "No"
      if audit_passed == "No"
        comments = "Missing keys: #{essential_env_variables_result[:missing_keys].join(", ")}"
        issue_url = GithubIssueCreation.new.create_issue(
          repo:, title: "Missing essential environment variables",
          description: comments)
        audit_passed += " #{issue_url}"
      end
    end
    apps_data << [app, all_essential_env_variables_set, comments, audit_passed]
  end
  Neetob::CLI::Sre::Base::APPS_LIST[:heroku].select { |app| app.include?("production") }.each do |app|
    ui.info("Checking essential env variables for #{app}", print_to_audit_log: false)
    essential_env_variables_result = Neetob::CLI::Sre::CheckEssentialEnv.new(app).run
    all_essential_env_variables_set = essential_env_variables_result[:all_keys_present]
    audit_passed = all_essential_env_variables_set ? "Yes" : "No"
    repo = app.gsub("-production", "")
    if audit_passed == "No"
      comments = "Missing keys: #{essential_env_variables_result[:missing_keys].join(", ")}"
      issue_url = GithubIssueCreation.new.create_issue(
        repo:, title: "Add missing essential environment variables",
        description: comments)
      audit_passed += " #{issue_url}"
    end
    apps_data << [app, all_essential_env_variables_set, comments, audit_passed]
  end
  ui.print_table(apps_data)
end