File tree Expand file tree Collapse file tree
health_inspector/checklists Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -22,9 +22,9 @@ def run
2222 # api_endpoint = env ? "environments/#{env}/cookbooks/#{cookbook_name}" : "cookbooks/#{cookbook_name}"
2323
2424 validator = HealthInspector ::Checklists ::Cookbooks . new ( self )
25- validator . validate_item ( validator . load_item ( cookbook_name ) )
25+ exit validator . validate_item ( validator . load_item ( cookbook_name ) )
2626 when 0 # We are inspecting all the cookbooks
27- HealthInspector ::Checklists ::Cookbooks . run ( self )
27+ exit HealthInspector ::Checklists ::Cookbooks . run ( self )
2828 end
2929 end
3030 end
Original file line number Diff line number Diff line change @@ -17,17 +17,17 @@ def run
1717 item_name = @name_args [ 1 ]
1818
1919 validator = HealthInspector ::Checklists ::DataBagItems . new ( self )
20- validator . validate_item ( validator . load_item ( "#{ bag_name } /#{ item_name } " ) )
20+ exit validator . validate_item ( validator . load_item ( "#{ bag_name } /#{ item_name } " ) )
2121
2222 when 1 # We are inspecting a data bag
2323 bag_name = @name_args [ 0 ]
2424
2525 validator = HealthInspector ::Checklists ::DataBags . new ( self )
26- validator . validate_item ( validator . load_item ( bag_name ) )
26+ exit validator . validate_item ( validator . load_item ( bag_name ) )
2727
2828 when 0 # We are inspecting all the data bags
2929 HealthInspector ::Checklists ::DataBags . run ( self )
30- HealthInspector ::Checklists ::DataBagItems . run ( self )
30+ exit HealthInspector ::Checklists ::DataBagItems . run ( self )
3131 end
3232 end
3333 end
Original file line number Diff line number Diff line change @@ -15,9 +15,9 @@ def run
1515 when 1 # We are inspecting a environment
1616 environment_name = @name_args [ 0 ]
1717 validator = HealthInspector ::Checklists ::Environments . new ( self )
18- validator . validate_item ( validator . load_item ( environment_name ) )
18+ exit validator . validate_item ( validator . load_item ( environment_name ) )
1919 when 0 # We are inspecting all the environments
20- HealthInspector ::Checklists ::Environments . run ( self )
20+ exit HealthInspector ::Checklists ::Environments . run ( self )
2121 end
2222 end
2323 end
Original file line number Diff line number Diff line change @@ -4,16 +4,20 @@ class Chef
44 class Knife
55 class Inspect < Knife
66
7+ CHECKLISTS = %w[ Cookbooks DataBags DataBagItems Environments Roles ]
8+
79 deps do
810 require "health_inspector"
911 end
1012
1113 banner "knife inspect"
1214
1315 def run
14- %w[ Cookbooks DataBags DataBagItems Environments Roles ] . each do |checklist |
16+ results = CHECKLISTS . map do |checklist |
1517 HealthInspector ::Checklists . const_get ( checklist ) . run ( self )
1618 end
19+
20+ exit ! results . include? ( false )
1721 end
1822 end
1923 end
Original file line number Diff line number Diff line change @@ -15,9 +15,9 @@ def run
1515 when 1 # We are inspecting a role
1616 role_name = @name_args [ 0 ]
1717 validator = HealthInspector ::Checklists ::Roles . new ( self )
18- validator . validate_item ( validator . load_item ( role_name ) )
18+ exit validator . validate_item ( validator . load_item ( role_name ) )
1919 when 0 # We are inspecting all the roles
20- HealthInspector ::Checklists ::Roles . run ( self )
20+ exit HealthInspector ::Checklists ::Roles . run ( self )
2121 end
2222 end
2323 end
Original file line number Diff line number Diff line change @@ -41,9 +41,13 @@ def each_item
4141 def run
4242 banner "Inspecting #{ self . class . title } "
4343
44+ results = [ ]
45+
4446 each_item do |item |
45- validate_item ( item )
47+ results << validate_item ( item )
4648 end
49+
50+ return ! results . include? ( false )
4751 end
4852
4953 def validate_item ( item )
@@ -52,8 +56,12 @@ def validate_item(item)
5256
5357 if failures . empty?
5458 print_success ( item . name ) # unless @context.quiet_success
59+
60+ true
5561 else
5662 print_failures ( item . name , failures )
63+
64+ false
5765 end
5866 end
5967
You can’t perform that action at this time.
0 commit comments