Class: Neetob::CLI::MonthlyAudit::InstancesAndAddons::NeetoDeployOrHeroku::AutoScalingEnabled
- Inherits:
-
Base
- Object
- Base
- Neetob::CLI::MonthlyAudit::InstancesAndAddons::NeetoDeployOrHeroku::AutoScalingEnabled
- Defined in:
- lib/neetob/cli/monthly_audit/instances_and_addons/neeto_deploy_or_heroku/auto_scaling_enabled.rb
Constant Summary
Constants inherited from Base
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize ⇒ AutoScalingEnabled
constructor
A new instance of AutoScalingEnabled.
- #run ⇒ Object
Methods included from Utils
#camel_case_to_slug, #is_upper?, #symbolize_keys
Constructor Details
#initialize ⇒ AutoScalingEnabled
Returns a new instance of AutoScalingEnabled.
11 12 13 |
# File 'lib/neetob/cli/monthly_audit/instances_and_addons/neeto_deploy_or_heroku/auto_scaling_enabled.rb', line 11 def initialize super() end |
Instance Method Details
#run ⇒ Object
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 60 61 |
# File 'lib/neetob/cli/monthly_audit/instances_and_addons/neeto_deploy_or_heroku/auto_scaling_enabled.rb', line 15 def run ui.success "### 3.1.4. Checking whether auto-scaling is enabled" apps_data = [["App", "Autoscaling config", "Comments", "Audit Passed"]] ui.info("\n", print_to_audit_log: false) last_comment = nil Neetob::CLI::Sre::Base::APPS_LIST[:neetodeploy].select { |app| app.include?("production") }.each do |app| ui.info("Checking auto_scaling config for #{app}", print_to_audit_log: false) autoscaling_config_result = Neetob::CLI::NeetoDeploy::AutoscalingConfig.new(app).run audit_passed = nil comments = nil autoscaling_config = nil repo = app.gsub("-production", "") if autoscaling_config_result.is_a?(Hash) && autoscaling_config_result["error"] == "Forbidden" audit_passed = "No" comments = "You do not have permission to access the config for this app." else autoscaling_config = JSON.parse(autoscaling_config_result.gsub("=>", ":")) autoscaling_turned_on_for_web = autoscaling_config["web"] audit_passed = autoscaling_turned_on_for_web ? "Yes" : "No" if audit_passed == "No" comments = "Auto-scaling is not enabled for web dynos." issue_url = GithubIssueCreation.new.create_issue( repo:, title: "Enable auto scaling for web dynos", description: comments) audit_passed += " #{issue_url}" same_as_last_comment = comments == last_comment last_comment = comments comments = "''" if same_as_last_comment end end apps_data << [app, autoscaling_config, comments, audit_passed] end Neetob::CLI::Sre::Base::APPS_LIST[:heroku].select { |app| app.include?("production") }.each do |app| ui.info("Checking auto_scaling config for #{app}", print_to_audit_log: false) autoscaling_config_result = Neetob::CLI::Heroku::AutoscalingConfig.new(app).run comments = nil audit_passed = autoscaling_config_result[:judoscale_addon_enabled] ? "Yes" : "No" if audit_passed == "No" comments = "Judoscale addon is not enabled" end apps_data << [app, autoscaling_config_result, comments, audit_passed] end ui.print_table(apps_data) end |