knife-update 0.0.7 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MTMzZjEzNmJkOTA5MzZlZGQyNTM1NmE5NDJmYWViNWE3NmE4Y2E5Ng==
4
+ MjdlY2Q1MDg5MmFiYWExMmIyMTI0YjBjN2ZlYWVjYjJlNjI3MmRmNQ==
5
5
  data.tar.gz: !binary |-
6
- NDFkYWFjNDRlY2NhMzI5MmI3YmUxNGVhY2VhOTg4OWQ2NzAyYjNkNg==
6
+ ZTU4ZGVlMzc0MWM5ZDM1NDcxYjAzZDFhZjNhMWE0YWQ5ODZhOTY2Yg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- YjMyN2EyYmQ4NzExOWJjMDYxM2ZmOGFlNmYzYzc4NzVmMmJjYzgxM2EzZWVm
10
- MDYyYWMxNTI5NGM2Mjc1ZTc4ZGQ3M2JlNWFkNjg0MWU0NTE5YWMyNTFlNjVl
11
- NDBiYjdmZjQ5MmRhMTUyMjRjMTMwZGY4MWI1OTkyNjc5MzAwNjc=
9
+ M2E1OGFjMmU4ZmI4NmI2NGEyNTc2MGM5ZGIwMTNlMjk0ZjA3NDgyYzJjMzNl
10
+ NGEzMmVkNTI4ZDJhZDE5ZTkzZDI4MGU1ZWQyYmYzZTM1M2UyMzVhZGQzNzZj
11
+ N2YwZWFiN2Y5YThhNzY0YWE0NjAwMjZiNTM3NjgzMDAxZmEzMmI=
12
12
  data.tar.gz: !binary |-
13
- ZWQ0MjUwNDEyMWEwNzUwNWIzM2JhMzkzNjFhNmNiYTU5ODdlM2JlY2M3ZDNm
14
- YTdiODQ1NjU1MDEyY2FhOTM5NzdmYjFkMTM2NjUyYzdiMTAxNzc3OGY5ZjIy
15
- YmIyNzIyNTJkM2FhMWI3ZjcwZmQ4NzA5NWI3N2RjMDc1OGJkOGE=
13
+ MGZiNzdlYTkyYTk3ZmNiODliMWQ3MmUxODM3YTMyYjlkMjZiM2NjNzNiMGQy
14
+ MWJiZjE1MmJiZmQyN2I1Njk4NDAyMGJiNzRmYTMyNGFmZTg0ZWUwZWZiZDY2
15
+ Y2Y4ZTEzMTFhYjZiZDc1OWQxZjMxNWQzNmRiYTViOTIxMWU5NDQ=
@@ -69,9 +69,10 @@ class Chef
69
69
 
70
70
  # List of all compatible recipes
71
71
  def recipes(nodes)
72
- nodes.inject([]) do |memo, node|
72
+ nodes.inject({}) do |memo, node|
73
73
  node.recipes.each do |recipe|
74
- memo << recipe.to_s unless memo.include?(recipe.to_s)
74
+ memo[recipe.to_s] ||= 0
75
+ memo[recipe.to_s] += 1
75
76
  end
76
77
 
77
78
  memo
@@ -28,11 +28,12 @@ class Chef
28
28
  def run
29
29
  list = node_list
30
30
  compatible = recipes(only(list, target_version))
31
- unknown = recipes(except(list, target_version)) - compatible
31
+ old = recipes(except(list, target_version))
32
+ unknown = compatible.each { |recipe, _| old.delete(recipe) }
32
33
 
33
34
  if compatible.any?
34
35
  ui.msg "recipes already used on Chef #{target_version}:"
35
- compatible.sort.each do |item|
36
+ compatible.sort_by { |k, _| k }.each do |item, _|
36
37
  ui.msg " #{item}"
37
38
  end
38
39
  ui.msg ''
@@ -40,8 +41,8 @@ class Chef
40
41
 
41
42
  if unknown.any?
42
43
  ui.msg "recipes not used on Chef #{target_version}:"
43
- unknown.sort.each do |item|
44
- ui.msg " #{item}"
44
+ unknown.sort_by { |k, _| k }.each do |item, nodes|
45
+ ui.msg " #{item} (used on #{nodes} nodes)"
45
46
  end
46
47
  ui.msg ''
47
48
  end
@@ -86,7 +86,7 @@ class Chef
86
86
  nodes = list.inject([]) do |memo, (version, nodes)|
87
87
  if version != target_version
88
88
  nodes.each do |node|
89
- if config[:force] || node.recipes.all? { |recipe| compatible.include?(recipe) }
89
+ if config[:force] || node.recipes.all? { |recipe| compatible.keys.include?(recipe) }
90
90
  memo << node
91
91
  end
92
92
  end
@@ -96,7 +96,7 @@ class Chef
96
96
  end
97
97
 
98
98
  if config[:force] && unknown.any?
99
- ui.warn "It's unknown if the following recipes are Chef #{target_version} compatible: #{unknown.sort.join(', ')}"
99
+ ui.warn "It's unknown if the following recipes are Chef #{target_version} compatible: #{unknown.keys.sort.join(', ')}"
100
100
  end
101
101
 
102
102
  if nodes.size > 0
@@ -18,7 +18,7 @@
18
18
 
19
19
  module Knife
20
20
  module Update
21
- VERSION = '0.0.7'
21
+ VERSION = '0.1.0'
22
22
  MAJOR, MINOR, TINY = VERSION.split('.')
23
23
  end
24
24
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-update
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Schmidt
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-25 00:00:00.000000000 Z
11
+ date: 2013-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chef
@@ -83,4 +83,3 @@ signing_key:
83
83
  specification_version: 4
84
84
  summary: knife update plugin
85
85
  test_files: []
86
- has_rdoc: