From 3bcb427dd703dcb2354a87b08beee08001acfca2 Mon Sep 17 00:00:00 2001 From: Roberto Alsina Date: Thu, 4 Jul 2024 10:38:15 -0300 Subject: [PATCH] Secrets client side implementation --- public/index.html | 13 +++++++------ src/daemon/secrets.cr | 5 +++-- src/faaso.cr | 1 + src/main.cr | 4 +++- src/secrets.cr | 4 ++-- src/views/secrets.ecr | 2 +- 6 files changed, 17 insertions(+), 12 deletions(-) diff --git a/public/index.html b/public/index.html index c7e8727..f91e483 100644 --- a/public/index.html +++ b/public/index.html @@ -66,9 +66,9 @@ - + - + diff --git a/src/daemon/secrets.cr b/src/daemon/secrets.cr index 2c95158..9226b23 100644 --- a/src/daemon/secrets.cr +++ b/src/daemon/secrets.cr @@ -34,9 +34,10 @@ module Secrets end # Deletes a secret from the disk and memory - delete "/secrets/:name/" do |env| + delete "/secrets/:funko/:name/" do |env| + funko = env.params.url["funko"] name = env.params.url["name"] - SECRETS.delete(name) + SECRETS.delete("#{funko}-#{name}") update_secrets halt env, status_code: 204, response: "Deleted" end diff --git a/src/faaso.cr b/src/faaso.cr index 65f238d..2a29444 100644 --- a/src/faaso.cr +++ b/src/faaso.cr @@ -1,6 +1,7 @@ require "./commands/build.cr" require "./commands/export.cr" require "./commands/scale.cr" +require "./commands/secret.cr" require "./commands/status.cr" require "./funko.cr" require "crest" diff --git a/src/main.cr b/src/main.cr index c3f5455..fa0bf6a 100644 --- a/src/main.cr +++ b/src/main.cr @@ -41,7 +41,7 @@ Usage: faaso scale FUNKO [SCALE] [-v=] [-l] faaso status FUNKO_NAME [-v=] [-l] faaso export SOURCE DESTINATION [-v=] - faaso secret [-d|-a] FUNKO NAME [-v=] [-l] + faaso secret [-d|-a] FUNKO SECRET [-v=] [-l] Options: -l --local Run commands locally instead of against a FaaSO server. @@ -65,4 +65,6 @@ when .fetch("scale", false) Faaso::Commands::Scale.new.run(ans, ans["FUNKO_NAME"].as(String), ans["SCALE"]) when .fetch("status", false) Faaso::Commands::Status.new.run(ans, ans["FUNKO_NAME"].as(String)) +when .fetch("secret", false) + Faaso::Commands::Secret.new.run(ans, ans["FUNKO"].as(String), ans["SECRET"].as(String)) end diff --git a/src/secrets.cr b/src/secrets.cr index 8418144..3b19774 100644 --- a/src/secrets.cr +++ b/src/secrets.cr @@ -15,9 +15,9 @@ module Secrets File.write(Path.new(funko_dir, name), value) end # Delete secrets not in the hash - Dir.glob(Path.new(SECRET_PATH, "*")).each do |funko_dir| + Dir.glob("#{SECRET_PATH}/*").each do |funko_dir| funko = File.basename(funko_dir) - Dir.glob(Path.new(funko_dir, "*")).each do |secret_file| + Dir.glob("#{funko_dir}/*").each do |secret_file| name = File.basename(secret_file) unless SECRETS.has_key?("#{funko}-#{name}") File.delete(secret_file) diff --git a/src/views/secrets.ecr b/src/views/secrets.ecr index d9899d4..3c57556 100644 --- a/src/views/secrets.ecr +++ b/src/views/secrets.ecr @@ -4,7 +4,7 @@ <%= f["name"] %> - + " src="bars.svg" class="htmx-indicator">