health_inspector 0.0.4 → 0.0.5

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.
data/HISTORY.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.0.5 ( 2012-04-13 )
2
+
3
+ * Fix #2, exception when a data bag item json file doesn't exist locally
4
+
1
5
  ## 0.0.4 ( 2012-04-09 )
2
6
 
3
7
  * Add checks for data bags, data bag items, environments, and roles
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
- # Health Inspector
1
+ ## Summary
2
2
 
3
- A tool to inspect your chef repo as is compares to what is on your chef server
3
+ `health_inspector` is tool to inspect your chef repo as it compares to what is
4
+ on your chef server.
4
5
 
5
6
  ## Usage
6
7
 
@@ -9,12 +10,20 @@ A tool to inspect your chef repo as is compares to what is on your chef server
9
10
 
10
11
  Run `health_inspector help` for more options
11
12
 
12
- ## What is checks
13
+ ## What it does
13
14
 
14
15
  So far it checks if...
15
16
 
16
- * your chef server has cookbooks you don't have locally
17
- * your chef server is missing cookbooks you have locally
18
- * cookbook versions are not the same between server and local chef repo
19
- * you have uncommitted changes in a cookbook (assuming your cookbook is a git repo)
20
- * you have commits in a cookbook that haven't been pushed to your remote (assuming your cookbook is a git repo)
17
+ * your cookbooks are in sync
18
+ * you have uncommitted changes in a cookbook (assuming your cookbooks are in
19
+ their own git repos)
20
+ * you have commits in a cookbook that haven't been pushed to your remote
21
+ (assuming your cookbooks are in their own git repos)
22
+ * your data bags are in sync
23
+ * your data bag items are in sync
24
+ * your environments are in sync
25
+ * your roles are in sync
26
+
27
+ ## Assumptions
28
+
29
+ * Your roles and environments are written using the ruby DSL.
data/Rakefile CHANGED
@@ -1 +1,10 @@
1
1
  require "bundler/gem_tasks"
2
+ require 'rake/testtask'
3
+
4
+ Rake::TestTask.new(:test) do |test|
5
+ test.libs << 'lib' << 'spec'
6
+ test.pattern = 'spec/**/*_spec.rb'
7
+ test.verbose = true
8
+ end
9
+
10
+ task :default => :test
@@ -18,9 +18,8 @@ Gem::Specification.new do |s|
18
18
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
19
  s.require_paths = ["lib"]
20
20
 
21
- # specify any dependencies here; for example:
22
- # s.add_development_dependency "rspec"
23
- # s.add_runtime_dependency "rest-client"
21
+ s.add_development_dependency "minitest"
22
+ s.add_development_dependency "mocha"
24
23
  s.add_runtime_dependency "thor"
25
24
  s.add_runtime_dependency "chef"
26
25
  end
@@ -30,7 +30,7 @@ module HealthInspector
30
30
  banner "Inspecting #{self.class.title}"
31
31
 
32
32
  items.each do |item|
33
- failures = checks.map { |check| run_check(check, item) }.compact
33
+ failures = run_checks(item)
34
34
 
35
35
  if failures.empty?
36
36
  print_success(item.name)
@@ -40,6 +40,10 @@ module HealthInspector
40
40
  end
41
41
  end
42
42
 
43
+ def run_checks(item)
44
+ checks.map { |check| run_check(check, item) }.compact
45
+ end
46
+
43
47
  def checks
44
48
  self.class.checks
45
49
  end
@@ -62,7 +62,7 @@ module HealthInspector
62
62
 
63
63
  def load_item_from_local(name)
64
64
  JSON.parse( File.read("#{@context.repo_path}/data_bags/#{name}.json") )
65
- rescue IOError
65
+ rescue IOError, Errno::ENOENT
66
66
  nil
67
67
  end
68
68
  end
