rake_terraform 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e82b03df01c88f7146f5614281aea65bdf098746
4
- data.tar.gz: c9f79cd69052a337eb3dfae6ac0544e7be174292
3
+ metadata.gz: 76c255ddec30794de2a3a25d1b4c2ff329bfc94f
4
+ data.tar.gz: 189430e50a791b3f0eec78a2f2d07604530244e6
5
5
  SHA512:
6
- metadata.gz: 6ef64c32031ef9134bba24e8cc99ec27b47ccd781d3db71952955717ad92e537c54825e313adf42e286ff156ac0eb4a69593acb77d0cdc39030a28345577357a
7
- data.tar.gz: 2a22dfa9c1a8aa8fdea3fcaa6df33c1fd1919c31a627ac2bfb9527cd3ee00463318a4d09d591fbb4818f205054b36e10c6da261023a97902b6e68d9174505ea7
6
+ metadata.gz: 7fbb79cc988c0a4108447859400e326f2154765721c7c06cd612e6a5e426777327496d961e2b4854e6b549023716e8ac8c94b66e7a3cd21fd5c94c9a06df8955
7
+ data.tar.gz: 0936551d175e815407edd77532a7097cd7a1d0969bf41b79b5e099410b6bca633a5a81c971b92d3011e2ac80adf197f50782b014070911c9c26f71e5d2ce2ca4
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rake_terraform (0.5.0)
4
+ rake_terraform (0.6.0)
5
5
  rake_dependencies (~> 0.15)
6
6
  ruby-terraform (~> 0.4)
7
7
 
@@ -15,13 +15,20 @@ module RakeTerraform
15
15
 
16
16
  parameter :backup_file
17
17
 
18
+ parameter :argument_names
19
+
18
20
  parameter :ensure_task, :default => :'terraform:ensure'
21
+
19
22
  parameter :provision_task_name, :default => :provision
23
+ parameter :provision_argument_names
24
+
20
25
  parameter :destroy_task_name, :default => :destroy
26
+ parameter :destroy_argument_names
21
27
 
22
28
  def define
23
29
  Provision.new do |t|
24
30
  t.name = provision_task_name
31
+ t.argument_names = provision_argument_names || argument_names || []
25
32
 
26
33
  t.configuration_name = configuration_name
27
34
  t.configuration_directory = configuration_directory
@@ -41,6 +48,8 @@ module RakeTerraform
41
48
  end
42
49
  Destroy.new do |t|
43
50
  t.name = destroy_task_name
51
+ t.argument_names = destroy_argument_names || argument_names || []
52
+
44
53
 
45
54
  t.configuration_name = configuration_name
46
55
  t.configuration_directory = configuration_directory
@@ -5,6 +5,7 @@ module RakeTerraform
5
5
  module Tasks
6
6
  class Destroy < TaskLib
7
7
  parameter :name, :default => :destroy
8
+ parameter :argument_names, :default => []
8
9
 
9
10
  parameter :configuration_name, :required => true
10
11
  parameter :configuration_directory, :required => true
@@ -33,18 +34,25 @@ module RakeTerraform
33
34
  end
34
35
 
35
36
  desc "Destroy #{configuration_name} using terraform"
36
- task name => [ensure_task] do
37
- apply_vars = vars.respond_to?(:call) ?
38
- vars.call(
39
- configuration_name: configuration_name,
40
- configuration_directory: configuration_directory,
41
- backend: backend,
42
- backend_config: backend_config,
43
- state_file: state_file,
44
- no_color: no_color,
45
- no_backup: no_backup,
46
- backup_file: backup_file) :
47
- vars
37
+ task name, argument_names => [ensure_task] do |_, args|
38
+ params = OpenStruct.new({
39
+ configuration_name: configuration_name,
40
+ configuration_directory: configuration_directory,
41
+ backend: backend,
42
+ backend_config: backend_config,
43
+ state_file: state_file,
44
+ no_color: no_color,
45
+ no_backup: no_backup,
46
+ backup_file: backup_file
47
+ })
48
+
49
+ derived_vars = vars.respond_to?(:call) ?
50
+ vars.call(*[args, params].slice(0, vars.arity)) :
51
+ vars
52
+ derived_backend_config = backend_config.respond_to?(:call) ?
53
+ backend_config.call(
54
+ *[args, params].slice(0, backend_config.arity)) :
55
+ backend_config
48
56
 
49
57
  puts "Destroying #{configuration_name}"
50
58
 
@@ -56,7 +64,7 @@ module RakeTerraform
56
64
  RubyTerraform.remote_config(
57
65
  no_color: no_color,
58
66
  backend: backend,
59
- backend_config: backend_config)
67
+ backend_config: derived_backend_config)
60
68
  end
61
69
  RubyTerraform.destroy(
62
70
  force: true,
@@ -65,7 +73,7 @@ module RakeTerraform
65
73
  backup: backup_file,
66
74
  directory: configuration_directory,
67
75
  state: state_file,
68
- vars: apply_vars)
76
+ vars: derived_vars)
69
77
  end
70
78
  end
71
79
  end
@@ -1,10 +1,12 @@
1
1
  require 'ruby_terraform'
2
+ require 'ostruct'
2
3
  require_relative '../tasklib'
3
4
 
4
5
  module RakeTerraform
5
6
  module Tasks
6
7
  class Provision < TaskLib
7
8
  parameter :name, :default => :provision
9
+ parameter :argument_names, :default => []
8
10
 
9
11
  parameter :configuration_name, :required => true
10
12
  parameter :configuration_directory, :required => true
@@ -33,18 +35,25 @@ module RakeTerraform
33
35
  end
34
36
 
35
37
  desc "Provision #{configuration_name} using terraform"
36
- task name => [ensure_task] do
37
- apply_vars = vars.respond_to?(:call) ?
38
- vars.call(
39
- configuration_name: configuration_name,
40
- configuration_directory: configuration_directory,
41
- backend: backend,
42
- backend_config: backend_config,
43
- state_file: state_file,
44
- no_color: no_color,
45
- no_backup: no_backup,
46
- backup_file: backup_file) :
38
+ task name, argument_names => [ensure_task] do |_, args|
39
+ params = OpenStruct.new({
40
+ configuration_name: configuration_name,
41
+ configuration_directory: configuration_directory,
42
+ backend: backend,
43
+ backend_config: backend_config,
44
+ state_file: state_file,
45
+ no_color: no_color,
46
+ no_backup: no_backup,
47
+ backup_file: backup_file
48
+ })
49
+
50
+ derived_vars = vars.respond_to?(:call) ?
51
+ vars.call(*[args, params].slice(0, vars.arity)) :
47
52
  vars
53
+ derived_backend_config = backend_config.respond_to?(:call) ?
54
+ backend_config.call(
55
+ *[args, params].slice(0, backend_config.arity)) :
56
+ backend_config
48
57
 
49
58
  puts "Provisioning #{configuration_name}"
50
59
 
@@ -56,7 +65,7 @@ module RakeTerraform
56
65
  RubyTerraform.remote_config(
57
66
  no_color: no_color,
58
67
  backend: backend,
59
- backend_config: backend_config)
68
+ backend_config: derived_backend_config)
60
69
  end
61
70
  RubyTerraform.apply(
62
71
  no_color: no_color,
@@ -64,7 +73,7 @@ module RakeTerraform
64
73
  backup: backup_file,
65
74
  directory: configuration_directory,
66
75
  state: state_file,
67
- vars: apply_vars)
76
+ vars: derived_vars)
68
77
  end
69
78
  end
70
79
  end
@@ -1,3 +1,3 @@
1
1
  module RakeTerraform
2
- VERSION = "0.5.0"
2
+ VERSION = "0.6.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rake_terraform
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toby Clemson