Class: Bauble::Cli::Pulumi

Inherits:
Object
  • Object
show all
Defined in:
lib/bauble/cli/pulumi.rb

Overview

Pulumi class

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config:) ⇒ Pulumi

Returns a new instance of Pulumi.



13
14
15
# File 'lib/bauble/cli/pulumi.rb', line 13

def initialize(config:)
  @config = config
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



11
12
13
# File 'lib/bauble/cli/pulumi.rb', line 11

def config
  @config
end

Instance Method Details

#create_or_select_stack(stack_name) ⇒ Object



42
43
44
45
46
47
48
49
50
# File 'lib/bauble/cli/pulumi.rb', line 42

def create_or_select_stack(stack_name)
  if stack_initialized?(stack_name)
    Logger.debug "Selecting stack #{stack_name}"
    select_stack(stack_name)
  else
    Logger.debug "Initializing stack #{stack_name}"
    init_stack(stack_name)
  end
end

#create_pulumi_yml(template) ⇒ Object



17
18
19
20
21
# File 'lib/bauble/cli/pulumi.rb', line 17

def create_pulumi_yml(template)
  Logger.debug 'Creating Pulumi.yaml...'
  FileUtils.mkdir_p(@config.pulumi_home)
  File.write("#{@config.pulumi_home}/Pulumi.yaml", template, mode: 'w')
end

#destroyObject



37
38
39
40
# File 'lib/bauble/cli/pulumi.rb', line 37

def destroy
  Logger.debug "Running pulumi destroy...\n"
  output_command('destroy --yes')
end

#init!Object



23
24
25
# File 'lib/bauble/cli/pulumi.rb', line 23

def init!
  init_pulumi unless pulumi_initialized?
end

#previewObject



27
28
29
30
# File 'lib/bauble/cli/pulumi.rb', line 27

def preview
  Logger.debug "Running pulumi preview...\n"
  output_command('preview')
end

#up(target = nil) ⇒ Object



32
33
34
35
# File 'lib/bauble/cli/pulumi.rb', line 32

def up(target = nil)
  Logger.debug "Running pulumi up...\n"
  output_command("up --yes#{target ? " --target #{target}" : ''}")
end