Module: Aptible::CLI::Subcommands::Services

Included in:
Agent
Defined in:
lib/aptible/cli/subcommands/services.rb

Class Method Summary collapse

Class Method Details

.included(thor) ⇒ Object



5
6
7
8
9
10
11
12
13
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
# File 'lib/aptible/cli/subcommands/services.rb', line 5

def self.included(thor)
  thor.class_eval do
    include Helpers::App

    desc 'services', 'List Services for an App'
    app_options
    def services
      app = ensure_app(options)

      Formatter.render(Renderer.current) do |root|
        root.list do |list|
          app.each_service do |service|
            list.object do |node|
              ResourceFormatter.inject_service(node, service, app)
            end
          end
        end
      end
    end

    desc 'services:settings SERVICE'\
           ' [--force-zero-downtime|--no-force-zero-downtime]'\
           ' [--simple-health-check|--no-simple-health-check]',
         'Modifies the zero-downtime deploy setting for a service'
    app_options
    option :force_zero_downtime,
           type: :boolean, default: false,
           desc: 'Force zero downtime deployments.'\
           ' Has no effect if service has an associated Endpoint'
    option :simple_health_check,
           type: :boolean, default: false,
           desc: 'Use a simple uptime healthcheck during deployments'
    define_method 'services:settings' do |service|
      service = ensure_service(options, service)
      updates = {}
      updates[:force_zero_downtime] =
        options[:force_zero_downtime] if options[:force_zero_downtime]
      updates[:naive_health_check] =
        options[:simple_health_check] if options[:simple_health_check]

      service.update!(**updates) if updates.any?
    end
  end
end