Sha256: 78548bef7bf573c9f093c98967e76cb1b39fb1ac53164bf43437bf1d6b9be894

Contents?: true

Size: 1.63 KB

Versions: 15

Compression:

Stored size: 1.63 KB

Contents

require 'rake_dependencies'
require 'ruby_terraform'
require 'rake_terraform/version'
require 'rake_terraform/tasklib'
require 'rake_terraform/tasks'

module RakeTerraform
  include RubyTerraform

  def self.define_command_tasks(&block)
    RakeTerraform::Tasks::All.new(&block)
  end

  def self.define_installation_tasks(opts = {})
    namespace = opts[:namespace] || :terraform
    version = opts[:version] || '0.10.3'
    path = opts[:path] || File.join('vendor', 'terraform')

    RubyTerraform.configure do |c|
      c.binary = File.join(path, 'bin', 'terraform')
    end
    RakeDependencies::Tasks::All.new do |t|
      t.namespace = namespace
      t.dependency = 'terraform'
      t.version = version
      t.path = path
      t.type = :zip

      t.os_ids = {mac: 'darwin', linux: 'linux'}

      t.uri_template =
          'https://releases.hashicorp.com/terraform/<%= @version %>/' +
              'terraform_<%= @version %>_<%= @os_id %>_amd64<%= @ext %>'
      t.file_name_template =
          'terraform_<%= @version %>_<%= @os_id %>_amd64<%= @ext %>'

      t.needs_fetch = lambda do |parameters|
        terraform_binary = File.join(
            parameters[:path],
            parameters[:binary_directory],
            'terraform')
        version_string = StringIO.new

        if File.exist?(terraform_binary)
          Lino::CommandLineBuilder.for_command(terraform_binary)
              .with_flag('-version')
              .build
              .execute(stdout: version_string)

          if version_string.string.lines.first =~ /#{version}/
            return false
          end
        end

        return true
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
rake_terraform-0.21.1.pre2 lib/rake_terraform.rb
rake_terraform-0.21.1.pre1 lib/rake_terraform.rb
rake_terraform-0.21.0 lib/rake_terraform.rb
rake_terraform-0.20.1.pre1 lib/rake_terraform.rb
rake_terraform-0.20.0 lib/rake_terraform.rb
rake_terraform-0.19.0 lib/rake_terraform.rb
rake_terraform-0.18.0 lib/rake_terraform.rb
rake_terraform-0.17.0 lib/rake_terraform.rb
rake_terraform-0.16.0 lib/rake_terraform.rb
rake_terraform-0.15.0 lib/rake_terraform.rb
rake_terraform-0.14.0 lib/rake_terraform.rb
rake_terraform-0.13.0 lib/rake_terraform.rb
rake_terraform-0.12.0 lib/rake_terraform.rb
rake_terraform-0.11.1 lib/rake_terraform.rb
rake_terraform-0.11.0 lib/rake_terraform.rb