Module: Bauble::Cli::Commands::Up

Included in:
BaubleCli
Defined in:
lib/bauble/cli/commands/up.rb

Overview

Up command

Class Method Summary collapse

Class Method Details

.included(thor) ⇒ Object



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
49
50
51
52
53
54
55
56
57
58
# File 'lib/bauble/cli/commands/up.rb', line 13

def included(thor)
  thor.class_eval do
    desc 'up', 'Deploy the application'
    method_option :stack, type: :string, desc: 'The stack to stand up', aliases: '-s'

    def up
      Logger.

      setup_app

      # check for any stacks
      raise 'No stacks found' if @app.stacks.empty?

      # check for multiple stacks
      if @app.stacks.length > 1 && options[:stack].nil?
        Logger.error 'Must provide a stack when multiple are defined'
        exit(1)
      end

      # set up stack
      stack_name = options[:stack] || @app.stacks.first.name
      @app.change_current_stack(stack_name)

      # bundle assets
      Logger.block_log 'Bundling assets...'
      Logger.nl
      @app.bundle

      # write template file
      pulumi.create_pulumi_yml(@app.template)

      # initialize pulumi
      pulumi.init!

      # create or select stack
      pulumi.create_or_select_stack(stack_name)

      # deploy the rest
      Logger.block_log 'Deploying application resources...'
      pulumi.up

      # log completion
      Logger.log "Up complete\n"
    end
  end
end