inspec-chef 0.3.3 → 0.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cf13aeb2415399d3c00d3bf0e03f64aa6d46161dbcaf028f7ce9d105476b46c8
4
- data.tar.gz: 9e721f499a57caf6ba16babc18c4e638a269db8fa6aa25f03048a0b3ef4049be
3
+ metadata.gz: '0787aed4a0054aa070d1457bc3d26e241ce74180199d0dd7a46ca4ec9acdc952'
4
+ data.tar.gz: 7d417717bfb8d91ad32e49217c86c1f12c90f8ae5469e76c6711561d507db64e
5
5
  SHA512:
6
- metadata.gz: 1edb515f0338855b9c6a3b266a70c808b48fcf01b12b0e88f750e4a530be9770a01fefea0c67ea4145f04836b93e5af6668dcfdad2f29f8ab0ca5f6b76cd299b
7
- data.tar.gz: '087bcae728e94fd4d4ea1c9f0f2774fe04c82b093bd5ecc61ffed86c61f9aedd757ca892fbf20293ce72f35560389699ca546a50908b8edf42421d2ef1198e96'
6
+ metadata.gz: a94ee8f3bfce202c599151468fda195ad8c4dfbd61b533bf11372306665a818b23fc0860c3e796c6573bb241f23e422c36f8a0fff10fee79ac2821bc4d14969d
7
+ data.tar.gz: c9730f1dd6dc92f0c8a0ddd72f7fd345213a7bb9eab1cf3a87e56615189699aaa0bc671f79e1a1a22bd2462738c2d609048a71e671748d50780ec2ac2c71d95d
@@ -115,16 +115,24 @@ module InspecPlugins
115
115
 
116
116
  # ========================================================================
117
117
  # Interfacing with Inspec and Chef
118
+ #
118
119
 
119
- # Reach for Kitchen data and return its evaluated config
120
- # @todo DI
121
- def kitchen_provisioner_config
120
+ # Access to kitchen data
121
+ def kitchen
122
122
  require "binding_of_caller"
123
- kitchen = binding.callers.find { |b| b.frame_description == "verify" }.receiver
123
+ binding.callers.find { |b| b.frame_description == "verify" }.receiver
124
+ end
124
125
 
126
+ # Return provisioner config
127
+ def kitchen_provisioner_config
125
128
  kitchen.provisioner.send(:provided_config)
126
129
  end
127
130
 
131
+ # Return verifier config
132
+ def kitchen_verifier_config
133
+ kitchen.verifier.send(:provided_config)
134
+ end
135
+
128
136
  # Get plugin specific configuration
129
137
  def plugin_conf
130
138
  inspec_config.fetch_plugin_config("inspec-chef")
@@ -147,7 +155,7 @@ module InspecPlugins
147
155
  def connect_to_chef_server
148
156
  # From within TestKitchen we need no Chef Server connection
149
157
  if inside_testkitchen?
150
- logger.info "Running from TestKitchen, using provisioner settings instead of Chef Server"
158
+ logger.info "Running from TestKitchen, using static settings instead of Chef Server"
151
159
 
152
160
  # Only connect once
153
161
  elsif !server_connected?
@@ -191,8 +199,7 @@ module InspecPlugins
191
199
 
192
200
  chef_server.data_bag_item.fetch(item, bag: databag).data
193
201
  else
194
- config = kitchen_provisioner_config
195
- filename = File.join(config[:data_bags_path], databag, item + ".json")
202
+ filename = File.join(data_bags_path, databag, item + ".json")
196
203
 
197
204
  begin
198
205
  return JSON.load(File.read(filename))
@@ -202,6 +209,12 @@ module InspecPlugins
202
209
  end
203
210
  end
204
211
 
212
+ # Calculate lookup path for databags within TestKitchen
213
+ def data_bags_path
214
+ # These can occur on suite-level, provisioner-level, verifier or at the default location
215
+ kitchen_provisioner_config[:data_bags_path] || kitchen_verifier_config[:data_bags_path] || File.join('test', 'data_bags')
216
+ end
217
+
205
218
  # Retrieve attributes of a node
206
219
  def get_attributes(node)
207
220
  unless inside_testkitchen?
@@ -5,6 +5,6 @@
5
5
  # to learn the current version.
6
6
  module InspecPlugins
7
7
  module Chef
8
- VERSION = "0.3.3".freeze
8
+ VERSION = "0.3.4".freeze
9
9
  end
10
10
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: inspec-chef
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Heinen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-07 00:00:00.000000000 Z
11
+ date: 2020-04-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef-api