rspec-terraform 0.1.0.pre.38 → 0.1.0.pre.39

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: e3e05eb03fa7646e942de57b9dace527769ff3f82d29a8558e296c633e4781f5
4
- data.tar.gz: a48852eace306d90abed4dceae0b3ae6967fde6206c884817690f78161a11f70
3
+ metadata.gz: d9e77a423f915bda9a4d02a980a21a1755a6dde139dc3d1890414eacfa72c1c8
4
+ data.tar.gz: 6e2ff10778fd5641f717fb2cf9e23d59e39312179a76cffa40d49ece0ae7a001
5
5
  SHA512:
6
- metadata.gz: 3e9bfbef08d1a36d6484543bc98e63ca2a1dbea26787c4460798aa0bd03a0155d5d68e077b357467d56c2e9f15ee7913df44c879f397375afa4eb6df1e9fb836
7
- data.tar.gz: 9e1d4703dcd59209d1141da61361a5503021416a11c29d772777d97b8bca316ef73282cefb1db1b8a4f8e990c69b0fb39602946f79d5df51dd134d6650ffed68
6
+ metadata.gz: a74ba985ec614bcdf6bcf1c9d031d663341f5f41a40feb513d03313d41cbbd97104c784c806ca5a64b38dffeaf5eea822722a0db2e3f1f78bd402ab18a19093a
7
+ data.tar.gz: e7c2d9563eb65a3931a4d51d775d1c07e9449a748b15cd1a06e1404a3c9d74d4f65634674d2a88ce736982a75642a3bfb2d6bcadeaef39db9f2182dacc3b3a51
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- rspec-terraform (0.1.0.pre.38)
4
+ rspec-terraform (0.1.0.pre.39)
5
5
  confidante (>= 0.27)
6
6
  rspec (>= 3.0)
7
7
  ruby-terraform (= 1.7.0.pre.16)
@@ -30,7 +30,7 @@ GEM
30
30
  partialruby (~> 0.3)
31
31
  sexp_processor (~> 4.0)
32
32
  excon (0.92.4)
33
- faker (2.22.0)
33
+ faker (2.23.0)
34
34
  i18n (>= 1.8.11, < 2)
35
35
  faraday (2.5.2)
36
36
  faraday-net_http (>= 2.0, < 3.1)
@@ -131,7 +131,7 @@ GEM
131
131
  diff-lcs (>= 1.2.0, < 2.0)
132
132
  rspec-support (~> 3.11.0)
133
133
  rspec-support (3.11.0)
134
- rubocop (1.35.1)
134
+ rubocop (1.36.0)
135
135
  json (~> 2.3)
136
136
  parallel (~> 1.10)
137
137
  parser (>= 3.1.2.1)
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RSpec
4
+ module Terraform
5
+ module Logging
6
+ class << self
7
+ def resolve_streams(opts = {})
8
+ streams = opts[:streams] || []
9
+ devices = devices(opts)
10
+
11
+ {
12
+ logger: resolve_logger(opts[:logger], streams, devices),
13
+ stdout: resolve_stdout(opts[:stdout], streams, devices),
14
+ stderr: resolve_stderr(opts[:stderr], streams, devices)
15
+ }
16
+ end
17
+
18
+ private
19
+
20
+ def resolve_logger(logger, streams, devices)
21
+ return logger if logger
22
+
23
+ log_devices = []
24
+ log_devices << devices[:file] if streams.include?(:file)
25
+ log_devices << devices[:stdout] if streams.include?(:standard)
26
+
27
+ multi_io(log_devices)
28
+ end
29
+
30
+ def resolve_stdout(stdout, streams, devices)
31
+ return stdout if stdout
32
+
33
+ log_devices = []
34
+ log_devices << devices[:file] if streams.include?(:file)
35
+ log_devices << devices[:stdout] if streams.include?(:standard)
36
+
37
+ multi_io(log_devices)
38
+ end
39
+
40
+ def resolve_stderr(stderr, streams, devices)
41
+ return stderr if stderr
42
+
43
+ log_devices = []
44
+ log_devices << devices[:file] if streams.include?(:file)
45
+ log_devices << devices[:stderr] if streams.include?(:standard)
46
+
47
+ multi_io(log_devices)
48
+ end
49
+
50
+ def devices(opts)
51
+ {
52
+ file: log_device(opts[:file_path] || File::NULL),
53
+ stdout: log_device($stdout),
54
+ stderr: log_device($stderr)
55
+ }
56
+ end
57
+
58
+ def log_device(io)
59
+ Logger::LogDevice.new(io)
60
+ end
61
+
62
+ def multi_io(ios)
63
+ RubyTerraform::MultiIO.new(*ios)
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module RSpec
4
4
  module Terraform