@@ -1,3 +1,3 @@
1
1
  module HealthInspector
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
File without changes
@@ -0,0 +1,7 @@
1
+ chef_repo_dir = File.expand_path( "../", File.dirname(__FILE__) )
2
+
3
+ client_key "#{chef_repo_dir}/.chef/client.pem"
4
+ log_level :info
5
+ log_location STDOUT
6
+ cache_type "BasicFile"
7
+ cookbook_path [ "#{chef_repo_dir}/cookbooks" ]
@@ -0,0 +1,14 @@
1
+ require 'spec_helper'
2
+
3
+ describe "HealthInspector::Checklists::DataBagItems" do
4
+ subject do
5
+ HealthInspector::Checklists::DataBagItems.new(health_inspector_context)
6
+ end
7
+
8
+ it "should detect if a data bag item does not exist locally" do
9
+ subject.expects(:data_bag_items_on_server).returns( ["apps/app1"] )
10
+ subject.expects(:load_item_from_server).with("apps/app1").returns({})
11
+ failures = subject.run_checks(subject.items.first)
12
+ failures.first.include?("exists on server but not locally").must_equal true
13
+ end
14
+ end
@@ -0,0 +1,21 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'minitest/autorun'
4
+ require 'mocha'
5
+ require 'health_inspector'
6
+
7
+ module HealthInspector::SpecHelpers
8
+ def health_inspector_context
9
+ @health_inspector_context ||= begin
10
+ repo_path = File.expand_path("../chef-repo", __FILE__)
11
+
12
+ HealthInspector::Context.new( repo_path, File.join(repo_path, ".chef/knife.rb") ).tap do |context|
13
+ context.configure
14
+ end
15
+ end
16
+ end
17
+ end
18
+
19
+ class MiniTest::Unit::TestCase
20
+ include HealthInspector::SpecHelpers
21
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: health_inspector
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,33 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-04-09 00:00:00.000000000Z
12
+ date: 2012-04-13 00:00:00.000000000Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: minitest
16
+ requirement: &2154652260 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: *2154652260
25
+ - !ruby/object:Gem::Dependency
26
+ name: mocha
27
+ requirement: &2154651840 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :development
34
+ prerelease: false
35
+ version_requirements: *2154651840
14
36
  - !ruby/object:Gem::Dependency
15
37
  name: thor
16
- requirement: &2168869000 !ruby/object:Gem::Requirement
38
+ requirement: &2154651420 !ruby/object:Gem::Requirement
17
39
  none: false
18
40
  requirements:
19
41
  - - ! '>='
@@ -21,10 +43,10 @@ dependencies:
21
43
  version: '0'
22
44
  type: :runtime
23
45
  prerelease: false
24
- version_requirements: *2168869000
46
+ version_requirements: *2154651420
25
47
  - !ruby/object:Gem::Dependency
26
48
  name: chef
27
- requirement: &2168868580 !ruby/object:Gem::Requirement
49
+ requirement: &2154650960 !ruby/object:Gem::Requirement
28
50
  none: false
29
51
  requirements:
30
52
  - - ! '>='
@@ -32,7 +54,7 @@ dependencies:
32
54
  version: '0'
33
55
  type: :runtime
34
56
  prerelease: false
35
- version_requirements: *2168868580
57
+ version_requirements: *2154650960
36
58
  description: A tool to inspect your chef repo as is compares to what is on your chef
37
59
  server
38
60
  email:
@@ -63,6 +85,10 @@ files:
63
85
  - lib/health_inspector/context.rb
64
86
  - lib/health_inspector/inspector.rb
65
87
  - lib/health_inspector/version.rb
88
+ - spec/chef-repo/.chef/client.pem
89
+ - spec/chef-repo/.chef/knife.rb
90
+ - spec/data_bag_item_spec.rb
91
+ - spec/spec_helper.rb
66
92
  homepage: https://github.com/bmarini/health_inspector
67
93
  licenses: []
68
94
  post_install_message:
@@ -87,5 +113,9 @@ rubygems_version: 1.8.10
87
113
  signing_key:
88
114
  specification_version: 3
89
115
  summary: A tool to inspect your chef repo as is compares to what is on your chef server
90
- test_files: []
116
+ test_files:
117
+ - spec/chef-repo/.chef/client.pem
118
+ - spec/chef-repo/.chef/knife.rb
119
+ - spec/data_bag_item_spec.rb
120
+ - spec/spec_helper.rb
91
121
  has_rdoc: