knife-inspect 0.7.1 → 0.8.0
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 +13 -5
- data/.coveralls.yml +1 -0
- data/HISTORY.md +7 -0
- data/MIT-LICENSE +3 -2
- data/README.md +14 -0
- data/knife-inspect.gemspec +1 -0
- data/lib/chef/knife/data_bag_inspect.rb +2 -3
- data/lib/health_inspector.rb +0 -1
- data/lib/health_inspector/checklists/base.rb +26 -20
- data/lib/health_inspector/checklists/cookbooks.rb +9 -13
- data/lib/health_inspector/checklists/data_bag_items.rb +12 -13
- data/lib/health_inspector/checklists/data_bags.rb +4 -9
- data/lib/health_inspector/checklists/environments.rb +2 -8
- data/lib/health_inspector/checklists/roles.rb +2 -8
- data/lib/health_inspector/color.rb +1 -1
- data/lib/health_inspector/context.rb +1 -5
- data/lib/health_inspector/pairing.rb +0 -1
- data/lib/health_inspector/version.rb +1 -1
- data/spec/chef-repo/cookbooks/cookbook_one/metadata.rb +2 -0
- data/spec/chef-repo/cookbooks/cookbook_two/metadata.rb +2 -0
- data/spec/chef-repo/data_bags/data_bag_one/one.json +0 -0
- data/spec/chef-repo/data_bags/data_bag_two/two.json +0 -0
- data/spec/chef-repo/data_bags/subdir/data_bag_from_subdir/three.json +0 -0
- data/spec/chef-repo/environments/environment_one.rb +0 -0
- data/spec/chef-repo/environments/environment_two.json +0 -0
- data/spec/chef-repo/environments/subdir/environment_from_subdir.js +0 -0
- data/spec/chef-repo/roles/role_one.json +0 -0
- data/spec/chef-repo/roles/role_two.json +0 -0
- data/spec/chef-repo/roles/subdir/role_from_subdir.json +0 -0
- data/spec/{cookbook_spec.rb → health_inspector/checklists/cookbook_spec.rb} +0 -0
- data/spec/health_inspector/checklists/cookbooks_spec.rb +35 -0
- data/spec/{data_bag_item_spec.rb → health_inspector/checklists/data_bag_item_spec.rb} +0 -0
- data/spec/health_inspector/checklists/data_bag_items_spec.rb +39 -0
- data/spec/{data_bag_spec.rb → health_inspector/checklists/data_bag_spec.rb} +0 -0
- data/spec/health_inspector/checklists/data_bags_spec.rb +33 -0
- data/spec/{environment_spec.rb → health_inspector/checklists/environment_spec.rb} +0 -0
- data/spec/health_inspector/checklists/environments_spec.rb +33 -0
- data/spec/{role_spec.rb → health_inspector/checklists/role_spec.rb} +0 -0
- data/spec/health_inspector/checklists/roles_spec.rb +33 -0
- data/spec/spec_helper.rb +13 -1
- metadata +77 -30
- data/lib/health_inspector/inspector.rb +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
YTcyNzJmYmE2Nzg0ZWRjN2QyMTA4YzA0ODJiZTNiYjg5ODE0NGNiNA==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
NDNkMTNlNWM5ODc3OGZhNmE0ZDI3ODliZTRmZGIzMGNiYTRkNjc0ZA==
|
5
7
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
Y2I1MTdlYTViNDdiZWQwZDA3OTM1NDhiYjgyZTM1MmNmNzM4NTMyZTliZmY1
|
10
|
+
YTJjOTA1MmRlZWIyYTE1NjdhNDUyMmYyNmYzYTZhZGU4ODM2YjdiNDE3ZWNj
|
11
|
+
Yzk5MjYzM2IyZmIwODM5ZDg5MjM5NzY4MWRjMWFkYWYzZDMyMDY=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
OWQ2NWRiYmYxMWIyMTg1YWRiMTc0MTljNzQ2NTkwYTgzZTcyZTcwMjFmNDc2
|
14
|
+
NzFkN2FkOWRmNDYxNTZhZjZmNDkwY2FhYjNiNzIzMmI1Y2ZhZTMyNThkNmZh
|
15
|
+
YTQyZjM0ZjdhNmU5MGI3OTdmZmIyOTJjMDFhMGEwNDg1Nzk3NmU=
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/HISTORY.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## 0.8.0 ( 2014-01-10 )
|
2
|
+
|
3
|
+
* New feature: Support data bags, data bag items, environments and roles inside
|
4
|
+
folders.
|
5
|
+
* Add initial specs for the checklists.
|
6
|
+
* General cleanup: got rid of some duplicate code and dead code.
|
7
|
+
|
1
8
|
## 0.7.1 ( 2014-01-06 )
|
2
9
|
|
3
10
|
* Small bug fix: `knife data bag inspect` returned the status code only for
|
data/MIT-LICENSE
CHANGED
@@ -1,4 +1,5 @@
|
|
1
|
-
Copyright (C) 2012 Ben Marini
|
1
|
+
Copyright (C) 2012-2013 Ben Marini and contributors
|
2
|
+
Copyright (C) 2014 Greg Karékinian and contributors
|
2
3
|
|
3
4
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
5
|
of this software and associated documentation files (the "Software"), to deal
|
@@ -16,4 +17,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
16
17
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
18
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
19
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
19
|
-
SOFTWARE.
|
20
|
+
SOFTWARE.
|
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
+
[](http://badge.fury.io/rb/knife-inspect)
|
1
2
|
[](http://travis-ci.org/bmarini/knife-inspect)
|
2
3
|
[](https://codeclimate.com/github/bmarini/knife-inspect)
|
4
|
+
[](https://coveralls.io/r/bmarini/knife-inspect)
|
3
5
|
|
4
6
|
## Summary
|
5
7
|
|
@@ -43,6 +45,18 @@ So far it checks if...
|
|
43
45
|
* your environments are in sync
|
44
46
|
* your roles are in sync
|
45
47
|
|
48
|
+
You can use it with your favorite Continuous Integration tool, it returns 0
|
49
|
+
when everything is in sync or 1 if it's not.
|
50
|
+
|
51
|
+
## Contributors
|
52
|
+
|
53
|
+
(in alphabetical order)
|
54
|
+
|
55
|
+
* Adam Sinnett ([@quandrum](https://github.com/quandrum))
|
56
|
+
* Eric Saxby ([@sax](https://github.com/sax))
|
57
|
+
* Dan Buch ([@meatballhat](@https://github.com/meatballhat))
|
58
|
+
* Kirt Fitzpatrick ([@kirtfitzpatrick](https://github.com/kirtfitzpatrick))
|
59
|
+
|
46
60
|
## Contributing
|
47
61
|
|
48
62
|
1. Fork it
|
data/knife-inspect.gemspec
CHANGED
@@ -26,6 +26,7 @@ Gem::Specification.new do |s|
|
|
26
26
|
s.add_development_dependency 'rake', '~> 10.1'
|
27
27
|
s.add_development_dependency 'rspec', '~> 2.14'
|
28
28
|
s.add_development_dependency 'simplecov', '~> 0.8'
|
29
|
+
s.add_development_dependency 'coveralls', '~> 0.7'
|
29
30
|
|
30
31
|
s.add_runtime_dependency 'chef', chef_version
|
31
32
|
s.add_runtime_dependency 'yajl-ruby', '~> 1.1'
|
@@ -3,7 +3,6 @@ require 'chef/knife'
|
|
3
3
|
class Chef
|
4
4
|
class Knife
|
5
5
|
class DataBagInspect < Knife
|
6
|
-
|
7
6
|
deps do
|
8
7
|
require 'health_inspector'
|
9
8
|
end
|
@@ -17,13 +16,13 @@ class Chef
|
|
17
16
|
item_name = @name_args[1]
|
18
17
|
|
19
18
|
validator = HealthInspector::Checklists::DataBagItems.new(self)
|
20
|
-
exit validator.validate_item(
|
19
|
+
exit validator.validate_item(validator.load_item("#{bag_name}/#{item_name}"))
|
21
20
|
|
22
21
|
when 1 # We are inspecting a data bag
|
23
22
|
bag_name = @name_args[0]
|
24
23
|
|
25
24
|
validator = HealthInspector::Checklists::DataBags.new(self)
|
26
|
-
exit validator.validate_item(
|
25
|
+
exit validator.validate_item(validator.load_item(bag_name))
|
27
26
|
|
28
27
|
when 0 # We are inspecting all the data bags
|
29
28
|
exit HealthInspector::Checklists::DataBags.run(self) &&
|
data/lib/health_inspector.rb
CHANGED
@@ -3,7 +3,6 @@ require "health_inspector/version"
|
|
3
3
|
require "health_inspector/color"
|
4
4
|
require "health_inspector/context"
|
5
5
|
require "health_inspector/pairing"
|
6
|
-
require "health_inspector/inspector"
|
7
6
|
require "health_inspector/checklists/base"
|
8
7
|
require "health_inspector/checklists/cookbooks"
|
9
8
|
require "health_inspector/checklists/data_bags"
|
@@ -26,16 +26,22 @@ module HealthInspector
|
|
26
26
|
@context.knife.ui
|
27
27
|
end
|
28
28
|
|
29
|
+
def server_items
|
30
|
+
raise NotImplementedError, "You must implement this method in a subclass"
|
31
|
+
end
|
32
|
+
|
33
|
+
def local_items
|
34
|
+
raise NotImplementedError, "You must implement this method in a subclass"
|
35
|
+
end
|
36
|
+
|
29
37
|
def all_item_names
|
30
|
-
(
|
38
|
+
(server_items + local_items).uniq.sort
|
31
39
|
end
|
32
40
|
|
33
|
-
# Subclasses should collect all items from the server and the local repo,
|
34
|
-
# and for each item pair, yield an object that contains a reference to
|
35
|
-
# the server item, and the local repo item. A reference can be nil if it does
|
36
|
-
# not exist in one of the locations.
|
37
41
|
def each_item
|
38
|
-
|
42
|
+
all_item_names.each do |name|
|
43
|
+
yield load_item(name)
|
44
|
+
end
|
39
45
|
end
|
40
46
|
|
41
47
|
def run
|
@@ -79,7 +85,7 @@ module HealthInspector
|
|
79
85
|
ui.msg color('bright fail', "- #{subject}")
|
80
86
|
|
81
87
|
failures.each do |message|
|
82
|
-
if message.
|
88
|
+
if message.is_a? Hash
|
83
89
|
puts color('bright yellow'," has the following values mismatched on the server and repo\n")
|
84
90
|
print_failures_from_hash(message)
|
85
91
|
else
|
@@ -103,31 +109,31 @@ module HealthInspector
|
|
103
109
|
end
|
104
110
|
|
105
111
|
def print_key(key, depth)
|
106
|
-
ui.msg indent(
|
112
|
+
ui.msg indent(color('bright yellow',"#{key} : "), depth)
|
107
113
|
end
|
108
114
|
|
109
115
|
def print_value_diff(value, depth)
|
110
|
-
print indent(
|
116
|
+
print indent(color('bright fail',"server value = "), depth + 1)
|
111
117
|
print value["server"]
|
112
118
|
print "\n"
|
113
|
-
print indent(
|
119
|
+
print indent(color('bright fail',"local value = "), depth + 1)
|
114
120
|
print value["local"]
|
115
121
|
print "\n\n"
|
116
122
|
end
|
117
123
|
|
118
124
|
def load_ruby_or_json_from_local(chef_class, folder, name)
|
119
|
-
path_template = "#{@context.repo_path}/#{folder}
|
120
|
-
ruby_pathname = Pathname.
|
121
|
-
json_pathname = Pathname.
|
122
|
-
js_pathname = Pathname.
|
125
|
+
path_template = "#{@context.repo_path}/#{folder}/**/#{name}.%s"
|
126
|
+
ruby_pathname = Pathname.glob(path_template % "rb")
|
127
|
+
json_pathname = Pathname.glob(path_template % "json")
|
128
|
+
js_pathname = Pathname.glob(path_template % "js")
|
123
129
|
|
124
|
-
if ruby_pathname.
|
130
|
+
if ! ruby_pathname.empty?
|
125
131
|
instance = chef_class.new
|
126
|
-
instance.from_file(ruby_pathname.to_s)
|
127
|
-
elsif json_pathname.
|
128
|
-
instance = chef_class.json_create(
|
129
|
-
elsif js_pathname.
|
130
|
-
instance = chef_class.json_create(
|
132
|
+
instance.from_file(ruby_pathname.first.to_s)
|
133
|
+
elsif ! json_pathname.empty?
|
134
|
+
instance = chef_class.json_create(Yajl::Parser.parse(json_pathname.first.read))
|
135
|
+
elsif ! js_pathname.empty?
|
136
|
+
instance = chef_class.json_create(Yajl::Parser.parse(js_pathname.first.read))
|
131
137
|
end
|
132
138
|
|
133
139
|
instance ? instance.to_hash : nil
|
@@ -5,7 +5,7 @@ module HealthInspector
|
|
5
5
|
include ExistenceValidations
|
6
6
|
|
7
7
|
def validate_versions
|
8
|
-
if versions_exist? && !versions_match?
|
8
|
+
if versions_exist? && ! versions_match?
|
9
9
|
errors.add "chef server has #{server} but local version is #{local}"
|
10
10
|
end
|
11
11
|
end
|
@@ -91,30 +91,22 @@ module HealthInspector
|
|
91
91
|
|
92
92
|
title "cookbooks"
|
93
93
|
|
94
|
-
def each_item
|
95
|
-
all_cookbook_names = ( server_cookbooks.keys + local_cookbooks.keys ).uniq.sort
|
96
|
-
|
97
|
-
all_cookbook_names.each do |name|
|
98
|
-
yield load_item(name)
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
94
|
def load_item(name)
|
103
95
|
Cookbook.new(@context,
|
104
96
|
:name => name,
|
105
|
-
:server =>
|
106
|
-
:local =>
|
97
|
+
:server => server_items[name],
|
98
|
+
:local => local_items[name]
|
107
99
|
)
|
108
100
|
end
|
109
101
|
|
110
|
-
def
|
102
|
+
def server_items
|
111
103
|
@context.rest.get_rest("/cookbooks").inject({}) do |hsh, (name,version)|
|
112
104
|
hsh[name] = Chef::Version.new(version["versions"].first["version"])
|
113
105
|
hsh
|
114
106
|
end
|
115
107
|
end
|
116
108
|
|
117
|
-
def
|
109
|
+
def local_items
|
118
110
|
@context.cookbook_path.
|
119
111
|
map { |path| Dir["#{path}/*"] }.
|
120
112
|
flatten.
|
@@ -129,6 +121,10 @@ module HealthInspector
|
|
129
121
|
end
|
130
122
|
end
|
131
123
|
|
124
|
+
def all_item_names
|
125
|
+
(server_items.keys + local_items.keys).uniq.sort
|
126
|
+
end
|
127
|
+
|
132
128
|
end
|
133
129
|
end
|
134
130
|
end
|
@@ -10,12 +10,6 @@ module HealthInspector
|
|
10
10
|
class DataBagItems < Base
|
11
11
|
title "data bag items"
|
12
12
|
|
13
|
-
def each_item
|
14
|
-
all_item_names.each do |name|
|
15
|
-
yield load_item(name)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
13
|
def load_item(name)
|
20
14
|
DataBagItem.new(@context,
|
21
15
|
:name => name,
|
@@ -32,14 +26,11 @@ module HealthInspector
|
|
32
26
|
end
|
33
27
|
end
|
34
28
|
|
29
|
+
# JSON files are data bag items, their parent folder is the data bag
|
35
30
|
def local_items
|
36
|
-
|
37
|
-
|
38
|
-
Dir.chdir("#{@context.repo_path}/data_bags") do
|
39
|
-
entries = Dir["**/*.json"].map { |entry| entry.gsub('.json', '') }
|
31
|
+
Dir["#{@context.repo_path}/data_bags/**/*.json"].map do |e|
|
32
|
+
e.split('/')[-2..-1].join('/').gsub('.json', '')
|
40
33
|
end
|
41
|
-
|
42
|
-
return entries
|
43
34
|
end
|
44
35
|
|
45
36
|
def load_item_from_server(name)
|
@@ -49,8 +40,16 @@ module HealthInspector
|
|
49
40
|
nil
|
50
41
|
end
|
51
42
|
|
43
|
+
# We support data bags that are inside a folder or git submodule, for
|
44
|
+
# example:
|
45
|
+
#
|
46
|
+
# data_bags/corp/apps/some_app.json is in the repo, but apps/some_app on
|
47
|
+
# the server
|
52
48
|
def load_item_from_local(name)
|
53
|
-
|
49
|
+
local_data_bag_item = Dir["#{@context.repo_path}/data_bags/**/#{name}.json"].first
|
50
|
+
return nil if local_data_bag_item.nil?
|
51
|
+
|
52
|
+
Yajl::Parser.parse(File.read(local_data_bag_item))
|
54
53
|
rescue IOError, Errno::ENOENT
|
55
54
|
nil
|
56
55
|
end
|
@@ -9,12 +9,6 @@ module HealthInspector
|
|
9
9
|
class DataBags < Base
|
10
10
|
title "data bags"
|
11
11
|
|
12
|
-
def each_item
|
13
|
-
all_item_names.each do |name|
|
14
|
-
yield load_item(name)
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
12
|
def load_item(name)
|
19
13
|
DataBag.new(@context,
|
20
14
|
:name => name,
|
@@ -27,10 +21,11 @@ module HealthInspector
|
|
27
21
|
@server_items ||= Chef::DataBag.list.keys
|
28
22
|
end
|
29
23
|
|
24
|
+
# JSON files are data bag items, their parent folder is the data bag
|
30
25
|
def local_items
|
31
|
-
@local_items ||= Dir["#{@context.repo_path}/data_bags
|
32
|
-
|
33
|
-
|
26
|
+
@local_items ||= Dir["#{@context.repo_path}/data_bags/**/*.json"].map do |e|
|
27
|
+
e.split('/')[-2].gsub('.json', '')
|
28
|
+
end
|
34
29
|
end
|
35
30
|
end
|
36
31
|
|
@@ -16,12 +16,6 @@ module HealthInspector
|
|
16
16
|
class Environments < Base
|
17
17
|
title "environments"
|
18
18
|
|
19
|
-
def each_item
|
20
|
-
all_item_names.each do |name|
|
21
|
-
yield load_item(name)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
19
|
def load_item(name)
|
26
20
|
Environment.new(@context,
|
27
21
|
:name => name,
|
@@ -35,8 +29,8 @@ module HealthInspector
|
|
35
29
|
end
|
36
30
|
|
37
31
|
def local_items
|
38
|
-
Dir
|
39
|
-
|
32
|
+
Dir["#{@context.repo_path}/environments/**/*.{rb,json,js}"].map do |e|
|
33
|
+
File.basename(e, '.*')
|
40
34
|
end
|
41
35
|
end
|
42
36
|
|
@@ -11,12 +11,6 @@ module HealthInspector
|
|
11
11
|
class Roles < Base
|
12
12
|
title "roles"
|
13
13
|
|
14
|
-
def each_item
|
15
|
-
all_item_names.each do |name|
|
16
|
-
yield load_item(name)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
14
|
def load_item(name)
|
21
15
|
Role.new(@context,
|
22
16
|
:name => name,
|
@@ -30,8 +24,8 @@ module HealthInspector
|
|
30
24
|
end
|
31
25
|
|
32
26
|
def local_items
|
33
|
-
Dir
|
34
|
-
|
27
|
+
Dir["#{@context.repo_path}/roles/**/*.{rb,json,js}"].map do |e|
|
28
|
+
File.basename(e, '.*')
|
35
29
|
end
|
36
30
|
end
|
37
31
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe HealthInspector::Checklists::Cookbooks do
|
4
|
+
let :checklist do
|
5
|
+
described_class.new(nil)
|
6
|
+
end
|
7
|
+
|
8
|
+
before do
|
9
|
+
expect(HealthInspector::Context).to receive(:new).with(nil).
|
10
|
+
and_return health_inspector_context
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#server_items' do
|
14
|
+
it 'returns a list of roles from the chef server' do
|
15
|
+
health_inspector_context.stub_chain(:rest, :get_rest).
|
16
|
+
with('/cookbooks').and_return({
|
17
|
+
'cookbook_one' => { 'versions' => [{ 'version' => '1.0.0' }] },
|
18
|
+
'cookbook_two' => { 'versions' => [{ 'version' => '0.0.1' }] }
|
19
|
+
})
|
20
|
+
expect(checklist.server_items).to eq({
|
21
|
+
'cookbook_one' => Chef::Version.new('1.0.0'),
|
22
|
+
'cookbook_two' => Chef::Version.new('0.0.1')
|
23
|
+
})
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe '#local_items' do
|
28
|
+
it 'returns a list of roles from the chef repo' do
|
29
|
+
expect(checklist.local_items).to eq({
|
30
|
+
'cookbook_one' => Chef::Version.new('1.0.0'),
|
31
|
+
'cookbook_two' => Chef::Version.new('0.0.1')
|
32
|
+
})
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
File without changes
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe HealthInspector::Checklists::DataBagItems do
|
4
|
+
let :checklist do
|
5
|
+
described_class.new(nil)
|
6
|
+
end
|
7
|
+
|
8
|
+
before do
|
9
|
+
expect(HealthInspector::Context).to receive(:new).with(nil).
|
10
|
+
and_return health_inspector_context
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#server_items' do
|
14
|
+
it 'returns a list of data bag items from the chef server' do
|
15
|
+
expect(Chef::DataBag).to receive(:list).and_return({
|
16
|
+
'data_bag_one' => 'url',
|
17
|
+
'data_bag_two' => 'url',
|
18
|
+
'data_bag_from_subdir' => 'url'
|
19
|
+
})
|
20
|
+
{ 'data_bag_one' => 'one',
|
21
|
+
'data_bag_two' => 'two',
|
22
|
+
'data_bag_from_subdir' => 'three' }.each do |data_bag, item|
|
23
|
+
expect(Chef::DataBag).to receive(:load).with(data_bag).
|
24
|
+
and_return({ item => 'url' })
|
25
|
+
end
|
26
|
+
expect(checklist.server_items.sort).to eq [
|
27
|
+
'data_bag_from_subdir/three', 'data_bag_one/one', 'data_bag_two/two'
|
28
|
+
]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#local_items' do
|
33
|
+
it 'returns a list of data bag items from the chef repo' do
|
34
|
+
expect(checklist.local_items.sort).to eq [
|
35
|
+
'data_bag_from_subdir/three', 'data_bag_one/one', 'data_bag_two/two'
|
36
|
+
]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
File without changes
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe HealthInspector::Checklists::DataBags do
|
4
|
+
let :checklist do
|
5
|
+
described_class.new(nil)
|
6
|
+
end
|
7
|
+
|
8
|
+
before do
|
9
|
+
expect(HealthInspector::Context).to receive(:new).with(nil).
|
10
|
+
and_return health_inspector_context
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#server_items' do
|
14
|
+
it 'returns a list of data bags from the chef server' do
|
15
|
+
expect(Chef::DataBag).to receive(:list).and_return({
|
16
|
+
'data_bag_one' => 'url',
|
17
|
+
'data_bag_two' => 'url',
|
18
|
+
'data_bag_from_subdir' => 'url'
|
19
|
+
})
|
20
|
+
expect(checklist.server_items.sort).to eq [
|
21
|
+
'data_bag_from_subdir', 'data_bag_one', 'data_bag_two'
|
22
|
+
]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#local_items' do
|
27
|
+
it 'returns a list of data bags from the chef repo' do
|
28
|
+
expect(checklist.local_items.sort).to eq [
|
29
|
+
'data_bag_from_subdir', 'data_bag_one', 'data_bag_two'
|
30
|
+
]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
File without changes
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe HealthInspector::Checklists::Environments do
|
4
|
+
let :checklist do
|
5
|
+
described_class.new(nil)
|
6
|
+
end
|
7
|
+
|
8
|
+
before do
|
9
|
+
expect(HealthInspector::Context).to receive(:new).with(nil).
|
10
|
+
and_return health_inspector_context
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#server_items' do
|
14
|
+
it 'returns a list of environments from the chef server' do
|
15
|
+
expect(Chef::Environment).to receive(:list).and_return({
|
16
|
+
'environment_one' => 'url',
|
17
|
+
'environment_two' => 'url',
|
18
|
+
'environment_from_subdir' => 'url'
|
19
|
+
})
|
20
|
+
expect(checklist.server_items.sort).to eq [
|
21
|
+
'environment_from_subdir', 'environment_one', 'environment_two'
|
22
|
+
]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#local_items' do
|
27
|
+
it 'returns a list of environments from the chef repo' do
|
28
|
+
expect(checklist.local_items.sort).to eq [
|
29
|
+
'environment_from_subdir', 'environment_one', 'environment_two'
|
30
|
+
]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
File without changes
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe HealthInspector::Checklists::Roles do
|
4
|
+
let :checklist do
|
5
|
+
described_class.new(nil)
|
6
|
+
end
|
7
|
+
|
8
|
+
before do
|
9
|
+
expect(HealthInspector::Context).to receive(:new).with(nil).
|
10
|
+
and_return health_inspector_context
|
11
|
+
end
|
12
|
+
|
13
|
+
describe '#server_items' do
|
14
|
+
it 'returns a list of roles from the chef server' do
|
15
|
+
expect(Chef::Role).to receive(:list).and_return({
|
16
|
+
'role_one' => 'url',
|
17
|
+
'role_two' => 'url',
|
18
|
+
'role_from_subdir' => 'url'
|
19
|
+
})
|
20
|
+
expect(checklist.server_items.sort).to eq [
|
21
|
+
'role_from_subdir', 'role_one', 'role_two'
|
22
|
+
]
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
describe '#local_items' do
|
27
|
+
it 'returns a list of roles from the chef repo' do
|
28
|
+
expect(checklist.local_items.sort).to eq [
|
29
|
+
'role_from_subdir', 'role_one', 'role_two'
|
30
|
+
]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
if RUBY_VERSION > '1.9'
|
2
2
|
require 'simplecov'
|
3
|
+
require 'coveralls'
|
4
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
5
|
+
SimpleCov::Formatter::HTMLFormatter,
|
6
|
+
Coveralls::SimpleCov::Formatter
|
7
|
+
]
|
3
8
|
SimpleCov.start do
|
4
9
|
add_filter "/spec/"
|
5
10
|
end
|
@@ -10,8 +15,15 @@ require 'bundler/setup'
|
|
10
15
|
require 'health_inspector'
|
11
16
|
|
12
17
|
module HealthInspector::SpecHelpers
|
18
|
+
def repo_path
|
19
|
+
@repo_path ||= File.expand_path("../chef-repo", __FILE__)
|
20
|
+
end
|
21
|
+
|
13
22
|
def health_inspector_context
|
14
|
-
@health_inspector_context ||=
|
23
|
+
@health_inspector_context ||= double(
|
24
|
+
:repo_path => repo_path,
|
25
|
+
:cookbook_path => ["#{repo_path}/cookbooks"]
|
26
|
+
)
|
15
27
|
end
|
16
28
|
end
|
17
29
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-inspect
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Greg Karékinian
|
@@ -9,82 +9,96 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-01-
|
12
|
+
date: 2014-01-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- -
|
18
|
+
- - ~>
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '10.1'
|
21
21
|
type: :development
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- -
|
25
|
+
- - ~>
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '10.1'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: rspec
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - ~>
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '2.14'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - ~>
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '2.14'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: simplecov
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- -
|
46
|
+
- - ~>
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '0.8'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - ~>
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0.8'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: coveralls
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ~>
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0.7'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0.7'
|
56
70
|
- !ruby/object:Gem::Dependency
|
57
71
|
name: chef
|
58
72
|
requirement: !ruby/object:Gem::Requirement
|
59
73
|
requirements:
|
60
|
-
- -
|
74
|
+
- - ! '>='
|
61
75
|
- !ruby/object:Gem::Version
|
62
76
|
version: '10'
|
63
|
-
- -
|
77
|
+
- - <=
|
64
78
|
- !ruby/object:Gem::Version
|
65
79
|
version: '12'
|
66
80
|
type: :runtime
|
67
81
|
prerelease: false
|
68
82
|
version_requirements: !ruby/object:Gem::Requirement
|
69
83
|
requirements:
|
70
|
-
- -
|
84
|
+
- - ! '>='
|
71
85
|
- !ruby/object:Gem::Version
|
72
86
|
version: '10'
|
73
|
-
- -
|
87
|
+
- - <=
|
74
88
|
- !ruby/object:Gem::Version
|
75
89
|
version: '12'
|
76
90
|
- !ruby/object:Gem::Dependency
|
77
91
|
name: yajl-ruby
|
78
92
|
requirement: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
|
-
- -
|
94
|
+
- - ~>
|
81
95
|
- !ruby/object:Gem::Version
|
82
96
|
version: '1.1'
|
83
97
|
type: :runtime
|
84
98
|
prerelease: false
|
85
99
|
version_requirements: !ruby/object:Gem::Requirement
|
86
100
|
requirements:
|
87
|
-
- -
|
101
|
+
- - ~>
|
88
102
|
- !ruby/object:Gem::Version
|
89
103
|
version: '1.1'
|
90
104
|
description: knife-inspect is a knife plugin to compare the content of your Chef repository
|
@@ -95,8 +109,9 @@ executables: []
|
|
95
109
|
extensions: []
|
96
110
|
extra_rdoc_files: []
|
97
111
|
files:
|
98
|
-
-
|
99
|
-
-
|
112
|
+
- .coveralls.yml
|
113
|
+
- .gitignore
|
114
|
+
- .travis.yml
|
100
115
|
- Gemfile
|
101
116
|
- HISTORY.md
|
102
117
|
- MIT-LICENSE
|
@@ -117,14 +132,29 @@ files:
|
|
117
132
|
- lib/health_inspector/checklists/roles.rb
|
118
133
|
- lib/health_inspector/color.rb
|
119
134
|
- lib/health_inspector/context.rb
|
120
|
-
- lib/health_inspector/inspector.rb
|
121
135
|
- lib/health_inspector/pairing.rb
|
122
136
|
- lib/health_inspector/version.rb
|
123
|
-
- spec/
|
124
|
-
- spec/
|
125
|
-
- spec/
|
126
|
-
- spec/
|
127
|
-
- spec/
|
137
|
+
- spec/chef-repo/cookbooks/cookbook_one/metadata.rb
|
138
|
+
- spec/chef-repo/cookbooks/cookbook_two/metadata.rb
|
139
|
+
- spec/chef-repo/data_bags/data_bag_one/one.json
|
140
|
+
- spec/chef-repo/data_bags/data_bag_two/two.json
|
141
|
+
- spec/chef-repo/data_bags/subdir/data_bag_from_subdir/three.json
|
142
|
+
- spec/chef-repo/environments/environment_one.rb
|
143
|
+
- spec/chef-repo/environments/environment_two.json
|
144
|
+
- spec/chef-repo/environments/subdir/environment_from_subdir.js
|
145
|
+
- spec/chef-repo/roles/role_one.json
|
146
|
+
- spec/chef-repo/roles/role_two.json
|
147
|
+
- spec/chef-repo/roles/subdir/role_from_subdir.json
|
148
|
+
- spec/health_inspector/checklists/cookbook_spec.rb
|
149
|
+
- spec/health_inspector/checklists/cookbooks_spec.rb
|
150
|
+
- spec/health_inspector/checklists/data_bag_item_spec.rb
|
151
|
+
- spec/health_inspector/checklists/data_bag_items_spec.rb
|
152
|
+
- spec/health_inspector/checklists/data_bag_spec.rb
|
153
|
+
- spec/health_inspector/checklists/data_bags_spec.rb
|
154
|
+
- spec/health_inspector/checklists/environment_spec.rb
|
155
|
+
- spec/health_inspector/checklists/environments_spec.rb
|
156
|
+
- spec/health_inspector/checklists/role_spec.rb
|
157
|
+
- spec/health_inspector/checklists/roles_spec.rb
|
128
158
|
- spec/spec_helper.rb
|
129
159
|
homepage: https://github.com/bmarini/knife-inspect
|
130
160
|
licenses:
|
@@ -136,24 +166,41 @@ require_paths:
|
|
136
166
|
- lib
|
137
167
|
required_ruby_version: !ruby/object:Gem::Requirement
|
138
168
|
requirements:
|
139
|
-
- -
|
169
|
+
- - ! '>='
|
140
170
|
- !ruby/object:Gem::Version
|
141
171
|
version: '0'
|
142
172
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
173
|
requirements:
|
144
|
-
- -
|
174
|
+
- - ! '>='
|
145
175
|
- !ruby/object:Gem::Version
|
146
176
|
version: '0'
|
147
177
|
requirements: []
|
148
178
|
rubyforge_project:
|
149
|
-
rubygems_version: 2.2.
|
179
|
+
rubygems_version: 2.2.1
|
150
180
|
signing_key:
|
151
181
|
specification_version: 4
|
152
182
|
summary: Inspect your chef repo as it is compared to what is on your chef server
|
153
183
|
test_files:
|
154
|
-
- spec/
|
155
|
-
- spec/
|
156
|
-
- spec/
|
157
|
-
- spec/
|
158
|
-
- spec/
|
184
|
+
- spec/chef-repo/cookbooks/cookbook_one/metadata.rb
|
185
|
+
- spec/chef-repo/cookbooks/cookbook_two/metadata.rb
|
186
|
+
- spec/chef-repo/data_bags/data_bag_one/one.json
|
187
|
+
- spec/chef-repo/data_bags/data_bag_two/two.json
|
188
|
+
- spec/chef-repo/data_bags/subdir/data_bag_from_subdir/three.json
|
189
|
+
- spec/chef-repo/environments/environment_one.rb
|
190
|
+
- spec/chef-repo/environments/environment_two.json
|
191
|
+
- spec/chef-repo/environments/subdir/environment_from_subdir.js
|
192
|
+
- spec/chef-repo/roles/role_one.json
|
193
|
+
- spec/chef-repo/roles/role_two.json
|
194
|
+
- spec/chef-repo/roles/subdir/role_from_subdir.json
|
195
|
+
- spec/health_inspector/checklists/cookbook_spec.rb
|
196
|
+
- spec/health_inspector/checklists/cookbooks_spec.rb
|
197
|
+
- spec/health_inspector/checklists/data_bag_item_spec.rb
|
198
|
+
- spec/health_inspector/checklists/data_bag_items_spec.rb
|
199
|
+
- spec/health_inspector/checklists/data_bag_spec.rb
|
200
|
+
- spec/health_inspector/checklists/data_bags_spec.rb
|
201
|
+
- spec/health_inspector/checklists/environment_spec.rb
|
202
|
+
- spec/health_inspector/checklists/environments_spec.rb
|
203
|
+
- spec/health_inspector/checklists/role_spec.rb
|
204
|
+
- spec/health_inspector/checklists/roles_spec.rb
|
159
205
|
- spec/spec_helper.rb
|
206
|
+
has_rdoc:
|
@@ -1,20 +0,0 @@
|
|
1
|
-
module HealthInspector
|
2
|
-
class Inspector
|
3
|
-
def self.inspect(checklists, options)
|
4
|
-
new(options).inspect( checklists )
|
5
|
-
end
|
6
|
-
|
7
|
-
def initialize(options)
|
8
|
-
@context = Context.new( options[:repopath], options[:configpath] )
|
9
|
-
@context.quiet_success = options[:'quiet-success']
|
10
|
-
@context.no_color = options[:'no-color']
|
11
|
-
@context.configure
|
12
|
-
end
|
13
|
-
|
14
|
-
def inspect(checklists)
|
15
|
-
checklists.each do |checklist|
|
16
|
-
Checklists.const_get(checklist).run(@context) if Checklists.const_defined?(checklist)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|