5
- VERSION = '0.1.0.pre.38'
5
+ VERSION = '0.1.0.pre.39'
6
6
  end
7
7
  end
@@ -7,6 +7,7 @@ require_relative 'terraform/version'
7
7
  require_relative 'terraform/configuration'
8
8
  require_relative 'terraform/matchers'
9
9
  require_relative 'terraform/helpers'
10
+ require_relative 'terraform/logging'
10
11
 
11
12
  # TODO
12
13
  # ====
@@ -18,17 +19,43 @@ require_relative 'terraform/helpers'
18
19
  # * Sensitive support in matchers
19
20
  #
20
21
 
22
+ # rubocop:disable Metrics/BlockLength
21
23
  RSpec.configure do |config|
22
24
  config.include(RSpec::Terraform::Matchers)
23
25
  config.prepend(RSpec::Terraform::Helpers)
24
26
 
25
27
  config.add_setting(:terraform_binary, default: 'terraform')
28
+
29
+ config.add_setting(:terraform_log_file_path, default: nil)
30
+ config.add_setting(:terraform_log_streams, default: [:standard])
31
+
32
+ config.add_setting(:terraform_logger, default: nil)
33
+ config.add_setting(:terraform_stdin, default: nil)
34
+ config.add_setting(:terraform_stdout, default: nil)
35
+ config.add_setting(:terraform_stderr, default: nil)
36
+
26
37
  config.add_setting(:terraform_execution_mode, default: :in_place)
38
+
27
39
  config.add_setting(
28
40
  :terraform_configuration_provider,
29
41
  default: RSpec::Terraform::Configuration.identity_provider
30
42
  )
43
+
44
+ config.before(:suite) do
45
+ resolved_streams = RSpec::Terraform::Logging.resolve_streams(
46
+ file_path: RSpec.configuration.terraform_log_file_path,
47
+ streams: RSpec.configuration.terraform_log_streams,
48
+ logger: RSpec.configuration.terraform_logger,
49
+ stdout: RSpec.configuration.terraform_stdout,
50
+ stderr: RSpec.configuration.terraform_stderr
51
+ )
52
+
53
+ RSpec.configuration.terraform_logger = resolved_streams[:logger]
54
+ RSpec.configuration.terraform_stdout = resolved_streams[:stdout]
55
+ RSpec.configuration.terraform_stderr = resolved_streams[:stderr]
56
+ end
31
57
  end
58
+ # rubocop:enable Metrics/BlockLength
32
59
 
33
60
  RSpec::Core::AnonymousExampleGroup
34
61
  .include(RSpec::Terraform::Helpers)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rspec-terraform
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre.38
4
+ version: 0.1.0.pre.39
5
5
  platform: ruby
6
6
  authors:
7
7
  - InfraBlocks Maintainers
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-31 00:00:00.000000000 Z
11
+ date: 2022-09-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: confidante
@@ -309,6 +309,7 @@ files:
309
309
  - lib/rspec/terraform/helpers/output.rb
310
310
  - lib/rspec/terraform/helpers/plan.rb
311
311
  - lib/rspec/terraform/helpers/var.rb
312
+ - lib/rspec/terraform/logging.rb
312
313
  - lib/rspec/terraform/matchers.rb
313
314
  - lib/rspec/terraform/matchers/include_output_change.rb
314
315
  - lib/rspec/terraform/matchers/include_resource_change.rb