knife-env-diff 0.0.2 → 0.0.3

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.
@@ -32,24 +32,24 @@ module GoulahKnifePlugins
32
32
  otherenvs = name_args.slice(1, name_args.length - 1)
33
33
 
34
34
  from_env = {}
35
- env = load_environment(firstenv)
36
- from_env[firstenv] = env.cookbook_versions
35
+ from_env[firstenv] = get_env_cookbooks(firstenv)
37
36
 
38
37
  to_env = {}
39
38
  otherenvs.each do |env_name|
40
- env = load_environment(env_name)
41
- to_env[env_name] = env.cookbook_versions
39
+ to_env[env_name] = get_env_cookbooks(env_name)
42
40
  end
43
41
 
44
42
  ui.msg "diffing environment " + firstenv + " against " + otherenvs.join(', ') + "\n\n"
45
43
 
46
44
  from_env.each_value do |from_cookbooks|
47
- from_cookbooks.each do |from_cookbook, from_version|
45
+ from_cookbooks.each do |from_cookbook, from_data|
46
+ from_version = from_data["versions"].first['version']
48
47
 
49
48
  diff_versions = {}
50
49
 
51
50
  to_env.each do |to_env, to_cookbooks|
52
- to_version = to_cookbooks[from_cookbook] || "missing"
51
+ to_version = to_cookbooks[from_cookbook]["versions"].first['version']
52
+
53
53
  if from_version != to_version
54
54
  diff_versions[to_env] = to_version
55
55
  end
@@ -69,17 +69,8 @@ module GoulahKnifePlugins
69
69
 
70
70
  end
71
71
 
72
- def load_environment(env)
73
- e = Chef::Environment.load(env)
74
- return e
75
- rescue Net::HTTPServerException => e
76
- if e.response.code.to_s == "404"
77
- ui.error "The environment #{env} does not exist on the server, aborting."
78
- Chef::Log.debug(e)
79
- exit 1
80
- else
81
- raise
82
- end
72
+ def get_env_cookbooks(env)
73
+ rest.get_rest("environments/#{env}/cookbooks")
83
74
  end
84
75
 
85
76
  end
@@ -1,5 +1,5 @@
1
1
  module Knife
2
2
  module EnvironmentDiff
3
- VERSION = "0.0.2"
3
+ VERSION = "0.0.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 2
9
- version: 0.0.2
8
+ - 3
9
+ version: 0.0.3
10
10
  platform: ruby
11
11
  authors:
12
12
  - John Goulah