knife-tidy 2.1.6 → 2.3.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6df7a5c7edcbf10d78ed4f4702b68e231b3f016308280b979bdd84928af0362e
4
- data.tar.gz: ae670780d34592914ddf4eba0ba67e3a4fd5a54fe49a0d8a4a9425e5c92aa1c0
3
+ metadata.gz: 6c2702f9782813c2c218f78232a3d174459c457d55c5384a52b10d23a0ac28bb
4
+ data.tar.gz: d0212907d1f8d6b8287e76f12ecac60bcecfb7dd9ca614a48a06b6d3322f0dca
5
5
  SHA512:
6
- metadata.gz: 41fc026a4bb68574ee10ddceb69414868ae4b031f995b6a0e11b86574f579215576b7763c906739c63132d2bf62f886a645dc0b2791bd71683f3ed441d4f7932
7
- data.tar.gz: 5e3e481f0e98d4bc141773ef92e6bf0c457678790fac6b7e36acf20e5d2da6365c8d0f8f23ce734fc118b217a73a6b994d7c3bfa79837b4540d8816e02d58227
6
+ metadata.gz: 5f31036894ee89b00964d0a6c94297935f6c8824414c90e09005d8ac9ab45399d56b430ca4f1b941cbeadd9b1b177d76963e2f85c81d2a288e3d611301479fb9
7
+ data.tar.gz: 7e93f0b7404db7453bac17ebd260a6e31e9ff72a1425353ad6331dc3bcbc3728226bc4ad9587d6c346b0036d36e416dc1f147105fa5e5dbf60eb1bd7b9a9ebed
@@ -130,10 +130,10 @@ class Chef
130
130
 
131
131
  def add_cookbook_name_to_metadata(cookbook_name, rb_path)
132
132
  ui.stdout.puts "REPAIRING: Correcting `name` in #{rb_path}"
133
- content = IO.readlines(rb_path)
133
+ content = File.readlines(rb_path)
134
134
  new_content = content.reject { |line| line =~ /^name\s+/ }
135
135
  name_field = "name '#{cookbook_name}'\n"
136
- IO.write rb_path, name_field + new_content.join("")
136
+ File.write(rb_path, name_field + new_content.join(""))
137
137
  end
138
138
 
139
139
  def fix_cookbook_names(org)
@@ -354,23 +354,19 @@ class Chef
354
354
  rl = Chef::RunList.new
355
355
  new_role["run_list"] = []
356
356
  the_role["run_list"].each do |item|
357
- begin
358
- rl << item
359
- new_role["run_list"].push(item)
360
- rescue ArgumentError
361
- ui.stdout.puts "REPAIRING: Invalid Recipe Item: #{item} in run_list from #{role_path}"
362
- end
357
+ rl << item
358
+ new_role["run_list"].push(item)
359
+ rescue ArgumentError
360
+ ui.stdout.puts "REPAIRING: Invalid Recipe Item: #{item} in run_list from #{role_path}"
363
361
  end
364
362
  if the_role.key?("env_run_lists")
365
363
  the_role["env_run_lists"].each_pair do |key, value|
366
364
  new_role["env_run_lists"][key] = []
367
365
  value.each do |item|
368
- begin
369
- rl << item
370
- new_role["env_run_lists"][key].push(item)
371
- rescue ArgumentError
372
- ui.stdout.puts "REPAIRING: Invalid Recipe Item: #{item} in env_run_lists #{key} from #{role_path}"
373
- end
366
+ rl << item
367
+ new_role["env_run_lists"][key].push(item)
368
+ rescue ArgumentError
369
+ ui.stdout.puts "REPAIRING: Invalid Recipe Item: #{item} in env_run_lists #{key} from #{role_path}"
374
370
  end
375
371
  end
376
372
  end
@@ -84,15 +84,13 @@ class Chef
84
84
  ui.info("Fetching report data for organization #{org}")
85
85
  reports[org] = {}
86
86
  report_file_suffixes.each do |report|
87
- begin
88
- file_name = "#{reports_dir}/#{org}#{report}"
89
- ui.info(" Parsing file #{file_name}")
90
- json_string = File.read(file_name)
91
- reports[org][report] = tidy.json_file_to_hash(json_string, symbolize_names: false)
92
- rescue Errno::ENOENT
93
- ui.info(" Skipping file #{file_name} - not found for organization #{org}")
94
- reports[org][report] = {}
95
- end
87
+ file_name = "#{reports_dir}/#{org}#{report}"
88
+ ui.info(" Parsing file #{file_name}")
89
+ json_string = File.read(file_name)
90
+ reports[org][report] = tidy.json_file_to_hash(json_string, symbolize_names: false)
91
+ rescue Errno::ENOENT
92
+ ui.info(" Skipping file #{file_name} - not found for organization #{org}")
93
+ reports[org][report] = {}
96
94
  end
97
95
 
98
96
  # Fetch a list of admin users for the current organization
@@ -196,9 +196,9 @@ class Chef
196
196
  dirs = path.split(File::SEPARATOR)
197
197
 
198
198
  until dirs.empty?
199
- version_match = dirs[-1].match(/\d+\.\d+\.\d+/)
200
- if dirs[-2] == "cookbooks" && version_match # we found the cookbook version not something that looks like one inside a cookbook path
201
- return version_match.to_s
199
+ version_match = dirs[-1][/\b\d{1,3}\.\d{1,3}\.\d{1,3}\b/]
200
+ if dirs.length >= 2 && dirs[-2] == "cookbooks" && version_match
201
+ return version_match
202
202
  else
203
203
  dirs.pop
204
204
  end
@@ -1,4 +1,4 @@
1
1
  module KnifeTidy
2
- VERSION = "2.1.6".freeze
2
+ VERSION = "2.3.0".freeze
3
3
  MAJOR, MINOR, TINY = VERSION.split(".")
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-tidy
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.6
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chef Software, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-03-18 00:00:00.000000000 Z
11
+ date: 2025-08-16 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Report on stale Chef Infra Server nodes and cookbooks and clean up data
14
14
  integrity issues in a knife-ec-backup object based backup
@@ -42,14 +42,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
42
42
  requirements:
43
43
  - - ">="
44
44
  - !ruby/object:Gem::Version
45
- version: 2.3.0
45
+ version: 2.7.0
46
46
  required_rubygems_version: !ruby/object:Gem::Requirement
47
47
  requirements:
48
48
  - - ">="
49
49
  - !ruby/object:Gem::Version
50
50
  version: '0'
51
51
  requirements: []
52
- rubygems_version: 3.1.4
52
+ rubygems_version: 3.3.27
53
53
  signing_key:
54
54
  specification_version: 4
55
55
  summary: Report on stale Chef Infra Server nodes and cookbooks and clean up data integrity