5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/itamae-spec/resource/file.rb', line 5
def send_tempfile
if !attributes.content && !content_file
@temppath = nil
return
end
begin
src = if content_file
content_file
else
f = Tempfile.open('itamae')
f.write(attributes.content)
f.close
f.path
end
@temppath = ::File.join(runner.tmpdir, Time.now.to_f.to_s)
if backend.is_a?(Itamae::Backend::Docker)
run_command(["mkdir", @temppath])
backend.send_file(src, @temppath)
@temppath = ::File.join(@temppath, ::File.basename(src))
elsif backend.is_a?(Itamae::Backend::Local)
run_command(["touch", @temppath])
run_specinfra(:change_file_mode, @temppath, '0600')
run_specinfra(:copy_file, src, @temppath)
else
run_command(["touch", @temppath])
run_specinfra(:change_file_mode, @temppath, '0600')
backend.send_file(src, @temppath)
end
run_specinfra(:change_file_mode, @temppath, '0600')
ensure
f.unlink if f
end
end
|