terraform-wrapper 1.3.0 → 1.3.2

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
  SHA256:
3
- metadata.gz: 91c97704433138c53e6e8c487ddc8ac55aaa08eafcd243be20c88009f3bc0ef8
4
- data.tar.gz: 4e912bdd6cf103be7f78067a99c24f87fd26f7f213fc18a61e9a636d82679fd1
3
+ metadata.gz: 0be894eaa86b7493c61971a31851c37cff0f34083c74d4341c83ff4c0e3e851f
4
+ data.tar.gz: 64670c333712e79c96ad88701b746937b5e2f1197e1c8e3c23221106ac6bc82d
5
5
  SHA512:
6
- metadata.gz: 819de26eca1f26340305bff23097d55ca9983aed1f99ab7006fa8b57d770d62628740a43f6af80025e3bf2d3b64c345e14f4bf587a957a2e42b11d1e46007b3e
7
- data.tar.gz: 2ce0e456878d5ca3e77d5460d885cf092582b3d1b8405b6f44056c5f6c2e04b67d6ae43190823376dd3b2bd55ff7bc37d38b988f4e94acd4e5ea3a91b41e697e
6
+ metadata.gz: 509c3ec3deaafc95f8d511f60568e454bc1a0317bfc40abdbe1603a9edaebf590da5261dc0ce779c05e56ad6f7d05b44cb3f2297765eae324b510d1b58320518
7
+ data.tar.gz: e437dd53cad70112cb681da581d6d074808df723f8fb27905b0ccd529204e12e200dc71511c86e332e6561221d394edf2ae831243f0893e3ff46f55b33e6f438
data/Gemfile CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  ###############################################################################
6
6
 
7
- source "https://rubygems.org"
7
+ source 'https://rubygems.org'
8
8
 
9
9
  ###############################################################################
10
10
 
data/Rakefile CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  ###############################################################################
6
6
 
7
- require "bundler/gem_tasks"
7
+ require 'bundler/gem_tasks'
8
8
 
9
9
  ###############################################################################
10
10
 
@@ -13,7 +13,7 @@ task default: %i[]
13
13
  ###############################################################################
14
14
 
15
15
  begin
16
- require "rspec/core/rake_task"
16
+ require 'rspec/core/rake_task'
17
17
  RSpec::Core::RakeTask.new(:spec)
18
18
  rescue LoadError
19
19
  end
@@ -1,108 +1,109 @@
1
1
  ###############################################################################
2
2
 
3
3
  module TerraformWrapper
4
-
5
- ###############################################################################
4
+ ###############################################################################
6
5
 
7
6
  module Shared
8
-
9
- ###############################################################################
7
+ ###############################################################################
10
8
 
11
9
  module Backends
12
-
13
- ###############################################################################
10
+ ###############################################################################
14
11
 
15
12
  class AWS < Common
16
-
17
- ###############################################################################
13
+ ###############################################################################
18
14
 
19
15
  include TerraformWrapper::Shared::Logging
20
16
 
21
- ###############################################################################
17
+ ###############################################################################
22
18
 
23
- @@default_class = "terraform-state"
19
+ @@default_class = 'terraform-state'
24
20
 
25
- ###############################################################################
21
+ ###############################################################################
26
22
 
27
- @@type = "aws"
23
+ @@type = 'aws'
28
24
 
29
- ###############################################################################
25
+ ###############################################################################
30
26
 
31
- attr_reader :bucket
32
- attr_reader :encrypt
33
- attr_reader :key
34
- attr_reader :region
27
+ attr_reader :bucket, :encrypt, :key, :region
35
28
 
36
- ###############################################################################
29
+ ###############################################################################
37
30
 
38
31
  def initialize(options:, variables:)
39
32
  construct(options: options, variables: variables)
40
33
  end
41
34
 
42
- ###############################################################################
35
+ ###############################################################################
43
36
 
44
- def hash()
45
- result = Hash.new
37
+ def hash
38
+ result = {}
46
39
 
47
- result["bucket"] = @bucket
48
- result["region"] = @region
49
- result["key"] = @key
50
- result["encrypt"] = @encrypt.to_s
40
+ result['bucket'] = @bucket
41
+ result['region'] = @region
42
+ result['key'] = @key
43
+ result['encrypt'] = @encrypt.to_s
51
44
 
