Minor refactor
This commit is contained in:
parent
379b4e2472
commit
d93c8518da
@ -16,56 +16,54 @@ module Faaso
|
|||||||
if options["--local"]
|
if options["--local"]
|
||||||
Log.info { "Building function... #{funko.name} in #{tmp_dir}" }
|
Log.info { "Building function... #{funko.name} in #{tmp_dir}" }
|
||||||
funko.build tmp_dir
|
funko.build tmp_dir
|
||||||
else # Running against a server
|
next
|
||||||
Faaso.check_version
|
end
|
||||||
# Create a tarball for the funko
|
Faaso.check_version
|
||||||
buf = IO::Memory.new
|
# Create a tarball for the funko
|
||||||
Compress::Gzip::Writer.open(buf) do |gzip|
|
buf = IO::Memory.new
|
||||||
Crystar::Writer.open(gzip) do |tw|
|
Compress::Gzip::Writer.open(buf) do |gzip|
|
||||||
Log.debug { "Adding files to tarball" }
|
Crystar::Writer.open(gzip) do |tw|
|
||||||
Dir.glob("#{tmp_dir}/**/*").each do |path|
|
Log.debug { "Adding files to tarball" }
|
||||||
next unless File.file? path
|
Dir.glob("#{tmp_dir}/**/*").each do |path|
|
||||||
rel_path = Path[path].relative_to tmp_dir
|
next unless File.file? path
|
||||||
Log.debug { "Adding #{rel_path}" }
|
rel_path = Path[path].relative_to tmp_dir
|
||||||
file_info = File.info(path)
|
Log.debug { "Adding #{rel_path}" }
|
||||||
hdr = Crystar::Header.new(
|
file_info = File.info(path)
|
||||||
name: rel_path.to_s,
|
hdr = Crystar::Header.new(
|
||||||
mode: file_info.permissions.to_u32,
|
name: rel_path.to_s,
|
||||||
size: file_info.size,
|
mode: file_info.permissions.to_u32,
|
||||||
)
|
size: file_info.size,
|
||||||
tw.write_header(hdr)
|
)
|
||||||
tw.write(File.read(path).to_slice)
|
tw.write_header(hdr)
|
||||||
end
|
tw.write(File.read(path).to_slice)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
tmp = File.tempname
|
|
||||||
File.open(tmp, "w") do |outf|
|
|
||||||
outf << buf
|
|
||||||
end
|
|
||||||
|
|
||||||
url = "#{Config.server}funkos/build/"
|
|
||||||
|
|
||||||
begin
|
|
||||||
user, password = Config.auth
|
|
||||||
Log.info { "Uploading funko to #{Config.server}" }
|
|
||||||
Log.info { "Starting remote build:" }
|
|
||||||
Crest.post(
|
|
||||||
url,
|
|
||||||
{"funko.tgz" => File.open(tmp), "name" => "funko.tgz"},
|
|
||||||
user: user, password: password
|
|
||||||
) do |response|
|
|
||||||
loop do
|
|
||||||
Log.info { response.body_io.gets }
|
|
||||||
break if response.body_io.closed?
|
|
||||||
end
|
|
||||||
end
|
|
||||||
Log.info { "Build finished successfully." }
|
|
||||||
rescue ex : Crest::InternalServerError
|
|
||||||
Log.error(exception: ex) { "Error building funko #{funko.name} from #{funko.path}" }
|
|
||||||
return 1
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
tmp = File.tempname
|
||||||
|
File.open(tmp, "w") do |outf|
|
||||||
|
outf << buf
|
||||||
|
end
|
||||||
|
|
||||||
|
url = "#{Config.server}funkos/build/"
|
||||||
|
|
||||||
|
user, password = Config.auth
|
||||||
|
Log.info { "Uploading funko to #{Config.server}" }
|
||||||
|
Log.info { "Starting remote build:" }
|
||||||
|
Crest.post(
|
||||||
|
url,
|
||||||
|
{"funko.tgz" => File.open(tmp), "name" => "funko.tgz"},
|
||||||
|
user: user, password: password
|
||||||
|
) do |response|
|
||||||
|
loop do
|
||||||
|
Log.info { response.body_io.gets }
|
||||||
|
break if response.body_io.closed?
|
||||||
|
end
|
||||||
|
end
|
||||||
|
Log.info { "Build finished successfully." }
|
||||||
|
rescue ex : Crest::InternalServerError
|
||||||
|
Log.error(exception: ex) { "Error building funko #{funko.name} from #{funko.path}" }
|
||||||
|
return 1
|
||||||
end
|
end
|
||||||
0
|
0
|
||||||
end
|
end
|
||||||
|
@ -14,6 +14,7 @@ FaaSO CLI tool.
|
|||||||
|
|
||||||
Usage:
|
Usage:
|
||||||
faaso build FOLDER ... [-v <level>] [-l] [--no-runtime]
|
faaso build FOLDER ... [-v <level>] [-l] [--no-runtime]
|
||||||
|
faaso deploy FUNKO [-v <level>] [-l]
|
||||||
faaso export SOURCE DESTINATION [-v <level>]
|
faaso export SOURCE DESTINATION [-v <level>]
|
||||||
faaso login [-v <level>]
|
faaso login [-v <level>]
|
||||||
faaso new -r runtime FOLDER [-v <level>]
|
faaso new -r runtime FOLDER [-v <level>]
|
||||||
|
Loading…
Reference in New Issue
Block a user