Forgotten file

This commit is contained in:
Roberto Alsina 2024-07-04 15:20:07 -03:00
parent 05438d13cf
commit 83b6615503
2 changed files with 50 additions and 0 deletions

49
src/commands/secret.cr Normal file
View File

@ -0,0 +1,49 @@
module Faaso
module Commands
struct Secret
def local(options, funko, name, secret)
if options["--add"]
dst_dir = "secrets/#{funko}"
Dir.mkdir_p(dst_dir) unless Dir.exists?(dst_dir)
File.write("#{dst_dir}/#{name}", secret)
elsif options["--delete"]
File.delete("secrets/#{funko}/#{name}")
end
end
def remote(options, funko, name, secret)
if options["--add"]
Crest.post(
"#{FAASO_SERVER}secrets/",
{
"funko" => funko,
"name" => name,
"value" => secret,
}, user: "admin", password: "admin")
Log.info { "Secret created" }
elsif options["--delete"]
Crest.delete(
"#{FAASO_SERVER}secrets/#{funko}/#{name}",
user: "admin", password: "admin")
end
rescue ex : Crest::RequestFailed
Log.error { "Error #{ex.response.status_code}" }
exit 1
end
def run(options, funko, name)
if options["--add"]
Log.info { "Enter the secret, end with Ctrl-D" } if STDIN.tty?
secret = STDIN.gets_to_end
else
secret = ""
end
if options["--local"]
return local(options, funko, name, secret)
end
remote(options, funko, name, secret)
end
end
end
end

View File

@ -48,6 +48,7 @@ localhost:8888 {
reverse_proxy /* http://#{funko}:3000
}
) }.join("\n") + "}"
# FIXME that 👆🏼 is not a functional load balancing config if scale > 1
if @@current_config != config
File.open("Caddyfile", "w") do |file|