52
- result["kms_key_id"] = @kms unless @kms.nil?
53
- result["role_arn"] = @role unless @role.nil?
45
+ result['kms_key_id'] = @kms unless @kms.nil?
46
+ result['role_arn'] = @role unless @role.nil?
54
47
 
55
- return result
48
+ result
56
49
  end
57
50
 
58
- ###############################################################################
51
+ ###############################################################################
59
52
 
60
53
  private
61
54
 
62
- ###############################################################################
55
+ ###############################################################################
63
56
 
64
- def specific()
57
+ def specific
65
58
  kms = nil
66
59
  role = nil
67
60
 
68
- logger.fatal("AWS backend mandatory option 'bucket' has not been set!") unless @options.key?("bucket")
69
- logger.fatal("AWS backend mandatory option 'region' has not been set!") unless @options.key?("region")
61
+ logger.fatal("AWS backend mandatory option 'bucket' has not been set!") unless @options.key?('bucket')
62
+ logger.fatal("AWS backend mandatory option 'region' has not been set!") unless @options.key?('region')
70
63
 
71
- bucket = @options["bucket"]
64
+ bucket = @options['bucket']
72
65
 
73
- logger.fatal("AWS backend S3 bucket name must be a string!") unless bucket.kind_of?(String)
74
- logger.fatal("AWS backend S3 bucket name must not be blank!") if bucket.strip.empty?
66
+ logger.fatal('AWS backend S3 bucket name must be a string!') unless bucket.is_a?(String)
67
+ logger.fatal('AWS backend S3 bucket name must not be blank!') if bucket.strip.empty?
75
68
 
76
- region = @options["region"]
69
+ region = @options['region']
77
70
 
78
- logger.fatal("AWS backend S3 bucket region must be a string!") unless region.kind_of?(String)
79
- logger.fatal("AWS backend S3 bucket region must not be blank!") if region.strip.empty?
71
+ logger.fatal('AWS backend S3 bucket region must be a string!') unless region.is_a?(String)
72
+ logger.fatal('AWS backend S3 bucket region must not be blank!') if region.strip.empty?
80
73
 
81
- key = @options.key?("key") ? @options["key"] : File.join("%{service}", "%{config}", "%{component}" + @@ext)
74
+ key = @options.key?('key') ? @options['key'] : File.join('%<service>s', '%<config>s', "%<component>s#{@@ext}")
82
75
 
83
- logger.fatal("AWS backend S3 bucket key must be a string!") unless key.kind_of?(String)
84
- logger.fatal("AWS backend S3 bucket key must not be blank!") if key.strip.empty?
76
+ logger.fatal('AWS backend S3 bucket key must be a string!') unless key.is_a?(String)
77
+ logger.fatal('AWS backend S3 bucket key must not be blank!') if key.strip.empty?
85
78
 
86
- encrypt = @options.key?("encrypt") ? @options["encrypt"] : true
79
+ encrypt = @options.key?('encrypt') ? @options['encrypt'] : true
87
80
 
88
- logger.fatal("AWS backend S3 bucket encryption enabled must be a Boolean!") unless [ true, false ].include?(encrypt)
81
+ logger.fatal('AWS backend S3 bucket encryption enabled must be a Boolean!') unless [true,
82
+ false].include?(encrypt)
89
83
 
90
- if @options.key?("kms") then
91
- kms = @options["kms"]
84
+ if @options.key?('kms')
85
+ kms = @options['kms']
92
86
 
93
- logger.fatal("AWS backend S3 bucket encryption KMS key ARN must be a string if specified!") unless kms.kind_of?(String)
94
- logger.fatal("AWS backend S3 bucket encryption KMS key ARN must not be blank if specified!") if kms.strip.empty?
87
+ unless kms.is_a?(String)
88
+ logger.fatal('AWS backend S3 bucket encryption KMS key ARN must be a string if specified!')
89
+ end
90
+ if kms.strip.empty?
91
+ logger.fatal('AWS backend S3 bucket encryption KMS key ARN must not be blank if specified!')
92
+ end
95
93
  end
