Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added protective code for errors parsing with versionomy #325

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 44 additions & 29 deletions lib/onceover/controlrepo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -232,46 +232,61 @@ def print_puppetfile_table

output_array = []
threads = []
error_array = []

puppetfile.modules.each do |mod|
threads << Thread.new do
row = []
logger.debug "Loading data for #{mod.full_name}"
row << mod.full_name
if mod.is_a?(R10K::Module::Forge)
row << mod.expected_version
row << mod.v3_module.current_release.version

current = Versionomy.parse(mod.expected_version)
latest = Versionomy.parse(mod.v3_module.current_release.version)
row << if current.major < latest.major
"Major".red
elsif current.minor < latest.minor
"Minor".yellow
elsif current.tiny < latest.tiny
"Tiny".green
else
"No".green
end

row << mod.v3_module.endorsement
superseded_by = mod.v3_module.superseded_by
row << (superseded_by.nil? ? '' : superseded_by[:slug])
else
row << "N/A"
row << "N/A"
row << "N/A"
row << "N/A"
row << "N/A"
begin
row = []
logger.debug "Loading data for #{mod.full_name}"
row << mod.full_name
if mod.is_a?(R10K::Module::Forge)
row << mod.expected_version
row << mod.v3_module.current_release.version

current = Versionomy.parse(mod.expected_version)
latest = Versionomy.parse(mod.v3_module.current_release.version)

row << if current.major < latest.major
"Major".red
elsif current.minor < latest.minor
"Minor".yellow
elsif current.tiny < latest.tiny
"Tiny".green
else
"No".green
end

row << mod.v3_module.endorsement
superseded_by = mod.v3_module.superseded_by
row << (superseded_by.nil? ? '' : superseded_by[:slug])
else
row << "N/A"
row << "N/A"
row << "N/A"
row << "N/A"
row << "N/A"
end
output_array << row
rescue => e
error = []
error << mod.full_name
error << mod.expected_version
error << mod.v3_module.current_release.version
error << e.message
error_array << error
logger.debug "Error loading module #{mod.full_name} - #{e.inspect}"
end
output_array << row
end
end

threads.map(&:join)

output_array.sort_by! { |line| line[0] }
error_array.sort_by! { |line| line[0] } unless error_array.empty?

puts Terminal::Table.new(headings: ["Full Name", "Current Version", "Latest Version", "Out of Date?", "Endorsement", "Superseded by"], rows: output_array)
puts Terminal::Table.new(headings: ["Issue assessing module", "Current", "Latest", "Error"], rows: error_array) unless error_array.empty?
end

def update_puppetfile
Expand Down