Class: Serverkit::Actions::Apply

Inherits:
Base
  • Object
show all
Defined in:
lib/serverkit/actions/apply.rb

Instance Method Summary collapse

Methods inherited from Base

#call, #initialize

Constructor Details

This class inherits a constructor from Serverkit::Actions::Base

Instance Method Details

#runObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/serverkit/actions/apply.rb', line 7

def run
  successful = backends.map do |backend|
    Thread.new do
      resources = recipe.resources.map(&:clone).map do |resource|
        resource.backend = backend
        resource.run_apply
        puts resource.inspect_apply_result
        resource
      end
      handlers = resources.select(&:notifiable?).flat_map(&:handlers).uniq.map(&:clone).map do |handler|
        handler.backend = backend
        handler.run_apply
        puts handler.inspect_apply_result
        handler
      end
      resources + handlers
    end
  end.map(&:value).flatten.all?(&:successful?)
  if successful
    exit
  else
    exit(1)
  end
end