rake-terraform-wrapper 0.2.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ba8ade0ab9aaf6327ed852a4fd0be7ad08bdf89effa975e89c919829c3a07972
4
- data.tar.gz: 6313ce0ae46436e8d0b6df26fbc5d7a1e11aacb526459181f86d7b8cf27a1ec8
3
+ metadata.gz: 6b6786170a0010d813b928967a2523810630b74d7eb50688a75001ba50e54c76
4
+ data.tar.gz: 5bebb75989daa4755d7d3311f05b9d1ce4893210759ab749b14d95cc8241e053
5
5
  SHA512:
6
- metadata.gz: 2415f8698342007343ae7e634770125e95a277f7ef7c3670fde19b65d3ad97a8f5aa1b256e593c767b824cf1e77c16da8065c5fe285038ed0f3080dcbe143f4e
7
- data.tar.gz: d9db9e2025ff99dd8a4c42679584ba9606f54b6518007f9507582e1977b0e137f05d930803d81fc6ad2a7338d462c5cd7edae33bc60e50aac1d3af44c3248fc8
6
+ metadata.gz: 79d87af07b6dcaa42d85f00439a8bfbc02a68a5de0d40a474bf66fcc99d9d63e7f04d023df3de18d79ba74ea9e68f3e603118f3aa61c257f951a58c53db1d595
7
+ data.tar.gz: 1fa057818549841a6b0f04f172dfaf26c5c1f8a68e8b3d3b51235884b3badb4e89d6ec532c6b672c5dffba056d3f43cbcdf946d82895551d90b1e4b1a974b5be
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rake-terraform-wrapper (0.2.2)
4
+ rake-terraform-wrapper (0.3.3)
5
5
  mixlib-shellout (~> 3.1)
6
6
  os (~> 1.1)
7
7
  rake (~> 13.0)
@@ -10,7 +10,7 @@ PATH
10
10
  GEM
11
11
  remote: https://rubygems.org/
12
12
  specs:
13
- chef-utils (16.5.64)
13
+ chef-utils (16.6.14)
14
14
  coderay (1.1.3)
15
15
  diff-lcs (1.4.4)
16
16
  ffi (1.13.1)
data/README.md CHANGED
@@ -23,6 +23,24 @@ Or install it yourself as:
23
23
  ```ruby
24
24
  require 'rake-terraform-wrapper'
25
25
 
26
+ # specify the following optional config
27
+ Ruby::Terraform.config do |c|
28
+ c.binary = "/path/to/terraform" # or `terraform.exe` on windows
29
+
30
+ # if you prefer that the binary is downloaded automatically, specify the version of the terraform binary
31
+ c.terraform_version = '13.0' #Default version
32
+
33
+ # optionally, specifiy the location where you want the terraform zip file to be downloaded
34
+ c.download_path = "~/.terraform-bin/#{terraform_version}" #default path
35
+ end
36
+
37
+ # to force download, if not specified, terraform will be downloaded automatically on first usage
38
+ task :download_terraform do
39
+ executable = Ruby::Terraform::Executable.new
40
+ executable.download(verbose: true)
41
+ executable.extract(verbose: true)
42
+ end
43
+
26
44
  namespace :network do
27
45
  Ruby::Terraform::Tasks::AllTasks.new(:network) do |tf|
28
46
  tf.dir = File.absolute_path("infra/network")
@@ -3,10 +3,30 @@ module Ruby
3
3
  class Configuration
4
4
  attr_accessor :terraform_version
5
5
  attr_accessor :download_path
6
+ attr_accessor :binary
6
7
 
7
8
  def initialize(opts = {})
8
- @terraform_version = opts[:terraform_version] || Ruby::Terraform::TERRAFORM_VERSION
9
- @download_path = opts[:download_path] || File.expand_path("~/.terraform-bin/#{terraform_version}")
9
+ @terraform_version = opts[:terraform_version]
10
+ @download_path = opts[:download_path]
11
+ @binary = opts[:terraform_binary]
12
+ end
13
+
14
+ def terraform_version
15
+ @terraform_version ||= Ruby::Terraform::TERRAFORM_VERSION
16
+ end
17
+
18
+ def download_path
19
+ @download_path ||= File.expand_path("~/.terraform-bin/#{terraform_version}")
20
+ end
21
+
22
+ def binary
23
+ if @binary
24
+ @binary
25
+ elsif OS.windows?
26
+ @binary ||= "#{@download_path}/terraform.exe"
27
+ else
28
+ @binary ||= "#{@download_path}/terraform"
29
+ end
10
30
  end
11
31
  end
12
32
  end
@@ -7,6 +7,8 @@ module Ruby
7
7
 
8
8
  def config
9
9
  @config ||= Configuration.new
10
+ yield @config if block_given?
11
+ @config
10
12
  end
11
13
 
12
14
  class Executable
@@ -15,26 +17,22 @@ module Ruby
15
17
  def initialize(config = Ruby::Terraform.config)
16
18
  @terraform_version = config.terraform_version
17
19
  @download_path = config.download_path
20
+ @binary = config.binary
18
21
  @download_filename = "#{@terraform_version}-terraform.zip"
19
-
20
22
  FileUtils.mkdir_p(@download_path)
21
23
 
22
24
  raise PlatformUnsupported unless supported?
23
25
  end
24
26
 
25
27
  def binary
26
- if OS.windows?
27
- "#{@download_path}/terraform.exe"
28
- else
29
- "#{@download_path}/terraform"
30
- end
28
+ @binary
31
29
  end
32
30
 
33
31
  def download(opts = {})
34
32
  return if binary_exist?
35
33
  opts[:uri] ||= ENV['TERRAFORM_DOWNLOAD_URL'] || "https://releases.hashicorp.com/#{download_uri}"
36
34
 
37
- $stderr.puts("Downloading terraform binary from #{uri}") if opts[:verbose]
35
+ $stderr.puts("Downloading terraform binary from #{opts[:uri]}") if opts[:verbose]
38
36
 
39
37
  open("#{@download_path}/#{@download_filename}", 'wb') do |saved_file|
40
38
  open(opts[:uri], 'rb') do |read_file|
@@ -43,10 +41,10 @@ module Ruby
43
41
  end
44
42
  end
45
43
 
46
- def extract(verbose = false)
44
+ def extract(opts={})
47
45
  return if binary_exist?
48
46
 
49
- Decompressor.extract("#{@download_path}/#{@download_filename}", @download_path, verbose)
47
+ Decompressor.extract("#{@download_path}/#{@download_filename}", @download_path, opts[:verbose] || false)
50
48
  make_exe
51
49
  end
52
50
 
@@ -20,7 +20,7 @@ module Ruby
20
20
  if build_dir
21
21
  task :pre_init do
22
22
  rm_rf dir_to_use
23
- mkdir_p dir_to_use
23
+ mkdir_p File.dirname(dir_to_use) # create parent dir
24
24
  cp_r dir, dir_to_use
25
25
  end
26
26
  end
@@ -1,6 +1,6 @@
1
1
  module Ruby
2
2
  module Terraform
3
- VERSION = "0.2.2".freeze
3
+ VERSION = "0.3.3".freeze
4
4
  TERRAFORM_VERSION = '0.13.3'.freeze
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rake-terraform-wrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ruby Terraform
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-21 00:00:00.000000000 Z
11
+ date: 2020-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mixlib-shellout