Use base58 for random strings
This commit is contained in:
parent
56ff326098
commit
6489ec0dc2
@ -1,3 +1,5 @@
|
||||
require "base58"
|
||||
|
||||
module Faaso
|
||||
module Commands
|
||||
# Build images for one or more funkos from source
|
||||
@ -7,7 +9,7 @@ module Faaso
|
||||
# Create temporary build location
|
||||
|
||||
funkos.each do |funko|
|
||||
tmp_dir = Path.new("tmp", UUID.random.to_s)
|
||||
tmp_dir = Path.new("tmp", Random.base58(8))
|
||||
Dir.mkdir_p(tmp_dir) unless File.exists? tmp_dir
|
||||
|
||||
funko.runtime = nil if options["--no-runtime"]
|
||||
|
@ -1,3 +1,4 @@
|
||||
require "base58"
|
||||
require "docr"
|
||||
require "kemal"
|
||||
require "../funko.cr"
|
||||
@ -34,7 +35,7 @@ module Funko
|
||||
# mosquito-cr/mosquito to make it a job queue
|
||||
post "/funkos/build/" do |env|
|
||||
# Create place to build funko
|
||||
tmp_dir = Path.new("tmp", UUID.random.to_s)
|
||||
tmp_dir = Path.new("tmp", Random.base58(8))
|
||||
Dir.mkdir_p(tmp_dir) unless File.exists? tmp_dir
|
||||
|
||||
# Expand tarball in there
|
||||
|
@ -309,7 +309,7 @@ module Funko
|
||||
)
|
||||
|
||||
docker_api = Docr::API.new(Docr::Client.new)
|
||||
response = docker_api.containers.create(name: "faaso-#{name}-#{randstr}", config: conf)
|
||||
response = docker_api.containers.create(name: "faaso-#{name}-#{Random.base58(6)}", config: conf)
|
||||
response.@warnings.each { |msg| Log.warn { msg } }
|
||||
docker_api.containers.start(response.@id) if autostart
|
||||
response.@id
|
||||
@ -349,8 +349,3 @@ module Funko
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def randstr(length = 6) : String
|
||||
chars = "abcdefghijklmnopqrstuvwxyz0123456789"
|
||||
String.new(Bytes.new(chars.to_slice.sample(length).to_unsafe, length))
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user