Skip to content

Commit

Permalink
Remove useless Dir.chdir in Terraform::Runner
Browse files Browse the repository at this point in the history
Dir.glob returns full file pathnames that have the dir_path stipped
before adding to the zipfile anyway so the Dir.chdir is entirely useless
here.
  • Loading branch information
agrare committed Sep 30, 2024
1 parent 707fe67 commit 5746b75
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions lib/terraform/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,7 @@ def encoded_zip_from_directory(template_path)
Tempfile.create(%w[opentofu-runner-payload .zip]) do |zip_file_path|
_log.debug("Create #{zip_file_path}")
Zip::File.open(zip_file_path, Zip::File::CREATE) do |zipfile|
Dir.chdir(dir_path)
Dir.glob("**/*").select { |fn| File.file?(fn) }.each do |file|
Dir.glob(File.join(dir_path, "/**/*")).select { |fn| File.file?(fn) }.each do |file|
_log.debug("Adding #{file}")
zipfile.add(file.sub("#{dir_path}/", ''), file)
end
Expand Down

0 comments on commit 5746b75

Please sign in to comment.