Sha256: d908ade48b2f1c95a5caf55b07a59899d2c8d066b6027d509c78c56ae4f70b43

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

# frozen_string_literal: true

require 'ruby_terraform'
require 'stringio'

require_relative './command_instantiation'

module RSpec
  module Terraform
    module Helpers
      module Actions
        module Show
          include CommandInstantiation

          def show(parameters, plan_file)
            stdout = StringIO.new
            show_command(stdout: stdout)
              .execute(show_parameters(parameters, plan_file))
            stdout.string
          end

          private

          def show_command(opts = {})
            instantiate_command(RubyTerraform::Commands::Show, opts)
          end

          def show_parameters(parameters, plan_file)
            with_show_plan_file_parameters(
              with_show_standard_parameters(parameters),
              plan_file
            )
          end

          def with_show_standard_parameters(parameters)
            parameters.merge(
              chdir: parameters[:configuration_directory],
              no_color: true,
              json: true
            )
          end

          def with_show_plan_file_parameters(parameters, plan_file)
            parameters.merge(
              path: plan_file
            )
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rspec-terraform-0.1.0.pre.47 lib/rspec/terraform/helpers/actions/show.rb