96
94
 
97
- if @options.key?("role") then
98
- role = @options["role"]
95
+ if @options.key?('role')
96
+ role = @options['role']
99
97
 
100
- logger.fatal("AWS backend role to assume ARN must be a string if specified!") unless role.kind_of?(String)
101
- logger.fatal("AWS backend role to assume ARN must not be blank if specified!") if role.strip.empty?
98
+ logger.fatal('AWS backend role to assume ARN must be a string if specified!') unless role.is_a?(String)
99
+ logger.fatal('AWS backend role to assume ARN must not be blank if specified!') if role.strip.empty?
102
100
  end
103
101
 
104
- @variables.core.keys.map{ |sym| sym.to_s }.each do |core|
105
- logger.fatal("AWS backend S3 bucket name or key must include %{#{core}}.") unless (bucket.include?("%{#{core}}") or key.include?("%{#{core}}"))
102
+ @variables.core.keys.map { |sym| sym.to_s }.each do |core|
103
+ unless bucket.include?("%<#{core}>s") || key.include?("%<#{core}>s") ||
104
+ bucket.include?("%{#{core}}") || key.include?("%{#{core}}")
105
+ logger.fatal("AWS backend S3 bucket name or key must include %<#{core}>s.")
106
+ end
106
107
  end
107
108
 
108
109
  begin
@@ -111,8 +112,8 @@ module TerraformWrapper
111
112
  key = key % @variables.identifiers
112
113
  kms = kms % @variables.identifiers unless kms.nil?
113
114
  role = role % @variables.identifiers unless role.nil?
114
- rescue
115
- logger.fatal("AWS backend options contain identifiers that are not included in the configuration file!")
115
+ rescue StandardError
116
+ logger.fatal('AWS backend options contain identifiers that are not included in the configuration file!')
116
117
  end
117
118
 
118
119
  logger.fatal("Key: #{key} is too long for backend of type: #{@@type}") if key.length > 1024
@@ -125,20 +126,16 @@ module TerraformWrapper
125
126
  @role = role
126
127
  end
127
128
 
128
- ###############################################################################
129
-
129
+ ###############################################################################
130
130
  end
131
131
 
132
- ###############################################################################
133
-
132
+ ###############################################################################
134
133
  end
135
134
 
136
- ###############################################################################
137
-
135
+ ###############################################################################
138
136
  end
139
137
 
140
- ###############################################################################
141
-
138
+ ###############################################################################
142
139
  end
143
140
 
144
141
  ###############################################################################
@@ -1,82 +1,78 @@
1
1
  ###############################################################################
2
2
 
3
3
  module TerraformWrapper
4
-
5
- ###############################################################################
4
+ ###############################################################################
6
5
 
7
6
  module Shared
8
-
9
- ###############################################################################
7
+ ###############################################################################
10
8
 
11
9
  module Backends
12
-
13
- ###############################################################################
10
+ ###############################################################################
14
11
 
15
12
  class Azure < Common
16
-
17
- ###############################################################################
13
+ ###############################################################################
18
14
 
19
15
  include TerraformWrapper::Shared::Logging
20
16
 
21
- ###############################################################################
17
+ ###############################################################################
22
18
 
23
- @@type = "azure"
19
+ @@type = 'azure'
24
20
 
25
- ###############################################################################
21
+ ###############################################################################
26
22
 
27
- attr_reader :account
28
- attr_reader :container
29
- attr_reader :group
30
- attr_reader :key
23
+ attr_reader :account, :container, :group, :key
31
24
 
32
- ###############################################################################
25
+ ###############################################################################
33
26
 
34
27
  def initialize(options:, variables:)
35
28
  construct(options: options, variables: variables)
36
29
  end
37
30
 
38
- ###############################################################################
31
+ ###############################################################################
39
32
 
