Skip to content

Commit

Permalink
upgrade: Better repocheck output
Browse files Browse the repository at this point in the history
Table output of repocheck subcommands was very hard to understand.
Output has been modified for better user experience.
  • Loading branch information
skazi0 committed Dec 7, 2018
1 parent 18ab62e commit eb619c6
Showing 1 changed file with 43 additions and 8 deletions.
51 changes: 43 additions & 8 deletions lib/crowbar/client/command/upgrade/repocheck.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,20 +36,55 @@ def execute
request.process do |request|
case request.code
when 200
formatter = Formatter::Nested.new(
format: provide_format,
headings: ["Status", "Value"],
values: Filter::Subset.new(
filter: provide_filter,
values: request.parsed_response
).result
)
hint = ""
if provide_format == :table
response = request.parsed_response
repos = {}
response.each do |type, type_data|
type_data["repos"].each do |repo|
next if repo.nil?
repos[repo] = { repo: repo, status: [], type: type } unless repos.key? repo
end
type_data["errors"].each do |error, error_data|
error_data.each do |arch, bad_repos|
bad_repos.each do |bad_repo|
hint = "Some repopositories are not available. " \
"Fix the problem and call the step again."
repos[bad_repo][:status] << "#{error} (#{arch})"
end
end
end
end

repos.values.each do |repo|
repo[:status] = repo[:status].uniq.join(", ")
repo[:status] = "available" if repo[:status].empty?
end

formatter = Formatter::Hash.new(
format: provide_format,
headings: ["Repository", "Status", "Type"],
values: Filter::Hash.new(
filter: provide_filter,
values: repos.values
).result
)
else
formatter = Formatter::Nested.new(
format: provide_format,
values: Filter::Subset.new(
filter: provide_filter,
values: request.parsed_response
).result
)
end

if formatter.empty?
err "No repochecks"
else
say formatter.result
next unless provide_format == :table
say hint unless hint.empty?
say "Next step: 'crowbarctl upgrade admin'" if args.component == "crowbar"
say "Next step: 'crowbarctl upgrade services'" if args.component == "nodes"
end
Expand Down

0 comments on commit eb619c6

Please sign in to comment.