Sha256: 6fd38e7b5c18eb5e38fcce5aa7e1200ff2638bddd96ab4e8c7fe57f32ec72411

Contents?: true

Size: 1.59 KB

Versions: 16

Compression:

Stored size: 1.59 KB

Contents

require 'rake_factory'
require 'ruby_terraform'
require 'ostruct'
require 'colored2'

module RakeTerraform
  module Tasks
    class Output < RakeFactory::Task
      default_name :output
      default_prerequisites RakeFactory::DynamicValue.new { |t|
        [t.ensure_task_name]
      }
      default_description RakeFactory::DynamicValue.new { |t|
        "Output #{t.configuration_name} using terraform"
      }

      parameter :configuration_name, :required => true
      parameter :source_directory, :required => true
      parameter :work_directory, :required => true

      parameter :backend_config

      parameter :state_file

      parameter :debug, :default => false
      parameter :no_color, :default => false
      parameter :no_print_output, :default => false

      parameter :ensure_task_name, :default => :'terraform:ensure'

      action do |t|
        Colored2.disable! if t.no_color

        configuration_directory =
            File.join(t.work_directory, t.source_directory)

        puts "Output of #{t.configuration_name}".cyan
        RubyTerraform.clean(
            directory: configuration_directory)

        mkdir_p File.dirname(configuration_directory)
        cp_r t.source_directory, configuration_directory

        Dir.chdir(configuration_directory) do
          RubyTerraform.init(
              backend_config: t.backend_config,
              no_color: t.no_color)

          output = RubyTerraform.output(
              no_color: t.no_color,
              state: t.state_file)

          puts output unless t.no_print_output

          output
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
rake_terraform-1.15.0 lib/rake_terraform/tasks/output.rb
rake_terraform-1.14.0.pre.1 lib/rake_terraform/tasks/output.rb
rake_terraform-1.13.0 lib/rake_terraform/tasks/output.rb
rake_terraform-1.12.0.pre.1 lib/rake_terraform/tasks/output.rb
rake_terraform-1.11.0 lib/rake_terraform/tasks/output.rb
rake_terraform-1.10.0.pre.2 lib/rake_terraform/tasks/output.rb
rake_terraform-1.10.0.pre.1 lib/rake_terraform/tasks/output.rb
rake_terraform-1.9.0 lib/rake_terraform/tasks/output.rb
rake_terraform-1.8.0.pre.2 lib/rake_terraform/tasks/output.rb
rake_terraform-1.8.0.pre.1 lib/rake_terraform/tasks/output.rb
rake_terraform-1.7.0 lib/rake_terraform/tasks/output.rb
rake_terraform-1.6.0.pre.1 lib/rake_terraform/tasks/output.rb
rake_terraform-1.5.0 lib/rake_terraform/tasks/output.rb
rake_terraform-1.4.0.pre.1 lib/rake_terraform/tasks/output.rb
rake_terraform-1.3.0 lib/rake_terraform/tasks/output.rb
rake_terraform-1.2.0.pre.1 lib/rake_terraform/tasks/output.rb