Secrets are persistent
This commit is contained in:
parent
72c519a23a
commit
02b54ca25d
@ -27,6 +27,18 @@ module Secrets
|
||||
end
|
||||
end
|
||||
|
||||
# Load secrets from the disk
|
||||
def self.load_secrets
|
||||
Dir.glob(Path.new(SECRET_PATH, "*")).each do |funko_dir|
|
||||
funko = File.basename(funko_dir)
|
||||
Dir.glob(Path.new(funko_dir, "*")).each do |secret_file|
|
||||
name = File.basename(secret_file)
|
||||
value = File.read(secret_file)
|
||||
SECRETS["#{funko}-#{name}"] = value
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Gets a secret in form {"name": "funko_name-secret_name", "value": "secret_value"}
|
||||
post "/secrets/" do |env|
|
||||
name = env.params.json["name"].as(String)
|
||||
@ -36,6 +48,10 @@ module Secrets
|
||||
halt env, status_code: 201, response: "Created"
|
||||
end
|
||||
|
||||
get "/secrets/" do |env|
|
||||
halt env, status_code: 200, response: SECRETS.keys.to_json
|
||||
end
|
||||
|
||||
# Deletes a secret from the disk and memory
|
||||
delete "/secrets/:name/" do |env|
|
||||
name = env.params.url["name"]
|
||||
@ -44,3 +60,5 @@ module Secrets
|
||||
halt env, status_code: 204, response: "Deleted"
|
||||
end
|
||||
end
|
||||
|
||||
Secrets.load_secrets
|
@ -1,6 +1,6 @@
|
||||
|
||||
User nobody
|
||||
Group nogroup
|
||||
LogLevel Info
|
||||
Port 8888
|
||||
Listen 0.0.0.0
|
||||
Timeout 600
|
||||
|
Loading…
Reference in New Issue
Block a user