inspec-chef 0.3.0 → 0.3.1
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 +4 -4
- data/inspec-chef.gemspec +1 -1
- data/lib/inspec-chef/input.rb +28 -19
- data/lib/inspec-chef/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d92257a6fe51e2e753b38cec027da0e1d81578cf9cd96bc941e17ffbf2957ab
|
4
|
+
data.tar.gz: 93d8dea2ff6a1f8d8040543e4bccb4316001c017459cb392f12edaf49ec33633
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c43fc11316341123dfff07d7eb1d8afe4515d53ab4f0bb7c8d36cb5e7f94683dad316be341d79fbd3f484f23dabdd554e5ae17bacef97e6b02fa17fc8422c09c
|
7
|
+
data.tar.gz: de6d24d7ed8d75e6f297d9ca30605db58009308b1e09397f9f8c46413f173037501cec8afb2533665fb7b98b7e2d881e056d4ce77b748d824b36f7275142fab7
|
data/inspec-chef.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.email = ["theinen@tecracer.de"]
|
22
22
|
spec.summary = "InSpec input plugin to access Chef Infra Server databags and attributes."
|
23
23
|
spec.description = "This plugin allows InSpec 'inputs' to be provided by Chef Server."
|
24
|
-
spec.homepage = "https://github.com/
|
24
|
+
spec.homepage = "https://github.com/sgre-chef/inspec-chef"
|
25
25
|
spec.license = "Apache-2.0"
|
26
26
|
|
27
27
|
# Though complicated-looking, this is pretty standard for a gemspec.
|
data/lib/inspec-chef/input.rb
CHANGED
@@ -16,26 +16,15 @@ module InspecPlugins::Chef
|
|
16
16
|
# Set up new class
|
17
17
|
def initialize
|
18
18
|
@plugin_conf = Inspec::Config.cached.fetch_plugin_config("inspec-chef")
|
19
|
-
|
20
|
-
unless defined?(Kitchen)
|
21
|
-
@chef_endpoint = fetch_plugin_setting("endpoint")
|
22
|
-
@chef_client = fetch_plugin_setting("client")
|
23
|
-
@chef_api_key = fetch_plugin_setting("key")
|
24
|
-
|
25
|
-
if chef_endpoint.nil? || chef_client.nil? || chef_api_key.nil?
|
26
|
-
raise "ERROR: Need configuration of chef endpoint, client name and api key."
|
27
|
-
end
|
28
|
-
|
29
|
-
connect_to_chef_server
|
30
|
-
end
|
31
19
|
end
|
32
20
|
|
33
21
|
# Fetch method used for Input plugins
|
34
22
|
def fetch(_profile_name, input_uri)
|
35
23
|
return nil unless valid_plugin_input? input_uri
|
36
24
|
|
37
|
-
|
25
|
+
connect_to_chef_server
|
38
26
|
|
27
|
+
input = parse_input(input_uri)
|
39
28
|
if input[:type] == :databag
|
40
29
|
data = get_databag_item(input[:object], input[:item])
|
41
30
|
elsif input[:type] == :node
|
@@ -92,13 +81,33 @@ module InspecPlugins::Chef
|
|
92
81
|
|
93
82
|
# Establish a Chef Server connection
|
94
83
|
def connect_to_chef_server
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
84
|
+
# From within TestKitchen we need no Chef Server connection
|
85
|
+
if defined?(Kitchen)
|
86
|
+
Inspec::Log.info "Running from TestKitchen, using provisioner settings instead of Chef Server"
|
87
|
+
|
88
|
+
# Only connect once
|
89
|
+
elsif !connected?
|
90
|
+
@chef_endpoint = fetch_plugin_setting("endpoint")
|
91
|
+
@chef_client = fetch_plugin_setting("client")
|
92
|
+
@chef_api_key = fetch_plugin_setting("key")
|
93
|
+
|
94
|
+
if chef_endpoint.nil? || chef_client.nil? || chef_api_key.nil?
|
95
|
+
raise "ERROR: Plugin inspec-chef needs configuration of chef endpoint, client name and api key."
|
96
|
+
end
|
97
|
+
|
98
|
+
@chef_api ||= ChefAPI::Connection.new(
|
99
|
+
endpoint: chef_endpoint,
|
100
|
+
client: chef_client,
|
101
|
+
key: chef_api_key
|
102
|
+
)
|
103
|
+
|
104
|
+
Inspec::Log.debug format("Connected to %s as client %s", chef_endpoint, chef_client)
|
105
|
+
end
|
106
|
+
end
|
100
107
|
|
101
|
-
|
108
|
+
# Return if connection is established
|
109
|
+
def connected?
|
110
|
+
! @chef_api.nil?
|
102
111
|
end
|
103
112
|
|
104
113
|
# Retrieve a Databag item from Chef Server
|
data/lib/inspec-chef/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inspec-chef
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Heinen
|
@@ -66,7 +66,7 @@ files:
|
|
66
66
|
- lib/inspec-chef/input.rb
|
67
67
|
- lib/inspec-chef/plugin.rb
|
68
68
|
- lib/inspec-chef/version.rb
|
69
|
-
homepage: https://github.com/
|
69
|
+
homepage: https://github.com/sgre-chef/inspec-chef
|
70
70
|
licenses:
|
71
71
|
- Apache-2.0
|
72
72
|
metadata: {}
|