24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
|
# File 'lib/chef/knife/env-diff.rb', line 24
def run
if name_args.size < 2
ui.error("You need to supply at least two environments")
show_usage
exit 1
end
firstenv = name_args.first
otherenvs = name_args.slice(1, name_args.length - 1)
from_env = {}
from_env[firstenv] = get_env_cookbooks(firstenv)
to_env = {}
otherenvs.each do |env_name|
to_env[env_name] = get_env_cookbooks(env_name)
end
ui.msg "diffing environment " + firstenv + " against " + otherenvs.join(', ') + "\n\n"
from_env.each_value do |from_cookbooks|
from_cookbooks.each do |from_cookbook, from_data|
diff_versions = {}
from_version = get_cookbook_version(from_data)
to_env.each do |env, to_cookbooks|
to_version = get_cookbook_version(to_cookbooks[from_cookbook])
if from_version != to_version || from_version.nil?
diff_versions[env] = to_version
end
end
unless diff_versions.empty?
ui.msg "cookbook: "+ from_cookbook
ui.msg " #{firstenv} version: #{from_version}"
diff_versions.each do |env, version|
ui.msg " #{env} version: "+ version
end
ui.msg "\n"
end
end
end
end
|