Class: Jets::CLI::Maintenance::Mode

Inherits:
Base
  • Object
show all
Defined in:
lib/jets/cli/maintenance/mode.rb

Instance Attribute Summary

Attributes inherited from Base

#options

Instance Method Summary collapse

Methods inherited from Base

#initialize

Methods included from Util::Truthy

#truthy?

Methods included from Lambda::Checks

#check_deployed!, #check_workers!, #workers_deployed?

Methods inherited from Base

#initialize, #paginate, #paging_params, rescue_api_error

Methods included from Util::Logging

#log

Methods included from AwsServices

#apigateway, #aws_options, #cfn, #codebuild, #dynamodb, #lambda_client, #logs, #s3, #s3_resource, #sns, #sqs, #ssm, #sts, #wafv2

Methods included from AwsServices::StackStatus

#output_value, #stack_exists?

Methods included from AwsServices::GlobalMemoist

included, #reset_cache!

Methods included from Api

#api, #api_key

Constructor Details

This class inherits a constructor from Jets::CLI::Maintenance::Base

Instance Method Details

#are_you_sure?Boolean

Returns:

  • (Boolean)


25
26
27
# File 'lib/jets/cli/maintenance/mode.rb', line 25

def are_you_sure?
  sure?("Will enable #{role_info} maintenance mode #{for_info}")
end

#for_infoObject



33
34
35
# File 'lib/jets/cli/maintenance/mode.rb', line 33

def for_info
  "for #{Jets.project.namespace}"
end

#offObject



9
10
11
12
# File 'lib/jets/cli/maintenance/mode.rb', line 9

def off
  warn "Disabling #{role_info} maintenance mode #{for_info}"
  role.off
end

#onObject



3
4
5
6
7
# File 'lib/jets/cli/maintenance/mode.rb', line 3

def on
  are_you_sure?
  warn "Enabling #{role_info} maintenance mode #{for_info}"
  role.on
end

#roleObject



37
38
39
40
41
# File 'lib/jets/cli/maintenance/mode.rb', line 37

def role
  # IE: Web or Worker
  klass = Jets::CLI::Maintenance.const_get(@options[:role].camelize)
  klass.new(@options)
end

#role_infoObject



29
30
31
# File 'lib/jets/cli/maintenance/mode.rb', line 29

def role_info
  @options[:role]
end

#statusObject



14
15
16
17
18
19
20
21
22
23
# File 'lib/jets/cli/maintenance/mode.rb', line 14

def status
  if @options[:all]
    warn "Maintenance status for #{Jets.project.namespace}"
    puts "web #{Web.new.status}"
    puts "worker #{Worker.new.status}"
  else
    warn "#{role_info.titleize} maintenance status #{for_info}"
    puts role.status
  end
end