Skip to content

Commit

Permalink
Handle case where from_env is missing a cookbook.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeremy Voorhis committed Apr 5, 2012
1 parent 8320e99 commit 04e946f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lib/chef/knife/env-diff.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,23 @@ def run

from_env.each_value do |from_cookbooks|
from_cookbooks.each do |from_cookbook, from_data|
from_version = from_data["versions"].first['version']

diff_versions = {}

unless from_data['versions'].empty?
from_version = from_data["versions"].first['version']
end

to_env.each do |to_env, to_cookbooks|
to_version = to_cookbooks[from_cookbook]["versions"].first['version']

if from_version != to_version
if from_version != to_version || from_version.nil?
diff_versions[to_env] = to_version
end
end

unless diff_versions.empty?
ui.msg "cookbook: "+ from_cookbook
ui.msg " #{firstenv} version: "+ from_version
ui.msg " #{firstenv} version: "+ (from_version || 'none')
diff_versions.each do |env, version|
ui.msg " #{env} version: "+ version
end
Expand Down

0 comments on commit 04e946f

Please sign in to comment.