Compare commits

..

No commits in common. "3d2ce7178ea88ee6bcc4b192306cf8c5fc6afc7c" and "753bbaebec867baab165247d2b75b29d0fab72f4" have entirely different histories.

3 changed files with 6 additions and 19 deletions

7
Cargo.lock generated
View file

@ -2,12 +2,6 @@
# It is not intended for manual editing. # It is not intended for manual editing.
version = 3 version = 3
[[package]]
name = "anyhow"
version = "1.0.88"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4e1496f8fb1fbf272686b8d37f523dab3e4a7443300055e74cdaa449f3114356"
[[package]] [[package]]
name = "block-buffer" name = "block-buffer"
version = "0.10.4" version = "0.10.4"
@ -185,7 +179,6 @@ checksum = "e86697c916019a8588c99b5fac3cead74ec0b4b819707a682fd4d23fa0ce1ba1"
name = "secrets-file-builder" name = "secrets-file-builder"
version = "0.1.0" version = "0.1.0"
dependencies = [ dependencies = [
"anyhow",
"handlebars", "handlebars",
"serde_json", "serde_json",
"url-escape", "url-escape",

View file

@ -9,7 +9,6 @@ repository = "https://git.nwex.de/networkException/secrets-file-builder"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies] [dependencies]
anyhow = "1.0.88"
handlebars = "5.1.0" handlebars = "5.1.0"
serde_json = "1.0.114" serde_json = "1.0.114"
url-escape = "0.1.1" url-escape = "0.1.1"

View file

@ -1,20 +1,16 @@
use std::env; use handlebars::{Context, Handlebars, Helper, HelperResult, JsonRender, Output, RenderContext, RenderErrorReason};
use std::fs;
use anyhow::Result;
use serde_json::{Map, Value}; use serde_json::{Map, Value};
use std::{env, error::Error};
use std::fs;
use url_escape; use url_escape;
use handlebars::{Context, Handlebars, Helper, HelperResult, JsonRender, Output, RenderContext, RenderErrorReason}; fn main() -> Result<(), Box<dyn Error>> {
fn main() -> Result<()> {
let mut handlebars = Handlebars::new(); let mut handlebars = Handlebars::new();
let path_to_contents = env::args().nth(1).expect("The first argument to be present."); let path_to_contents = env::args().nth(1).expect("The first argument to be present.");
let output_path = env::args().nth(2).expect("The second argument to be present."); let output_path = env::args().nth(2).expect("The second argument to be present.");
let contents = fs::read_to_string(path_to_contents).expect("To be able to read the contents file at the path '{path_to_contents}' passed as the first argument."); let contents = fs::read_to_string(path_to_contents).expect("To be able to open a file at the path passed as the first argument.");
let secret_inputs = env::vars().filter(|(key, _)| key.starts_with("SECRET_")); let secret_inputs = env::vars().filter(|(key, _)| key.starts_with("SECRET_"));
@ -25,8 +21,7 @@ fn main() -> Result<()> {
panic!("Secret environment variable is not in format 'name:path_to_secret'"); panic!("Secret environment variable is not in format 'name:path_to_secret'");
}; };
let secret_value = fs::read_to_string(path_to_secret) let secret_value = fs::read_to_string(path_to_secret)?;
.expect("To be able to read in secret '{secret_key}' from path '{path_to_secret}'");
println!("Registering secret '{secret_key}' from '{path_to_secret}'."); println!("Registering secret '{secret_key}' from '{path_to_secret}'.");