Module: Kitchen::Pulumi::Command::Input

Defined in:
lib/kitchen/pulumi/command/input.rb

Overview

Class used to fetch resolved stack inputs via '$ pulumi config --json'

Class Method Summary collapse

Class Method Details

.run(directory:, stack:, conf_file:, logger:) ⇒ Object


15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/kitchen/pulumi/command/input.rb', line 15

def run(directory:, stack:, conf_file:, logger:)
  cmd = "config -C #{directory} -s #{stack} #{conf_file} -j"

  ::Kitchen::Pulumi::ShellOut.run(cmd: cmd, logger: logger) do |stdout:|
    yield inputs: ::Kitchen::Util.stringified_hash(
      ::JSON.parse(stdout),
    )
  end
rescue ::JSON::ParserError => e
  raise(
    ::Kitchen::Pulumi::Error,
    "Parsing resolved stack config as JSON failed: #{e.message}",
  )
end