knife-tidy 2.1.2 → 2.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ebbadbfe49e6402c189f63e8e0290eeb93d409f89f4220ef9ad6bdc96b0b455f
4
- data.tar.gz: ee7f3392eac804aeec3490c33c1e02d9d22d1bd038f3a1eb8222fd9d9c660dd9
3
+ metadata.gz: 6df7a5c7edcbf10d78ed4f4702b68e231b3f016308280b979bdd84928af0362e
4
+ data.tar.gz: ae670780d34592914ddf4eba0ba67e3a4fd5a54fe49a0d8a4a9425e5c92aa1c0
5
5
  SHA512:
6
- metadata.gz: e78b266e0482121cd3d551a9d683cd79b85aae16bb31d53260c2c73a7ceae1080052cd582957b55a23099c7799ed8312e0a5fcde1b920640497af04872894ab7
7
- data.tar.gz: b1e97749b9ed73fe512b76a45291541b070eb730ded2f86dc4de1f355258e319017338e183c53a0dd2b4671f98a513ba4a5ca69053e6dc834359f396e15257ee
6
+ metadata.gz: 41fc026a4bb68574ee10ddceb69414868ae4b031f995b6a0e11b86574f579215576b7763c906739c63132d2bf62f886a645dc0b2791bd71683f3ed441d4f7932
7
+ data.tar.gz: 5e3e481f0e98d4bc141773ef92e6bf0c457678790fac6b7e36acf20e5d2da6365c8d0f8f23ce734fc118b217a73a6b994d7c3bfa79837b4540d8816e02d58227
@@ -19,8 +19,8 @@ class Chef
19
19
 
20
20
  option :keep_versions,
21
21
  long: "--keep-versions MIN",
22
- default: 0,
23
- description: "Keep a minimum of this many versions of each cookbook (default: 0)"
22
+ default: 1,
23
+ description: "Keep a minimum of this many versions of each cookbook (default: 1)"
24
24
 
25
25
  def run
26
26
  ensure_reports_dir!
@@ -82,8 +82,6 @@ class Chef
82
82
  end
83
83
  end
84
84
 
85
- used_cookbooks = keep_cookbook_versions(cb_list, keep_versions)
86
-
87
85
  Chef::Log.debug("Used cookbook list before checking environments: #{used_cookbooks}")
88
86
  pins = environment_constraints(org)
89
87
  used_cookbooks = check_environment_pins(used_cookbooks, pins, cb_list)
@@ -98,7 +96,7 @@ class Chef
98
96
  stale_nodes_hash = { 'threshold_days': node_threshold, 'org_total_node_count': nodes.count, 'count': stale_nodes.count, 'list': stale_nodes }
99
97
  stale_orgs.push(org) if stale_nodes.count == nodes.count
100
98
 
101
- tidy.write_new_file(unused_cookbooks(used_cookbooks, cb_list), ::File.join(tidy.reports_dir, "#{org}_unused_cookbooks.json"), backup = false)
99
+ tidy.write_new_file(unused_cookbooks(used_cookbooks, cb_list, keep_versions), ::File.join(tidy.reports_dir, "#{org}_unused_cookbooks.json"), backup = false)
102
100
  tidy.write_new_file(version_count, ::File.join(tidy.reports_dir, "#{org}_cookbook_count.json"), backup = false)
103
101
  tidy.write_new_file(stale_nodes_hash, ::File.join(tidy.reports_dir, "#{org}_stale_nodes.json"), backup = false)
104
102
 
@@ -162,15 +160,6 @@ class Chef
162
160
  cb_list
163
161
  end
164
162
 
165
- def keep_cookbook_versions(cb_list, min)
166
- retain = {}
167
- cb_list.each do |name, versions|
168
- keep = versions.sort { |a, b| Gem::Version.new(a) <=> Gem::Version.new(b) }.last(min)
169
- retain[name] = keep
170
- end
171
- retain
172
- end
173
-
174
163
  def cookbook_count(cb_list)
175
164
  cb_count_list = {}
176
165
  cb_list.each do |name, versions|
@@ -179,14 +168,14 @@ class Chef
179
168
  cb_count_list
180
169
  end
181
170
 
182
- def unused_cookbooks(used_list, cb_list)
171
+ def unused_cookbooks(used_list, cb_list, keep_versions)
183
172
  unused_list = {}
184
173
  cb_list.each do |name, versions|
185
174
  versions.sort! { |a, b| Gem::Version.new(a) <=> Gem::Version.new(b) }
186
175
  if used_list[name].nil? # Not in the used list at all (Remove all versions)
187
176
  unused_list[name] = versions
188
177
  elsif used_list[name].sort != versions # Is in the used cookbook list, but version arrays do not match (Find unused versions)
189
- unused = versions - used_list[name] - [versions.last] # Don't delete the most recent version as it might not be in a run_list yet.
178
+ unused = versions - used_list[name] - versions.last(keep_versions) # Don't delete the X most recent version as it might not be in a run_list yet.
190
179
  unused_list[name] = unused unless unused.empty?
191
180
  end
192
181
  end
@@ -1,4 +1,4 @@
1
1
  module KnifeTidy
2
- VERSION = "2.1.2".freeze
2
+ VERSION = "2.1.6".freeze
3
3
  MAJOR, MINOR, TINY = VERSION.split(".")
4
4
  end
metadata CHANGED
@@ -1,19 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-tidy
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.2
4
+ version: 2.1.6
5
5
  platform: ruby
6
6
  authors:
7
- - Jeremy Miller
7
+ - Chef Software, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-21 00:00:00.000000000 Z
11
+ date: 2022-03-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Report on stale Chef Server nodes and cookbooks and clean up data integrity
14
- issues in a knife-ec-backup object based backup
13
+ description: Report on stale Chef Infra Server nodes and cookbooks and clean up data
14
+ integrity issues in a knife-ec-backup object based backup
15
15
  email:
16
- - jmiller@chef.io
16
+ - oss@chef.io
17
17
  executables: []
18
18
  extensions: []
19
19
  extra_rdoc_files: []
@@ -30,7 +30,7 @@ files:
30
30
  - lib/chef/tidy_server.rb
31
31
  - lib/chef/tidy_substitutions.rb
32
32
  - lib/knife-tidy/version.rb
33
- homepage: https://github.com/chef-customers/knife-tidy
33
+ homepage: https://github.com/chef/knife-tidy
34
34
  licenses:
35
35
  - Apache-2.0
36
36
  metadata: {}
@@ -49,9 +49,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
49
49
  - !ruby/object:Gem::Version
50
50
  version: '0'
51
51
  requirements: []
52
- rubygems_version: 3.0.3
52
+ rubygems_version: 3.1.4
53
53
  signing_key:
54
54
  specification_version: 4
55
- summary: Report on stale Chef Server nodes and cookbooks and clean up data integrity
55
+ summary: Report on stale Chef Infra Server nodes and cookbooks and clean up data integrity
56
56
  issues in a knife-ec-backup object based backup
57
57
  test_files: []