Skip to content

Commit

Permalink
Use tmpfile extension
Browse files Browse the repository at this point in the history
Having a proper extension, even for temporary files is much cleaner.
  • Loading branch information
ekohl committed May 3, 2022
1 parent 422c1ec commit a8f7869
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/beaker_puppet_helpers/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ def apply_manifest_on(hosts, manifest, opts = {}, &block)

puppet_apply_opts = host[:default_apply_opts].merge(puppet_apply_opts) if host[:default_apply_opts].respond_to? :merge

file_path = host.tmpfile(%(apply_manifest_#{Time.now.strftime('%H%M%S%L')}.pp))
file_path = host.tmpfile(%(apply_manifest_#{Time.now.strftime('%H%M%S%L')}), '.pp')
begin
create_remote_file(host, file_path, "#{manifest}\n")

Expand Down
3 changes: 1 addition & 2 deletions lib/beaker_puppet_helpers/install_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,7 @@ def self.puppet_package_name(host, prefer_aio: true)
def self.wget_on(host, url)
extension = File.extname(url)
name = File.basename(url, extension)
# Can't use host.tmpfile since we need to set an extension
target = host.exec(Beaker::Command.new("mktemp -t '#{name}-XXXXXX#{extension}'")).stdout.strip
target = host.tmpfile(name, extension)
begin
host.exec(Beaker::Command.new("wget -O '#{target}' '#{url}'"))
yield target
Expand Down
2 changes: 1 addition & 1 deletion lib/beaker_puppet_helpers/module_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def install_local_module_on(hosts, source = '.')
source_path = builder.build
begin
block_on hosts do |host|
target_file = host.tmpfile('puppet_module')
target_file = host.tmpfile('puppet_module', '.tar.gz')
begin
host.do_scp_to(source_path, target_file, {})
install_puppet_module_via_pmt_on(host, target_file)
Expand Down

0 comments on commit a8f7869

Please sign in to comment.