Class: Opsup::App

Inherits:
Object
  • Object
show all
Defined in:
lib/opsup/app.rb

Constant Summary collapse

AVAILABLE_COMMANDS =
%w[
  update_cookbooks
  setup
  configure
  deploy
].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logger:) ⇒ App

Returns a new instance of App.



15
16
17
# File 'lib/opsup/app.rb', line 15

def initialize(logger:)
  @logger = logger
end

Class Method Details

.createObject



9
10
11
12
13
# File 'lib/opsup/app.rb', line 9

def self.create
  new(
    logger: Opsup::Logger.instance,
  )
end

Instance Method Details

#available_commandsObject



26
27
28
# File 'lib/opsup/app.rb', line 26

def available_commands
  AVAILABLE_COMMANDS
end

#run(commands, config) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/opsup/app.rb', line 30

def run(commands, config)
  validate_commands(commands)
  @logger.warn('Started in DRYRUN MODE') if config.dryrun
  @logger.debug("Running #{commands} with #{config.to_h}")

  opsworks = new_opsworks_client(config)
  opsworks_commands = commands.map { |c| command_to_opsworks_command(c) }

  stack_operator = Opsup::StackOperator.create(opsworks: opsworks)
  stack_operator.run_commands(
    opsworks_commands,
    stack_name: config.stack_name,
    mode: config.running_mode,
    dryrun: config.dryrun,
  )
ensure
  @logger.warn('Finished in DRYRUN MODE') if config.dryrun
end