40
- def hash()
41
- return {
42
- "container_name" => @container,
43
- "key" => @key,
44
- "resource_group_name" => @group,
45
- "storage_account_name" => @account
33
+ def hash
34
+ {
35
+ 'container_name' => @container,
36
+ 'key' => @key,
37
+ 'resource_group_name' => @group,
38
+ 'storage_account_name' => @account
46
39
  }
47
40
  end
48
41
 
49
- ###############################################################################
42
+ ###############################################################################
50
43
 
51
44
  private
52
45
 
53
- ###############################################################################
46
+ ###############################################################################
54
47
 
55
- def specific()
56
- logger.fatal("Azure backend mandatory option 'group' has not been set!") unless @options.key?("group")
48
+ def specific
49
+ logger.fatal("Azure backend mandatory option 'group' has not been set!") unless @options.key?('group')
57
50
 
58
- group = @options["group"]
51
+ group = @options['group']
59
52
 
60
- logger.fatal("Azure backend group must be a string!") unless group.kind_of?(String)
61
- logger.fatal("Azure backend group must not be blank!") if group.strip.empty?
53
+ logger.fatal('Azure backend group must be a string!') unless group.is_a?(String)
54
+ logger.fatal('Azure backend group must not be blank!') if group.strip.empty?
62
55
 
63
- account = @options.key?("account") ? @options["account"] : group + "tf"
56
+ account = @options.key?('account') ? @options['account'] : group + 'tf'
64
57
 
65
- logger.fatal("Azure backend storage account must be a string!") unless account.kind_of?(String)
66
- logger.fatal("Azure backend storage account must not be blank!") if account.strip.empty?
58
+ logger.fatal('Azure backend storage account must be a string!') unless account.is_a?(String)
59
+ logger.fatal('Azure backend storage account must not be blank!') if account.strip.empty?
67
60
 
68
- container = @options.key?("container") ? @options["container"] : "default"
61
+ container = @options.key?('container') ? @options['container'] : 'default'
69
62
 
70
- logger.fatal("Azure backend storage account container must be a string!") unless container.kind_of?(String)
71
- logger.fatal("Azure backend storage account container must not be blank!") if container.strip.empty?
63
+ logger.fatal('Azure backend storage account container must be a string!') unless container.is_a?(String)
64
+ logger.fatal('Azure backend storage account container must not be blank!') if container.strip.empty?
72
65
 
73
- key = @options.key?("key") ? @options["key"] : File.join("%{service}", "%{config}", "%{component}" + @@ext)
66
+ key = @options.key?('key') ? @options['key'] : File.join('%<service>s', '%<config>s', "%<component>s#{@@ext}")
74
67
 
75
- logger.fatal("Azure backend storage account key must be a string!") unless key.kind_of?(String)
76
- logger.fatal("Azure backend storage account key must not be blank!") if key.strip.empty?
68
+ logger.fatal('Azure backend storage account key must be a string!') unless key.is_a?(String)
69
+ logger.fatal('Azure backend storage account key must not be blank!') if key.strip.empty?
77
70
 
78
- @variables.core.keys.map{ |sym| sym.to_s }.each do |core|
79
- logger.fatal("Azure backend container or key must include %{#{core}}.") unless (container.include?("%{#{core}}") or key.include?("%{#{core}}"))
71
+ @variables.core.keys.map { |sym| sym.to_s }.each do |core|
72
+ unless container.include?("%<#{core}>s") || key.include?("%<#{core}>s") ||
73
+ container.include?("%{#{core}}") || key.include?("%{#{core}}")
74
+ logger.fatal("Azure backend container or key must include %<#{core}>s.")
75
+ end
80
76
  end
81
77
 
82
78
  begin
@@ -84,14 +80,14 @@ module TerraformWrapper
84
80
  account = account % @variables.identifiers
85
81
  container = container % @variables.identifiers
86
82
  key = key % @variables.identifiers
87
- rescue
88
- logger.fatal("Azure backend options contain identifiers that are not included in the configuration file!")
83
+ rescue StandardError
84
+ logger.fatal('Azure backend options contain identifiers that are not included in the configuration file!')
89
85
  end
90
86
 
91
- if key.length > 1024 then
87
+ if key.length > 1024
92
88
  logger.fatal("Key: #{key} is too long for backend of type: #{@@type}")
93
- else
94
- logger.warn("Key for backend of type: #{@@type} exceeds 256 characters. This will not work with the Azure Storage Emulator. If key is not being overriden, consider using less identifiers.") if key.length > 256
89
+ elsif key.length > 256
90
+ logger.warn("Key for backend of type: #{@@type} exceeds 256 characters. This will not work with the Azure Storage Emulator. If key is not being overriden, consider using less identifiers.")
95
91
  end
96
92
 
97
93
  @group = group
@@ -100,20 +96,16 @@ module TerraformWrapper
100
96
  @key = key
101
97
  end
102
98
 
103
- ###############################################################################
104
-
99
+ ###############################################################################
105
100
  end
106
101
 
107
- ###############################################################################
108
-
102
+ ###############################################################################
109
103
  end
110
104
 
111
- ###############################################################################
112
-
105
+ ###############################################################################
113
106
  end
114
107
 
115
- ###############################################################################
116
-
108
+ ###############################################################################
117
109
  end
118
110
 
119
111
  ###############################################################################
@@ -1,58 +1,56 @@
1
1
  ###############################################################################
2
2
 
3
3
  module TerraformWrapper
4
-
5
- ###############################################################################
4
+ ###############################################################################
6
5
 
7
6
  module Shared
8
-
9
- ###############################################################################
7
+ ###############################################################################
10
8
 
11
9
  module Backends
12
-
13
- ###############################################################################
10
+ ###############################################################################
14
11
 
15
12
  class Common
16
-
17
- ###############################################################################
13
+ ###############################################################################
18
14
 
19
15
  include TerraformWrapper::Shared::Logging
20
16
 
21
- ###############################################################################
17
+ ###############################################################################
22
18
 
23
- @@ext = ".tfstate"
19
+ @@ext = '.tfstate'
24
20
  @@type
25
21
 
26
- ###############################################################################
22
+ ###############################################################################
27
23
 
28
24
  @options
29
25
  @variables
30
26
 
31
- ###############################################################################
27
+ ###############################################################################
32
28
 
33
29
  def initialize(options:, variables:)
34
- logger.fatal("This class should not be used directly! Please create a backend-specific class instead!")
30
+ logger.fatal('This class should not be used directly! Please create a backend-specific class instead!')
35
31
  end
36
32
 
37
- ###############################################################################
33
+ ###############################################################################
38
34
 
39
- def hash()
35
+ def hash
40
36
  logger.fatal("The backend specific class should override the 'hash' method to return a hash of parameters for Terraform to set!")
41
37
  end
42
38
 
43
- ###############################################################################
39
+ ###############################################################################
44
40
 
45
- def type()
46
- logger.fatal("The backend specific class should set the 'type' class variable to a string!") unless @@type.kind_of?(String)
41
+ def type
42
+ unless @@type.is_a?(String)
43
+ logger.fatal("The backend specific class should set the 'type' class variable to a string!")
44
+ end
47
45
 
48
- return @@type
46
+ @@type
49
47
  end
50
48
 
51
- ###############################################################################
49
+ ###############################################################################
52
50
 
53
51
  private
54
52
 
55
- ###############################################################################
53
+ ###############################################################################
56
54
 
57
55
  def construct(options:, variables:)
58
56
  @options = options
@@ -61,26 +59,22 @@ module TerraformWrapper
61
59
  specific
62
60
  end
63
61
 
64
- ###############################################################################
62
+ ###############################################################################
65
63
 
66
- def specific()
64
+ def specific
67
65
  logger.fatal("The backend specific class should override the 'specific' method to include backend specific validation and setup, or simply return 'true' if it is not required.")
68
66
  end
69
67
 
70
- ###############################################################################
71
-
68
+ ###############################################################################
72
69
  end
73
70
 
74
- ###############################################################################
75
-
71
+ ###############################################################################
76
72
  end
77
73
 
78
- ###############################################################################
79
-
74
+ ###############################################################################
80
75
  end
81
76
 
82
- ###############################################################################
83
-
77
+ ###############################################################################
84
78
  end
85
79
 
86
80
  ###############################################################################
@@ -1,89 +1,91 @@
1
1
  ###############################################################################
2
2
 
3
3
  module TerraformWrapper
4
-
5
- ###############################################################################
4
+ ###############################################################################
6
5
 
7
6
  module Shared
8
-
9
- ###############################################################################
7
+ ###############################################################################
10
8
 
11
9
  module Backends
12
-
13
- ###############################################################################
10
+ ###############################################################################
14
11
 
15
12
  class Local < Common
16
-
17
- ###############################################################################
13
+ ###############################################################################
18
14
 
19
15
  include TerraformWrapper::Shared::Logging
20
16
 
21
- ###############################################################################
17
+ ###############################################################################
22
18
 
23
- @@type = "local"
19
+ @@type = 'local'
24
20
 
25
- ###############################################################################
21
+ ###############################################################################
26
22
 
27
23
  attr_reader :path
28
24
 
29
- ###############################################################################
25
+ ###############################################################################
30
26
 
31
27
  def initialize(options:, variables:)
32
28
  construct(options: options, variables: variables)
33
29
  end
34
30
 
35
- ###############################################################################
31
+ ###############################################################################
36
32
 
37
- def hash()
38
- return {
39
- "path" => @path
33
+ def hash
34
+ {
35
+ 'path' => @path
40
36
  }
41
37
  end
42
38
 
43
- ###############################################################################
39
+ ###############################################################################
44
40
 
45
41
  private
46
42
 
47
- ###############################################################################
43
+ ###############################################################################
44
+
45
+ def specific
46
+ path = if @options.key?('path')
47
+ @options['path']
48
+ else
49
+ File.join(Dir.pwd, 'state', 'terraform', '%<config>s',
50
+ "%<component>s#{@@ext}")
51
+ end
48
52
 
49
- def specific()
50
- path = @options.key?("path") ? @options["path"] : File.join(Dir.pwd, "state", "terraform", "%{config}", "%{component}" + @@ext)
53
+ logger.fatal('Local backend path must be a string!') unless path.is_a?(String)
54
+ logger.fatal('Local backend path must not be blank!') if path.strip.empty?
51
55
 
52
- logger.fatal("Local backend path must be a string!") unless path.kind_of?(String)
53
- logger.fatal("Local backend path must not be blank!") if path.strip.empty?
56
+ @variables.core.keys.map { |sym| sym.to_s }.each do |core|
57
+ next if (core == 'service') && path.include?(Dir.pwd)
54
58
 
55
- @variables.core.keys.map{ |sym| sym.to_s }.each do |core|
56
- next if (core == "service") and (path.include?(Dir.pwd))
57
- logger.fatal("Local backend path must include %{#{core}}.") unless path.include?("%{#{core}}")
59
+ unless path.include?("%<#{core}>s") || path.include?("%{#{core}}")
60
+ logger.fatal("Local backend path must include %<#{core}>s.")
61
+ end
58
62
  end
59
63
 
60
64
  begin
61
65
  path = path % @variables.identifiers
62
- rescue
63
- logger.fatal("Local backend options contain identifiers that are not included in the configuration file!")
66
+ rescue StandardError
67
+ logger.fatal('Local backend options contain identifiers that are not included in the configuration file!')
64
68
  end
65
69
 
66
70
  directory = File.dirname(path)
67
71
 
68
- logger.fatal("Failed to create state directory: #{directory}") unless ::TerraformWrapper.create_directory(directory: directory, purpose: "state")
72
+ logger.fatal("Failed to create state directory: #{directory}") unless ::TerraformWrapper.create_directory(
73
+ directory: directory, purpose: 'state'
74
+ )
69
75
 
70
76
  @path = path
71
77
  end
72
78
 
73
- ###############################################################################
74
-
79
+ ###############################################################################
75
80
  end
76
81
 
77
- ###############################################################################
78
-
82
+ ###############################################################################
79
83
  end
80
84
 
81
- ###############################################################################
82
-
85
+ ###############################################################################
83
86
  end
84
87
 
85
- ###############################################################################
86
-
88
+ ###############################################################################
87
89
  end
88
90
 
89
91
  ###############################################################################
@@ -1,13 +1,11 @@
1
1
  ###############################################################################
2
2
 
3
3
  module TerraformWrapper
4
+ ###############################################################################
4
5
 
5
- ###############################################################################
6
-
7
- VERSION = "1.3.0"
8
-
9
- ###############################################################################
6
+ VERSION = '1.3.2'
10
7
 
8
+ ###############################################################################
11
9
  end
12
10
 
13
11
  ###############################################################################
@@ -11,46 +11,52 @@ require_relative 'terraform-wrapper/common'
11
11
  ###############################################################################
12
12
 
13
13
  module TerraformWrapper
14
+ ###############################################################################
14
15
 
15
- ###############################################################################
16
-
17
- @logger = TerraformWrapper::Shared::Logging.logger_for("TerraformWrapper")
16
+ @logger = TerraformWrapper::Shared::Logging.logger_for('TerraformWrapper')
18
17
 
19
- ###############################################################################
18
+ ###############################################################################
20
19
 
21
20
  @logger.info("Terraform Wrapper for Ruby - version: #{TerraformWrapper::VERSION}")
22
21
 
23
- ###############################################################################
22
+ ###############################################################################
24
23
 
25
- def self.deployment_tasks(component:, options: Hash.new, service:)
24
+ def self.deployment_tasks(component:, service:, options: {})
26
25
  @logger.info("Building tasks for service: #{service}, component: #{component}...")
27
26
 
28
- @logger.fatal("Options must be specified as a hash!") unless options.kind_of?(Hash)
29
-
30
- binary_options = Hash.new
31
- binary_options["base"] = options.key?("binary-base") ? options["binary-base"] : File.join(Dir.pwd, "vendor", "terraform")
32
- binary_options["version"] = options.key?("binary-version") ? options["binary-version"] : Shared::Latest.instance.version
33
-
34
- code_options = Hash.new
35
- code_options["base"] = options.key?("code-base") ? options["code-base"] : File.join(Dir.pwd, "terraform")
36
- code_options["name"] = component
37
-
38
- config_options = Hash.new
39
- config_options["auth-azure"] = options.key?("config-auth-azure") ? options["config-auth-azure"] : false
40
- config_options["auth-azure-options"] = options.key?("config-auth-azure-options") ? options["config-auth-azure-options"] : Hash.new
41
- config_options["base"] = options.key?("config-base") ? options["config-base"] : File.join(Dir.pwd, "config")
42
- config_options["backend"] = options.key?("config-backend") ? options["config-backend"] : "local"
43
- config_options["backend-options"] = options.key?("config-backend-options") ? options["config-backend-options"] : Hash.new
44
- config_options["service"] = service
45
-
46
- provider_options = Hash.new
47
- provider_options["platforms"] = options.key?("provider-platforms") ? options["provider-platforms"] : Array.new
27
+ @logger.fatal('Options must be specified as a hash!') unless options.is_a?(Hash)
28
+
29
+ binary_options = {}
30
+ binary_options['base'] =
31
+ options.key?('binary-base') ? options['binary-base'] : File.join(Dir.pwd, 'vendor', 'terraform')
32
+ binary_options['version'] =
33
+ options.key?('binary-version') ? options['binary-version'] : Shared::Latest.instance.version
34
+
35
+ code_options = {}
36
+ code_options['base'] = options.key?('code-base') ? options['code-base'] : File.join(Dir.pwd, 'terraform')
37
+ code_options['name'] = component
38
+
39
+ config_options = {}
40
+ config_options['auth-azure'] =
41
+ options.key?('config-auth-azure') ? options['config-auth-azure'] : false
42
+ config_options['auth-azure-options'] =
43
+ options.key?('config-auth-azure-options') ? options['config-auth-azure-options'] : {}
44
+ config_options['base'] =
45
+ options.key?('config-base') ? options['config-base'] : File.join(Dir.pwd, 'config')
46
+ config_options['backend'] =
47
+ options.key?('config-backend') ? options['config-backend'] : 'local'
48
+ config_options['backend-options'] =
49
+ options.key?('config-backend-options') ? options['config-backend-options'] : {}
50
+ config_options['service'] = service
51
+
52
+ provider_options = {}
53
+ provider_options['platforms'] = options.key?('provider-platforms') ? options['provider-platforms'] : []
48
54
 
49
55
  provider = TerraformWrapper::Shared::Provider.new(options: provider_options)
50
56
  binary = TerraformWrapper::Shared::Binary.new(options: binary_options, provider: provider)
51
57
  code = TerraformWrapper::Shared::Code.new(options: code_options)
52
58
 
53
- tasks = Array.new
59
+ tasks = []
54
60
  tasks << TerraformWrapper::Tasks::Apply.new(binary: binary, code: code, options: config_options)
55
61
  tasks << TerraformWrapper::Tasks::Binary.new(binary: binary)
56
62
  tasks << TerraformWrapper::Tasks::Clean.new(code: code)
@@ -62,11 +68,10 @@ module TerraformWrapper
62
68
  tasks << TerraformWrapper::Tasks::Taint.new(binary: binary, code: code, options: config_options)
63
69
  tasks << TerraformWrapper::Tasks::Upgrade.new(binary: binary, code: code)
64
70
  tasks << TerraformWrapper::Tasks::Validate.new(binary: binary, code: code)
65
- return tasks
71
+ tasks
66
72
  end
67
73
 
68
- ###############################################################################
69
-
74
+ ###############################################################################
70
75
  end
71
76
 
72
77
  ###############################################################################
@@ -4,33 +4,35 @@
4
4
 
5
5
  ###############################################################################
6
6
 
7
- require_relative "lib/terraform-wrapper/version"
7
+ require_relative 'lib/terraform-wrapper/version'
8
8
 
9
9
  ###############################################################################
10
10
 
11
11
  Gem::Specification.new do |spec|
12
- spec.name = "terraform-wrapper"
12
+ spec.name = 'terraform-wrapper'
13
13
  spec.version = TerraformWrapper::VERSION
14
- spec.authors = ["Richard Lees"]
15
- spec.email = ["git0@bitservices.io"]
14
+ spec.authors = ['Richard Lees']
15
+ spec.email = ['git0@bitservices.io']
16
16
 
17
- spec.summary = "A ruby wrapper for managing Terraform binaries and remote state."
18
- spec.description = "A ruby wrapper for managing Terraform binaries and remote state. Each Terraform command (plan, apply, etc) is wrapped so that the correct binary is used and remote state referenced."
19
- spec.homepage = "https://gitlab.com/bitservices/ruby/terraform-wrapper/"
20
- spec.license = "MIT"
17
+ spec.summary = 'A ruby wrapper for managing Terraform binaries and remote state.'
18
+ spec.description = 'A ruby wrapper for managing Terraform binaries and remote state. Each Terraform command (plan, apply, etc) is wrapped so that the correct binary is used and remote state referenced.'
19
+ spec.homepage = 'https://gitlab.com/bitservices/ruby/terraform-wrapper/'
20
+ spec.license = 'MIT'
21
21
 
22
- spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
22
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.6.0')
23
23
 
24
- spec.metadata["homepage_uri"] = spec.homepage
25
- spec.metadata["source_code_uri"] = spec.homepage
24
+ spec.metadata['homepage_uri'] = spec.homepage
25
+ spec.metadata['source_code_uri'] = spec.homepage
26
26
 
27
27
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
28
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:archlinux|test|spec|features)/}) or f.match(%r{\Aavatar(?:_group)?\.png\z}) }
28
+ `git ls-files -z`.split("\x0").reject do |f|
29
+ f.match(%r{\A(?:archlinux|test|spec|features)/}) or f.match(/\Aavatar(?:_group)?\.png\z/)
30
+ end
29
31
  end
30
32
 
31
- spec.bindir = "exe"
33
+ spec.bindir = 'exe'
32
34
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
33
- spec.require_paths = ["lib"]
35
+ spec.require_paths = ['lib']
34
36
 
35
37
  spec.add_dependency 'rake', '~> 13.0'
36
38
  spec.add_dependency 'rubyzip', '~> 2.3'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: terraform-wrapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Lees
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-07-08 00:00:00.000000000 Z
11
+ date: 2022-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -126,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
126
  - !ruby/object:Gem::Version
127
127
  version: '0'
128
128
  requirements: []
129
- rubygems_version: 3.3.7
129
+ rubygems_version: 3.3.26
130
130
  signing_key:
131
131
  specification_version: 4
132
132
  summary: A ruby wrapper for managing Terraform binaries and remote state.