terraform-wrapper 1.2.7 → 1.3.1

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: 6f5d1501a011dbf4424f148da0809664d95f3fe8c6bb6ab021b5c3b1c57d71d0
4
- data.tar.gz: 8d102af24e50ea63d057805f099e037c9b3821cb209dfdbcbc52f74506af3614
3
+ metadata.gz: '08f80aabab7ef1a6dbd14f0192ae4b9fabd8f4c648c79fb1d2af43b5dc566521'
4
+ data.tar.gz: 65b6fc7b2177c5ff46ea6f3c54cc01b871ec57af40667ca066f5c91ee3302002
5
5
  SHA512:
6
- metadata.gz: c1106d34527d215ad01722686b3516c57d68dbe4a4195cc1f89ccefc7f55f3ed587796eec6123356ec4315a0877fe27e328bab1e8e19bf659d43d7f14ddc7f95
7
- data.tar.gz: eb97a8a2a50ee21994344dadf3c2ec388779d25faa4eff8d2e1f40bf6bd592ab2e21e3e2b2cd290feae5669e5e3c87ee66eca09e40ed3d499e84d8c58e8f4d19
6
+ metadata.gz: d1facab7fdf808e52d099735f2d9411ed7c4b653ca89dbf7e394650ea805eac32f4eb90c14df67cf777d62fc77032e745d83a7aaa8924b205342365d402f711c
7
+ data.tar.gz: 5b54afa80939578ba88a577ac8b9abfa2c04973e51b8c4f9c11ba6248b2ddb63ef559f057764d357d21a1c19456afdfa8fb83288e67e024f056ac394c47c4c45
data/.gitignore CHANGED
@@ -21,8 +21,3 @@
21
21
  /tmp/
22
22
 
23
23
  ###############################################################################
24
-
25
- /archlinux/
26
- !/archlinux/PKGBUILD
27
-
28
- ###############################################################################
data/.gitlab-ci.yml CHANGED
@@ -1,37 +1,8 @@
1
1
  ###############################################################################
2
2
 
3
- image: ruby
4
-
5
- ###############################################################################
6
-
7
- stages:
8
- - test
9
- - publish
10
-
11
- ###############################################################################
12
-
13
- test:
14
- stage : test
15
- script:
16
- - echo "-- Beginning Test --"
17
- - echo "-- Tests not implemented yet --"
18
-
19
- ###############################################################################
20
-
21
- deploy:
22
- rules:
23
- - if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/'
24
- stage: publish
25
- script:
26
- - echo "-- Beginning Publish --"
27
- - test -n "${GEM_HOST_API_KEY}"
28
- - echo "RubyGems API key found!"
29
- - hash rake
30
- - hash ruby
31
- - hash gem
32
- - echo "-- Publishing Gem --"
33
- - rake release
34
- - echo "-- Listing Sums --"
35
- - sha256sum "pkg"/*.gem
3
+ include:
4
+ - project: 'bitservices/gitlab/ruby'
5
+ ref: latest
6
+ file: '/templates/gems.yml'
36
7
 
37
8
  ###############################################################################
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
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,10 +4,18 @@
4
4
 
5
5
  ###############################################################################
6
6
 
7
- require "bundler/gem_tasks"
7
+ require 'bundler/gem_tasks'
8
8
 
9
9
  ###############################################################################
10
10
 
11
11
  task default: %i[]
12
12
 
13
13
  ###############################################################################
14
+
15
+ begin
16
+ require 'rspec/core/rake_task'
17
+ RSpec::Core::RakeTask.new(:spec)
18
+ rescue LoadError
19
+ end
20
+
21
+ ###############################################################################
data/avatar-0.png ADDED
Binary file
data/avatar-1.png ADDED
Binary file
@@ -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}}") || key.include?("%{#{core}}") ||
73
+ container.include?("%<#{core}>s") || key.include?("%<#{core}>s")
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
  ###############################################################################
@@ -52,7 +52,11 @@ module TerraformWrapper
52
52
  logger.fatal("Response body from Hashicorp Checkpoint is not permitted!") if not response.class.body_permitted?
53
53
  logger.fatal("Response body from Hashicorp Checkpoint is empty!") if response.body.nil?
54
54
 
55
- body = JSON.parse(response.body)
55
+ begin
56
+ body = JSON.parse(response.body)
57
+ rescue JSON::ParserError
58
+ logger.fatal("Response body from Hashicorp Checkpoint is not valid JSON!")
59
+ end
56
60
 
57
61
  logger.fatal("Hashicorp Checkpoint JSON response did not include latest available Terraform version!") if not body.key?("current_version")
58
62
  logger.fatal("Hashicorp Checkpoint indicated latest available version of Terraform is blank!") if body["current_version"].empty?
@@ -1,13 +1,11 @@
1
1
  ###############################################################################
2
2
 
3
3
  module TerraformWrapper
4
+ ###############################################################################
4
5
 
5
- ###############################################################################
6
-
7
- VERSION = "1.2.7"
8
-
9
- ###############################################################################
6
+ VERSION = '1.3.1'
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,36 +4,40 @@
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/rlees85-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'
39
+
40
+ spec.add_development_dependency 'rspec', '~> 3.10'
37
41
  end
38
42
 
39
43
  ###############################################################################
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.2.7
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Lees
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-12-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
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.10'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.10'
41
55
  description: A ruby wrapper for managing Terraform binaries and remote state. Each
42
56
  Terraform command (plan, apply, etc) is wrapped so that the correct binary is used
43
57
  and remote state referenced.
@@ -49,9 +63,12 @@ extra_rdoc_files: []
49
63
  files:
50
64
  - ".gitignore"
51
65
  - ".gitlab-ci.yml"
66
+ - ".rspec"
52
67
  - Gemfile
53
68
  - LICENSE.txt
54
69
  - Rakefile
70
+ - avatar-0.png
71
+ - avatar-1.png
55
72
  - bin/console
56
73
  - bin/setup
57
74
  - lib/terraform-wrapper.rb
@@ -88,12 +105,12 @@ files:
88
105
  - lib/terraform-wrapper/tasks/validate.rb
89
106
  - lib/terraform-wrapper/version.rb
90
107
  - terraform-wrapper.gemspec
91
- homepage: https://gitlab.com/rlees85-ruby/terraform-wrapper/
108
+ homepage: https://gitlab.com/bitservices/ruby/terraform-wrapper/
92
109
  licenses:
93
110
  - MIT
94
111
  metadata:
95
- homepage_uri: https://gitlab.com/rlees85-ruby/terraform-wrapper/
96
- source_code_uri: https://gitlab.com/rlees85-ruby/terraform-wrapper/
112
+ homepage_uri: https://gitlab.com/bitservices/ruby/terraform-wrapper/
113
+ source_code_uri: https://gitlab.com/bitservices/ruby/terraform-wrapper/
97
114
  post_install_message:
98
115
  rdoc_options: []
99
116
  require_paths:
@@ -109,7 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
126
  - !ruby/object:Gem::Version
110
127
  version: '0'
111
128
  requirements: []
112
- rubygems_version: 3.2.32
129
+ rubygems_version: 3.3.26
113
130
  signing_key:
114
131
  specification_version: 4
115
132
  summary: A ruby wrapper for managing Terraform binaries and remote state.