Class: Neetob::CLI::MonthlyAudit::InstancesAndAddons::NeetoDeployOrHeroku::ScheduledExportsEnabled

Inherits:
Base
  • Object
show all
Defined in:
lib/neetob/cli/monthly_audit/instances_and_addons/neeto_deploy_or_heroku/scheduled_exports_enabled.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

#initializeScheduledExportsEnabled

Returns a new instance of ScheduledExportsEnabled.



10
11
12
# File 'lib/neetob/cli/monthly_audit/instances_and_addons/neeto_deploy_or_heroku/scheduled_exports_enabled.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
# File 'lib/neetob/cli/monthly_audit/instances_and_addons/neeto_deploy_or_heroku/scheduled_exports_enabled.rb', line 14

def run
  ui.success "### 3.1.5. Checking whether scheduled exports are enabled"

  apps_data = [["App", "Scheduled exports config", "Comments", "Audit Passed"]]
  ui.info("\n", print_to_audit_log: false)
  last_scheduled_exports_config = nil
  Neetob::CLI::Sre::Base::APPS_LIST[:neetodeploy].select { |app| app.include?("production") }.each do |app|
    ui.info("Checking Scheduled exports config for #{app}", print_to_audit_log: false)
    scheduled_exports_result = Neetob::CLI::NeetoDeploy::ScheduledExports.new(app).run
    audit_passed = nil
    comments = nil
    scheduled_exports_config = nil
    repo = app.gsub("-production", "")
    if scheduled_exports_result.include? "Forbidden"
      audit_passed = "No"
      comments = "You do not have permission to access the config for this app."
    else
      scheduled_exports_config = scheduled_exports_result
        .gsub("\e[32m", "")
        .gsub("\e[0m", "")
        .gsub("#{app}'s", "")
        .strip
      audit_passed = scheduled_exports_config.include?("turned on") ? "Yes" : "No"
      if audit_passed == "No"
        comments = scheduled_exports_config
        issue_url = GithubIssueCreation.new.create_issue(
          repo:, title: "Enable scheduled exports",
          description: strip_ansi_codes(comments))
        audit_passed += " #{issue_url}"
      end
      same_as_last_scheduled_export_config = scheduled_exports_config == last_scheduled_exports_config
      last_scheduled_exports_config = scheduled_exports_config
      if same_as_last_scheduled_export_config
        scheduled_exports_config = "''"
      end
    end
    apps_data << [app, scheduled_exports_config, comments, audit_passed]
  end
  ui.print_table(apps_data)
end