Open svteb opened 1 month ago
Comments from @martin-mat were correct in pointing out some unhandled cases/lack of information provided. I've come to understand the intentions behind FileUtils.rm_rf(tgz_name)
and decided to bring it back:
unless input_file && !input_file.empty?
files_to_delete = Dir.glob("#{Helm.chart_name(helm_chart)}-*.tgz") ~> addition
files_to_delete.each do |file|
FileUtils.rm(file)
puts "Deleted: #{file}"
end ~> end of addition
helm_info = Helm.pull(helm_chart)
unless helm_info[:status].success?
puts "Helm pull error".colorize(:red)
raise "Helm pull error"
end
end
It was necessary to do it like this because FileUtils.rm_rf
does not work with file globbing which was originally present. This addition also removed the necessity of checking for state where multiple versions of some helm archive were present (as they get deleted and the newest one gets pulled subsequentially).
Another mistake from the previous commit, that was undiscovered, was the necessity of moving this entire block before the block where tgz archive is being discovered, as the Helm.pull(helm_chart)
command is what downloads the tgz archive. This also makes the sequence of steps somewhat more logical:
helm_pull -> discover_tgz -> extract_tgz
whereas the previous sequence was discover_tgz -> helm_pull -> extract_tgz
.
Furthermore I added an exception that prints better information in case no tgz file is discovered.
Description
Removed file globbing as it caused errors and added a new function that will detect a specific tgz file to be untared. Removed the line:
FileUtils.rm_rf(tgz_name)
as it did not work previously and now that globbing has been fixed it would cause undesired behavior (honestly I was not able to figure out why it is there at all).Issues:
Refs: #1947
How has this been tested:
Types of changes:
Checklist:
Documentation
Code Review
Issue