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

Use tmpfile extension #3

Merged
merged 1 commit into from
May 6, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion beaker_puppet_helpers.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ Gem::Specification.new do |s|
s.require_paths = ['lib']

# Run time dependencies
s.add_runtime_dependency 'beaker', '>= 4', '< 6'
s.add_runtime_dependency 'beaker', '>= 5.8.1', '< 6'
s.add_runtime_dependency 'puppet-modulebuilder', '>= 0.3', '< 2'
end
2 changes: 1 addition & 1 deletion lib/beaker_puppet_helpers/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,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 @@ -99,8 +99,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 @@ -44,7 +44,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
2 changes: 1 addition & 1 deletion spec/beaker_puppet_helpers/module_utils_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def logger
expect(Puppet::Modulebuilder::Builder).to receive(:new).with('/path/to/module').and_return(builder)
expect(builder).to receive(:build).and_return('/path/to/tarball')

expect(host).to receive(:tmpfile).with('puppet_module').and_return('temp')
expect(host).to receive(:tmpfile).with('puppet_module', '.tar.gz').and_return('temp')
expect(host).to receive(:do_scp_to).with('/path/to/tarball', 'temp', {})
expect(dsl).to receive(:install_puppet_module_via_pmt_on).with(host, 'temp')
expect(host).to receive(:rm_rf).with('temp')
Expand Down