knife-verschart 2.7.3 → 2.7.4

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.
Files changed (2) hide show
  1. data/lib/chef/knife/Verschart.rb +46 -31
  2. metadata +2 -2
@@ -11,19 +11,24 @@ end
11
11
 
12
12
  module Verschart
13
13
  class Verschart < Chef::Knife
14
- banner 'knife verschart [-e env[,env,...]] [[-o| --env_order] env[,env,...]]'
14
+ banner 'knife verschart [--primary env[,env,...]] [[-o| --env_order] env[,env,...]] [[--cbselect] cookbook[,cookbook,...]]'
15
15
 
16
16
  option :primary,
17
- :short => "-e env[,env,...]",
17
+ :long => "--primary env[,env,...]",
18
18
  :description => "A comma-separated list of environments to be considered primary. Versions which are NOT frozen willl be highlighted red.",
19
19
  :proc => Proc.new { |primary| Chef::Config[:knife][:primary] = primary.split(',') }
20
20
 
21
21
  option :envorder,
22
22
  :short => "-o env[,env,....]",
23
23
  :long => "--env_order env[,env,....]",
24
- :description => "A comma-separated list of environments to establish an display order. Any existing environments not included in this list will be added at the end",
24
+ :description => "A comma-separated list of environments to establish a display order. Any existing environments not included in this list will be added at the end",
25
25
  :proc => Proc.new { |envorder| Chef::Config[:knife][:envorder] = envorder.split(',') }
26
26
 
27
+ option :cbselect,
28
+ :long => "--cbselect cookbook[,cookbook,....]",
29
+ :description => "A comma-separated list of cookbooks to include in the chart",
30
+ :proc => Proc.new { |cbselect| Chef::Config[:knife][:cbselect] = cbselect.split(',') }
31
+
27
32
  def run
28
33
  # Load Options
29
34
  primary = config[:primary] || []
@@ -31,6 +36,7 @@ module Verschart
31
36
  envorder = []
32
37
  envorder = order.split(',') unless order.empty?
33
38
  srv = server_url.sub(%r{https://}, '').sub(/:[0-9]*$/, '')
39
+ cbselect = config[:cbselect] || []
34
40
 
35
41
  # Opening output
36
42
  ui.info('')
@@ -77,21 +83,28 @@ module Verschart
77
83
  charthash['Latest'] = Hash.new
78
84
  charthash['Cookbooks'] = Hash.new
79
85
  charthash['Latest']['col'] = 12
86
+ r = Regexp.union(cbselect)
80
87
  server_side_cookbooks = Chef::CookbookVersion.list
81
88
  server_side_cookbooks.each do |svcb|
82
- fm = Chef::CookbookVersion.load(svcb[0])
83
- cblen = fm.metadata.name.length if fm.metadata.name.length > cblen
84
- charthash['Latest'][fm.metadata.name] = Hash.new(0)
85
- charthash['Cookbooks'][fm.metadata.name] = Hash.new(0)
86
- charthash['Latest'][fm.metadata.name]['vs'] = fm.metadata.version.to_s
87
- charthash['Cookbooks'][fm.metadata.name]['vs'] = fm.metadata.name
88
- if fm.frozen_version?
89
- charthash['Latest'][fm.metadata.name]['teal'] = true
90
- else
91
- charthash['Latest'][fm.metadata.name]['teal'] = false
89
+ select_match = false
90
+ if !cbselect.empty? && r =~ svcb[0]
91
+ select_match = true
92
92
  end
93
- charthash['Latest'][fm.metadata.name]['bold'] = false
94
- charthash['Latest'][fm.metadata.name]['red'] = false
93
+ if cbselect.empty? || select_match
94
+ fm = Chef::CookbookVersion.load(svcb[0])
95
+ cblen = fm.metadata.name.length if fm.metadata.name.length > cblen
96
+ charthash['Latest'][fm.metadata.name] = Hash.new(0)
97
+ charthash['Cookbooks'][fm.metadata.name] = Hash.new(0)
98
+ charthash['Latest'][fm.metadata.name]['vs'] = fm.metadata.version.to_s
99
+ charthash['Cookbooks'][fm.metadata.name]['vs'] = fm.metadata.name
100
+ if fm.frozen_version?
101
+ charthash['Latest'][fm.metadata.name]['teal'] = true
102
+ else
103
+ charthash['Latest'][fm.metadata.name]['teal'] = false
104
+ end
105
+ charthash['Latest'][fm.metadata.name]['bold'] = false
106
+ charthash['Latest'][fm.metadata.name]['red'] = false
107
+ end
95
108
  end
96
109
 
97
110
  # Set first column width
@@ -172,23 +185,25 @@ module Verschart
172
185
  end
173
186
  end
174
187
 
175
- # Look for obsolete constraints
176
- hd = 0 # Flag for section header
177
- ev = 0 # Flag for Environent header
178
-
179
- envs.each do |env|
180
- charthash[env].keys.each do |ckbk|
181
- unless charthash['Cookbooks'].has_key?(ckbk)
182
- unless hd == 1
183
- ui.info('')
184
- ui.info('Obsolete Version constraints are listed below')
185
- hd = 1
186
- end
187
- unless ev == 1
188
- ui.info('')
189
- ui.info(env)
188
+ if cbselect.empty?
189
+ # Look for obsolete constraints
190
+ hd = 0 # Flag for section header
191
+ ev = 0 # Flag for Environent header
192
+
193
+ envs.each do |env|
194
+ charthash[env].keys.each do |ckbk|
195
+ unless charthash['Cookbooks'].has_key?(ckbk)
196
+ unless hd == 1
197
+ ui.info('')
198
+ ui.info('Obsolete Version constraints are listed below')
199
+ hd = 1
200
+ end
201
+ unless ev == 1
202
+ ui.info('')
203
+ ui.info(env)
204
+ end
205
+ ui.info("-- #{ckbk} #{charthash[env][ckbk]['vs']}")
190
206
  end
191
- ui.info("-- #{ckbk} #{charthash[env][ckbk]['vs']}")
192
207
  end
193
208
  end
194
209
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-verschart
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.3
4
+ version: 2.7.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-09-27 00:00:00.000000000 Z
12
+ date: 2014-09-29 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description:
15
15
  email: chazzly@gmail.com