rake_terraform 0.7.0 → 0.8.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: a81fd1d519598c03f5b2368cf7768ebc80aa2c45
4
- data.tar.gz: d8116458a1b30a3bdf7b5e3023ad34d7407acef3
3
+ metadata.gz: 49f64a19258530d7b83183db8c801c6ca9a429fe
4
+ data.tar.gz: 7e7670a2b688257ad4df32ad2ed7441985936241
5
5
  SHA512:
6
- metadata.gz: 57d064d02f385802aebd5e41d064c6a6265cfef9fcb7c33241d3a473ee945b50506736d510f95b2cf4a32575e0f84b0c1a5b6d858bf501ba40873bc182e7f52b
7
- data.tar.gz: eae63c886e9e8ffd98c7e44dfbf938fa2e51b6001bf976c670012475dbfab3cc4a036471028916c437bf20730e1a4614430e8d95b497220f9ae8ee5da183a40a
6
+ metadata.gz: 3e2affe61d5a6e77f7ed4dad4b4a91b46b1d65c07a3ef21771e4113694b93c73d3c3565c073e4caa5a0d2b8800c7a9f723dd5a4dd0dad654ac9e45093cbe4b38
7
+ data.tar.gz: a49b8333cb57e9cc19b786918e244443956d5860cf5c19409e030b590876cbc270cb1f25e89c13084603d795efdd2e8b1bbc0065bcf7831142faac78caad2750
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rake_terraform (0.7.0)
4
+ rake_terraform (0.8.0)
5
5
  rake_dependencies (~> 0.15)
6
- ruby-terraform (~> 0.4)
6
+ ruby-terraform (~> 0.5)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
@@ -46,7 +46,7 @@ GEM
46
46
  diff-lcs (>= 1.2.0, < 2.0)
47
47
  rspec-support (~> 3.5.0)
48
48
  rspec-support (3.5.0)
49
- ruby-terraform (0.4.0)
49
+ ruby-terraform (0.5.0)
50
50
  lino (~> 1.1)
51
51
  rubyzip (1.2.1)
52
52
  thread_safe (0.3.5)
@@ -1,3 +1,4 @@
1
+ require_relative 'tasks/plan'
1
2
  require_relative 'tasks/provision'
2
3
  require_relative 'tasks/destroy'
3
4
  require_relative 'tasks/all'
@@ -14,11 +14,15 @@ module RakeTerraform
14
14
  parameter :no_backup, :default => false
15
15
 
16
16
  parameter :backup_file
17
+ parameter :plan_file
17
18
 
18
19
  parameter :argument_names
19
20
 
20
21
  parameter :ensure_task, :default => :'terraform:ensure'
21
22
 
23
+ parameter :plan_task_name, :default => :plan
24
+ parameter :plan_argument_names
25
+
22
26
  parameter :provision_task_name, :default => :provision
23
27
  parameter :provision_argument_names
24
28
 
@@ -26,6 +30,25 @@ module RakeTerraform
26
30
  parameter :destroy_argument_names
27
31
 
28
32
  def define
33
+ Plan.new do |t|
34
+ t.name = plan_task_name
35
+ t.argument_names = plan_argument_names || argument_names || []
36
+
37
+ t.configuration_name = configuration_name
38
+ t.configuration_directory = configuration_directory
39
+
40
+ t.backend = backend
41
+ t.backend_config = backend_config
42
+
43
+ t.vars = vars
44
+ t.state_file = state_file
45
+
46
+ t.no_color = no_color
47
+
48
+ t.plan_file = plan_file
49
+
50
+ t.ensure_task = ensure_task
51
+ end
29
52
  Provision.new do |t|
30
53
  t.name = provision_task_name
31
54
  t.argument_names = provision_argument_names || argument_names || []
@@ -0,0 +1,79 @@
1
+ require 'ruby_terraform'
2
+ require 'ostruct'
3
+ require_relative '../tasklib'
4
+
5
+ module RakeTerraform
6
+ module Tasks
7
+ class Plan < TaskLib
8
+ parameter :name, :default => :plan
9
+ parameter :argument_names, :default => []
10
+
11
+ parameter :configuration_name, :required => true
12
+ parameter :configuration_directory, :required => true
13
+
14
+ parameter :backend
15
+ parameter :backend_config
16
+
17
+ parameter :vars, default: {}
18
+ parameter :state_file
19
+
20
+ parameter :no_color, :default => false
21
+
22
+ parameter :plan_file
23
+ parameter :destroy, :default => false
24
+
25
+ parameter :ensure_task, :default => :'terraform:ensure'
26
+
27
+ def process_arguments(args)
28
+ self.name = args[0] if args[0]
29
+ end
30
+
31
+ def define
32
+ if backend && state_file
33
+ raise ArgumentError.new(
34
+ "Only one of 'state_file' and 'backend' can be provided.")
35
+ end
36
+
37
+ desc "Plan #{configuration_name} using terraform"
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
+ })
47
+
48
+ derived_vars = vars.respond_to?(:call) ?
49
+ vars.call(*[args, params].slice(0, vars.arity)) :
50
+ vars
51
+ derived_backend_config = backend_config.respond_to?(:call) ?
52
+ backend_config.call(
53
+ *[args, params].slice(0, backend_config.arity)) :
54
+ backend_config
55
+
56
+ puts "Planning #{configuration_name}"
57
+
58
+ RubyTerraform.clean
59
+ RubyTerraform.get(
60
+ directory: configuration_directory,
61
+ no_color: no_color)
62
+ if backend
63
+ RubyTerraform.remote_config(
64
+ no_color: no_color,
65
+ backend: backend,
66
+ backend_config: derived_backend_config)
67
+ end
68
+ RubyTerraform.plan(
69
+ no_color: no_color,
70
+ destroy: destroy,
71
+ directory: configuration_directory,
72
+ state: state_file,
73
+ plan: plan_file,
74
+ vars: derived_vars)
75
+ end
76
+ end
77
+ end
78
+ end
79
+ end
@@ -1,3 +1,3 @@
1
1
  module RakeTerraform
2
- VERSION = "0.7.0"
2
+ VERSION = "0.8.0"
3
3
  end
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.require_paths = ['lib']
23
23
 
24
24
  spec.add_dependency 'rake_dependencies', '~> 0.15'
25
- spec.add_dependency 'ruby-terraform', '~> 0.4'
25
+ spec.add_dependency 'ruby-terraform', '~> 0.5'
26
26
 
27
27
  spec.add_development_dependency 'bundler', '~> 1.14'
28
28
  spec.add_development_dependency 'rake', '~> 11.0'
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.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Toby Clemson
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - ~>
32
32
  - !ruby/object:Gem::Version
33
- version: '0.4'
33
+ version: '0.5'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ~>
39
39
  - !ruby/object:Gem::Version
40
- version: '0.4'
40
+ version: '0.5'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -147,6 +147,7 @@ files:
147
147
  - lib/rake_terraform/tasks.rb
148
148
  - lib/rake_terraform/tasks/all.rb
149
149
  - lib/rake_terraform/tasks/destroy.rb
150
+ - lib/rake_terraform/tasks/plan.rb
150
151
  - lib/rake_terraform/tasks/provision.rb
151
152
  - lib/rake_terraform/version.rb
152
153
  - rake_terraform.gemspec