From 472ccb2a43176fc94adec8251e3343feabe2f065 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Thu, 2 May 2024 01:02:17 -0700 Subject: [PATCH 01/11] feat: add dotenv-vault CLI --- .github/workflows/ci.yml | 4 ++ .vscode/settings.json | 4 ++ Cargo.toml | 11 +++++ README.md | 14 ++++++ src/main.rs | 94 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 127 insertions(+) create mode 100644 .vscode/settings.json create mode 100644 src/main.rs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 767ddc7..b68bbe3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -35,6 +35,10 @@ jobs: with: command: test + - name: Build CLI + run: | + cargo build --bin dotenv-vault --features=cli + clippy: runs-on: ubuntu-latest steps: diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..457c5fe --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "rust-analyzer.cargo.features": "all", + "rust-analyzer.cargo.allTargets": true, +} diff --git a/Cargo.toml b/Cargo.toml index 2604154..652700c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,8 +11,19 @@ license = "MIT" edition = "2021" rust-version = "1.64.0" +[[bin]] +name = "dotenv-vault" +required-features = ["cli"] + +[lib] + +[features] +default = [] +cli = ["dep:argh"] + [dependencies] aes-gcm = "0.10.2" +argh = { version = "0.1.12", optional = true } base64 = "0.21.2" dotenvy = "0.15.7" hex = "0.4.3" diff --git a/README.md b/README.md index 96d42f4..3556907 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,20 @@ The extended standard lets you load encrypted secrets from your `.env.vault` fil * [FAQ](#faq) * [Changelog](./CHANGELOG.md) +## Install CLI + +The dotenv-vault CLI allows loading the `.env.vault` file and run the given program with the environment variables set. + +```shell +cargo install dotenv-vault --features cli +``` + +## Usage CLI + +```shell +dotenv-vault run -- some_program arg1 arg2 +``` + ## Install ```shell diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..cb0e6f7 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,94 @@ +use argh::FromArgs; +use dotenv_vault::dotenv; +use std::env; +use std::process::{exit, Command}; + +#[derive(FromArgs, PartialEq, Debug)] +/// The CLI program to load the .env.vault file and run the specified program with the specified arguments. +/// +/// You have to set the DOTENV_KEY environment variable before calling dotenv-vault. +/// +/// Example: +/// dotenv-vault run -- my_program arg1 arg2 +struct Opts { + #[argh(subcommand)] + commands: Commands, + + #[argh(switch, long = "override")] + /// whether to override the existing environment variables + override_: bool, + + #[argh(positional)] + /// the separator + separator: String, + + #[argh(positional)] + /// the program to run + program: String, + + #[argh(positional)] + /// the arguments to pass to the program + program_args: Vec, +} + +#[derive(FromArgs, PartialEq, Debug)] +#[argh(subcommand)] +enum Commands { + Run(Run), +} + +#[derive(FromArgs, PartialEq, Debug)] +/// Load the .env.vault file and run the specified program with the specified arguments. +#[argh(subcommand, name = "run")] +struct Run {} + +#[derive(Debug)] +#[repr(i32)] +enum CLIError { + Separator, + EnvLoad, + EnvOverrideLoad, + ProgramExecution, +} + +fn main() { + let opts = argh::from_env::(); + + // Check if the separator is correct + if opts.separator != "--" { + eprintln!("Invalid separator: {}. Expected --", opts.separator); + exit(CLIError::Separator as i32); + } + + // Load the .env.vault file + if opts.override_ { + dotenv().unwrap_or_else(|err| { + eprintln!("{}", err); + exit(CLIError::EnvOverrideLoad as i32); + }); + } else { + dotenv_vault::dotenv().unwrap_or_else(|err| { + eprintln!("{}", err); + exit(CLIError::EnvLoad as i32); + }); + }; + + // Run the specified program with the specified arguments + let output = Command::new(opts.program) + .args(opts.program_args) + .envs(env::vars()) + .output() + .unwrap_or_else(|err| { + eprintln!("Failed to execute program: {}", err); + exit(CLIError::ProgramExecution as i32); + }); + + if !output.status.success() { + exit( + output + .status + .code() + .unwrap_or(CLIError::ProgramExecution as i32), + ); + } +} From 4deaebc6e979d2a4c98616e77e08574eb2636923 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Thu, 2 May 2024 01:36:47 -0700 Subject: [PATCH 02/11] fix: fix command and separator parsing in CLI --- src/main.rs | 100 ++++++++++++++++++++++++---------------------------- 1 file changed, 46 insertions(+), 54 deletions(-) diff --git a/src/main.rs b/src/main.rs index cb0e6f7..5aab101 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,4 @@ use argh::FromArgs; -use dotenv_vault::dotenv; use std::env; use std::process::{exit, Command}; @@ -13,15 +12,22 @@ use std::process::{exit, Command}; struct Opts { #[argh(subcommand)] commands: Commands, +} + +#[derive(FromArgs, PartialEq, Debug)] +#[argh(subcommand)] +enum Commands { + Run(Run), +} +#[derive(FromArgs, PartialEq, Debug)] +/// Load the .env.vault file and run the specified program with the specified arguments. +#[argh(subcommand, name = "run")] +struct Run { #[argh(switch, long = "override")] /// whether to override the existing environment variables override_: bool, - #[argh(positional)] - /// the separator - separator: String, - #[argh(positional)] /// the program to run program: String, @@ -31,64 +37,50 @@ struct Opts { program_args: Vec, } -#[derive(FromArgs, PartialEq, Debug)] -#[argh(subcommand)] -enum Commands { - Run(Run), -} - -#[derive(FromArgs, PartialEq, Debug)] -/// Load the .env.vault file and run the specified program with the specified arguments. -#[argh(subcommand, name = "run")] -struct Run {} - #[derive(Debug)] #[repr(i32)] enum CLIError { - Separator, - EnvLoad, - EnvOverrideLoad, - ProgramExecution, + EnvLoad = 1, + EnvOverrideLoad = 2, + ProgramExecution = 3, } fn main() { let opts = argh::from_env::(); - // Check if the separator is correct - if opts.separator != "--" { - eprintln!("Invalid separator: {}. Expected --", opts.separator); - exit(CLIError::Separator as i32); - } - - // Load the .env.vault file - if opts.override_ { - dotenv().unwrap_or_else(|err| { - eprintln!("{}", err); - exit(CLIError::EnvOverrideLoad as i32); - }); - } else { - dotenv_vault::dotenv().unwrap_or_else(|err| { - eprintln!("{}", err); - exit(CLIError::EnvLoad as i32); - }); - }; + match opts.commands { + Commands::Run(run_opts) => { + // Load the .env.vault file + if run_opts.override_ { + dotenv_vault::dotenv_override().unwrap_or_else(|err| { + eprintln!("Failed to load env: {}", err); + exit(CLIError::EnvOverrideLoad as i32); + }); + } else { + dotenv_vault::dotenv().unwrap_or_else(|err| { + eprintln!("Failed to load env: {}", err); + exit(CLIError::EnvLoad as i32); + }); + }; - // Run the specified program with the specified arguments - let output = Command::new(opts.program) - .args(opts.program_args) - .envs(env::vars()) - .output() - .unwrap_or_else(|err| { - eprintln!("Failed to execute program: {}", err); - exit(CLIError::ProgramExecution as i32); - }); + // Run the specified program with the specified arguments + let output = Command::new(run_opts.program) + .args(run_opts.program_args) + .envs(env::vars()) + .output() + .unwrap_or_else(|err| { + eprintln!("Failed to execute program: {}", err); + exit(CLIError::ProgramExecution as i32); + }); - if !output.status.success() { - exit( - output - .status - .code() - .unwrap_or(CLIError::ProgramExecution as i32), - ); + if !output.status.success() { + exit( + output + .status + .code() + .unwrap_or(CLIError::ProgramExecution as i32), + ); + } + } } } From 8df481f16523a8d633bfb0cf4f50a82500a9d9f0 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Thu, 2 May 2024 01:38:15 -0700 Subject: [PATCH 03/11] fix: log into stderr instead of stdout --- src/log.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/log.rs b/src/log.rs index bdd3b0e..49df87c 100644 --- a/src/log.rs +++ b/src/log.rs @@ -7,7 +7,7 @@ macro_rules! log_fn { where T: Display, { - println!( + eprintln!( "[dotenv-vault@{}][{}] {}", env!("CARGO_PKG_VERSION"), $level, From ba942a2063cf48a4c45b996660c377e16bea0825 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Thu, 2 May 2024 01:45:13 -0700 Subject: [PATCH 04/11] fix: pipe the stdio for the executed program --- src/main.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 5aab101..ddb50dd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,6 @@ use argh::FromArgs; use std::env; -use std::process::{exit, Command}; +use std::process::{exit, Command, Stdio}; #[derive(FromArgs, PartialEq, Debug)] /// The CLI program to load the .env.vault file and run the specified program with the specified arguments. @@ -67,6 +67,9 @@ fn main() { let output = Command::new(run_opts.program) .args(run_opts.program_args) .envs(env::vars()) + .stdin(Stdio::inherit()) + .stdout(Stdio::inherit()) + .stderr(Stdio::inherit()) .output() .unwrap_or_else(|err| { eprintln!("Failed to execute program: {}", err); From c496311d1cced1285f7ca6e35b2606d6cf81c254 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Thu, 2 May 2024 01:48:47 -0700 Subject: [PATCH 05/11] test: add dotenv test for the CLI --- Cargo.toml | 1 + tests/cli_tests.rs | 53 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 tests/cli_tests.rs diff --git a/Cargo.toml b/Cargo.toml index 652700c..90f5f81 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,3 +32,4 @@ url = "2.4.0" [dev-dependencies] serial_test = "2.0.0" tempfile = "3.7.0" +assert_cmd = { version = "2.0.14", features = ["color-auto"] } diff --git a/tests/cli_tests.rs b/tests/cli_tests.rs new file mode 100644 index 0000000..5f2f31e --- /dev/null +++ b/tests/cli_tests.rs @@ -0,0 +1,53 @@ +use assert_cmd::Command; +use std::{env, fs::File, io::prelude::*}; +use tempfile::tempdir; + +#[test] +fn dotenv_vault_cli() { + env::set_var("DOTENV_KEY", "dotenv://:key_ddcaa26504cd70a6fef9801901c3981538563a1767c297cb8416e8a38c62fe00@dotenv.local/vault/.env.vault?environment=production"); + + let tmp = tempdir().unwrap(); + let vault_path = tmp.path().join(".env.vault"); + let mut vault = File::create(&vault_path).unwrap(); + vault + .write_all("DOTENV_VAULT_PRODUCTION=\"s7NYXa809k/bVSPwIAmJhPJmEGTtU0hG58hOZy7I0ix6y5HP8LsHBsZCYC/gw5DDFy5DgOcyd18R\"".as_bytes()) + .unwrap(); + vault.sync_all().unwrap(); + + let cwd = env::current_dir().unwrap(); + env::set_current_dir(&tmp).unwrap(); + + { + // Run the CLI program with dotenv-vault run -- + let mut cmd = Command::cargo_bin("dotenv-vault").unwrap(); + if cfg!(windows) { + cmd.args(["run", "--", "cmd", "/C", "echo %ALPHA%"]); + } else { + cmd.args(["run", "--", "bash", "-c", "printenv ALPHA"]); + } + + cmd.assert().success(); + let output = cmd.output().unwrap(); + assert_eq!(String::from_utf8(output.stdout).unwrap(), "zeta\n"); + } + + { + env::set_var("ALPHA", "beta"); + + // Run the CLI program with dotenv-vault run --override -- + let mut cmd = Command::cargo_bin("dotenv-vault").unwrap(); + if cfg!(windows) { + cmd.args(["run", "--override", "--", "cmd", "/C", "echo %ALPHA%"]); + } else { + cmd.args(["run", "--override", "--", "bash", "-c", "printenv ALPHA"]); + } + + cmd.assert().success(); + let output = cmd.output().unwrap(); + assert_eq!(String::from_utf8(output.stdout).unwrap(), "zeta\n"); + } + + tmp.close().unwrap(); + env::remove_var("DOTENV_KEY"); + env::set_current_dir(cwd).unwrap(); +} From de607a047fbd42f03e888523d3d3b2c1a0bc638c Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Thu, 2 May 2024 01:56:42 -0700 Subject: [PATCH 06/11] fix: update dependencies --- Cargo.toml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 90f5f81..78e5f08 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,12 +24,12 @@ cli = ["dep:argh"] [dependencies] aes-gcm = "0.10.2" argh = { version = "0.1.12", optional = true } -base64 = "0.21.2" +base64 = "0.22.1" dotenvy = "0.15.7" hex = "0.4.3" url = "2.4.0" [dev-dependencies] -serial_test = "2.0.0" +serial_test = "3.1.1" tempfile = "3.7.0" assert_cmd = { version = "2.0.14", features = ["color-auto"] } From 4450031b3b2990308986ebb3ac58b2006ca5037f Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Thu, 2 May 2024 02:42:19 -0700 Subject: [PATCH 07/11] feat: support specifying the cwd when running --- README.md | 6 ++++++ src/main.rs | 21 +++++++++++++++++++++ tests/cli_tests.rs | 26 +++++++++++++++++++++++--- 3 files changed, 50 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3556907..7819343 100644 --- a/README.md +++ b/README.md @@ -31,6 +31,12 @@ cargo install dotenv-vault --features cli dotenv-vault run -- some_program arg1 arg2 ``` +or run at a different working directory that contains the `.env.vault` and override existing environment variables: + +```shell +dotenv-vault run --cwd ./some_folder --override -- some_program arg1 arg2 +``` + ## Install ```shell diff --git a/src/main.rs b/src/main.rs index ddb50dd..1714d2a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,6 @@ use argh::FromArgs; use std::env; +use std::path::PathBuf; use std::process::{exit, Command, Stdio}; #[derive(FromArgs, PartialEq, Debug)] @@ -28,6 +29,10 @@ struct Run { /// whether to override the existing environment variables override_: bool, + #[argh(option)] + /// current working directory to run the program in + cwd: Option, + #[argh(positional)] /// the program to run program: String, @@ -43,6 +48,7 @@ enum CLIError { EnvLoad = 1, EnvOverrideLoad = 2, ProgramExecution = 3, + CwdChange = 4, } fn main() { @@ -50,6 +56,15 @@ fn main() { match opts.commands { Commands::Run(run_opts) => { + let current_cwd = env::current_dir().unwrap(); + + if let Some(given_cwd) = run_opts.cwd { + env::set_current_dir(&given_cwd).unwrap_or_else(|err| { + eprintln!("Failed to change the current working directory: {}", err); + exit(CLIError::CwdChange as i32); + }); + } + // Load the .env.vault file if run_opts.override_ { dotenv_vault::dotenv_override().unwrap_or_else(|err| { @@ -76,6 +91,12 @@ fn main() { exit(CLIError::ProgramExecution as i32); }); + // Restore the current working directory + env::set_current_dir(current_cwd).unwrap_or_else(|err| { + eprintln!("Failed to change the current working directory: {}", err); + exit(CLIError::CwdChange as i32); + }); + if !output.status.success() { exit( output diff --git a/tests/cli_tests.rs b/tests/cli_tests.rs index 5f2f31e..152a1e7 100644 --- a/tests/cli_tests.rs +++ b/tests/cli_tests.rs @@ -31,15 +31,35 @@ fn dotenv_vault_cli() { assert_eq!(String::from_utf8(output.stdout).unwrap(), "zeta\n"); } + env::set_current_dir(&cwd).unwrap(); + { env::set_var("ALPHA", "beta"); - // Run the CLI program with dotenv-vault run --override -- + // override the existing environment variables and specify the current working directory let mut cmd = Command::cargo_bin("dotenv-vault").unwrap(); if cfg!(windows) { - cmd.args(["run", "--override", "--", "cmd", "/C", "echo %ALPHA%"]); + cmd.args([ + "run", + "--cwd", + tmp.path().to_string_lossy().as_ref(), + "--override", + "--", + "cmd", + "/C", + "echo %ALPHA%", + ]); } else { - cmd.args(["run", "--override", "--", "bash", "-c", "printenv ALPHA"]); + cmd.args([ + "run", + "--cwd", + tmp.path().to_string_lossy().as_ref(), + "--override", + "--", + "bash", + "-c", + "printenv ALPHA", + ]); } cmd.assert().success(); From a7f9340f1ee5228fe1da9fd092380e8972b8306b Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Thu, 2 May 2024 02:55:30 -0700 Subject: [PATCH 08/11] ci: build the CLI before running the tests --- .github/workflows/ci.yml | 8 ++++---- src/main.rs | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b68bbe3..fcaa536 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,15 +30,15 @@ jobs: command: test args: --no-run + - name: Build CLI + run: | + cargo build --bin dotenv-vault --features=cli + - name: Run tests uses: actions-rs/cargo@v1 with: command: test - - name: Build CLI - run: | - cargo build --bin dotenv-vault --features=cli - clippy: runs-on: ubuntu-latest steps: diff --git a/src/main.rs b/src/main.rs index 1714d2a..affb2d7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -79,7 +79,7 @@ fn main() { }; // Run the specified program with the specified arguments - let output = Command::new(run_opts.program) + let output = Command::new(&run_opts.program) .args(run_opts.program_args) .envs(env::vars()) .stdin(Stdio::inherit()) @@ -87,7 +87,7 @@ fn main() { .stderr(Stdio::inherit()) .output() .unwrap_or_else(|err| { - eprintln!("Failed to execute program: {}", err); + eprintln!("Failed to execute program {}: {}", run_opts.program, err); exit(CLIError::ProgramExecution as i32); }); From 684b7c5f99808fd444dc58992d70405d350d0d92 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Sun, 5 May 2024 18:03:18 -0700 Subject: [PATCH 09/11] fix: fix clippy issues --- src/lib.rs | 8 ++++---- src/main.rs | 2 +- src/vault.rs | 30 +++++++++++++----------------- tests/cli_tests.rs | 2 +- 4 files changed, 19 insertions(+), 23 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 1ba1460..273e7f2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -74,7 +74,7 @@ mod tests { let tmp = tempdir().unwrap(); let vault_path = tmp.path().join(".env.vault"); - let mut vault = File::create(&vault_path).unwrap(); + let mut vault = File::create(vault_path).unwrap(); vault .write_all("DOTENV_VAULT_PRODUCTION=\"s7NYXa809k/bVSPwIAmJhPJmEGTtU0hG58hOZy7I0ix6y5HP8LsHBsZCYC/gw5DDFy5DgOcyd18R\"".as_bytes()) .unwrap(); @@ -101,7 +101,7 @@ mod tests { fn dotenv_fallback_to_env() { let tmp = tempdir().unwrap(); let env_path = tmp.path().join(".env"); - let mut env = File::create(&env_path).unwrap(); + let mut env = File::create(env_path).unwrap(); env.write_all("TESTKEY=\"from .env\"".as_bytes()).unwrap(); env.sync_all().unwrap(); @@ -127,7 +127,7 @@ mod tests { let tmp = tempdir().unwrap(); let vault_path = tmp.path().join(".env.vault"); - let mut vault = File::create(&vault_path).unwrap(); + let mut vault = File::create(vault_path).unwrap(); vault .write_all("DOTENV_VAULT_PRODUCTION=\"s7NYXa809k/bVSPwIAmJhPJmEGTtU0hG58hOZy7I0ix6y5HP8LsHBsZCYC/gw5DDFy5DgOcyd18R\"".as_bytes()) .unwrap(); @@ -156,7 +156,7 @@ mod tests { fn dotenv_override_fallback_to_env() { let tmp = tempdir().unwrap(); let env_path = tmp.path().join(".env"); - let mut env = File::create(&env_path).unwrap(); + let mut env = File::create(env_path).unwrap(); env.write_all("TESTKEY=\"from .env\"".as_bytes()).unwrap(); env.sync_all().unwrap(); diff --git a/src/main.rs b/src/main.rs index affb2d7..db03176 100644 --- a/src/main.rs +++ b/src/main.rs @@ -59,7 +59,7 @@ fn main() { let current_cwd = env::current_dir().unwrap(); if let Some(given_cwd) = run_opts.cwd { - env::set_current_dir(&given_cwd).unwrap_or_else(|err| { + env::set_current_dir(given_cwd).unwrap_or_else(|err| { eprintln!("Failed to change the current working directory: {}", err); exit(CLIError::CwdChange as i32); }); diff --git a/src/vault.rs b/src/vault.rs index e7cad20..bc62eab 100644 --- a/src/vault.rs +++ b/src/vault.rs @@ -153,26 +153,24 @@ impl Vault { }; for key in keys.split(',') { - match self + if let Ok(decrypted) = self .instructions(key) .and_then(|(k, e)| { let vault = dotenvy::from_path_iter(path)?; - let ciphertext = match vault.into_iter().find(|item| match item { + let maybe_ciphertext = vault.into_iter().find(|item| match item { Ok((k, _)) => k == &e, _ => false, - }) { + }); + let ciphertext = match maybe_ciphertext { Some(Ok((_, c))) => c, - _ => { - return Err(Error::EnvironmentNotFound(e)); - } + _ => return Err(Error::EnvironmentNotFound(e)), }; Ok((ciphertext, k)) }) .and_then(|(c, k)| self.decrypt(c, k)) { - Ok(decrypted) => return Ok(decrypted), - Err(_) => continue, + return Ok(decrypted); } } @@ -202,9 +200,8 @@ mod tests { #[test] fn instructions_ok() { let vault = Vault::new(); - let instructions = vault.instructions( - "dotenv://:key_1234@dotenv.org/vault/.env.vault?environment=production".into(), - ); + let instructions = vault + .instructions("dotenv://:key_1234@dotenv.org/vault/.env.vault?environment=production"); assert!(instructions.is_ok()); let (key, environment) = instructions.unwrap(); @@ -215,8 +212,8 @@ mod tests { #[test] fn instructions_invalid_scheme() { let vault = Vault::new(); - let instructions = vault - .instructions("invalid://dotenv.org/vault/.env.vault?environment=production".into()); + let instructions = + vault.instructions("invalid://dotenv.org/vault/.env.vault?environment=production"); assert!(instructions.is_err()); assert!(matches!(instructions.unwrap_err(), Error::InvalidScheme)); @@ -225,8 +222,8 @@ mod tests { #[test] fn instructions_missing_key() { let vault = Vault::new(); - let instructions = vault - .instructions("dotenv://dotenv.org/vault/.env.vault?environment=production".into()); + let instructions = + vault.instructions("dotenv://dotenv.org/vault/.env.vault?environment=production"); assert!(instructions.is_err()); assert!(matches!(instructions.unwrap_err(), Error::MissingKey)); @@ -235,8 +232,7 @@ mod tests { #[test] fn instructions_missing_environment() { let vault = Vault::new(); - let instructions = - vault.instructions("dotenv://:key_1234@dotenv.org/vault/.env.vault".into()); + let instructions = vault.instructions("dotenv://:key_1234@dotenv.org/vault/.env.vault"); assert!(instructions.is_err()); assert!(matches!( diff --git a/tests/cli_tests.rs b/tests/cli_tests.rs index 152a1e7..e324995 100644 --- a/tests/cli_tests.rs +++ b/tests/cli_tests.rs @@ -8,7 +8,7 @@ fn dotenv_vault_cli() { let tmp = tempdir().unwrap(); let vault_path = tmp.path().join(".env.vault"); - let mut vault = File::create(&vault_path).unwrap(); + let mut vault = File::create(vault_path).unwrap(); vault .write_all("DOTENV_VAULT_PRODUCTION=\"s7NYXa809k/bVSPwIAmJhPJmEGTtU0hG58hOZy7I0ix6y5HP8LsHBsZCYC/gw5DDFy5DgOcyd18R\"".as_bytes()) .unwrap(); From b06f8fca6a254cc70a5a95662497bf2a76452184 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Sun, 5 May 2024 18:04:45 -0700 Subject: [PATCH 10/11] ci: update MSRV to 1.65.0 --- .github/workflows/ci.yml | 2 +- Cargo.toml | 2 +- README.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index fcaa536..34e8a46 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: false matrix: - rust: [stable, beta, nightly, 1.64.0] + rust: [stable, beta, nightly, 1.65.0] steps: - uses: actions/checkout@v3 diff --git a/Cargo.toml b/Cargo.toml index 78e5f08..4fba2d4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ keywords = ["dotenv", "env", "environment", "settings", "vault"] categories = ["config"] license = "MIT" edition = "2021" -rust-version = "1.64.0" +rust-version = "1.65.0" [[bin]] name = "dotenv-vault" diff --git a/README.md b/README.md index 7819343..a43a34b 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![crates.io](https://img.shields.io/crates/v/dotenv-vault.svg)](https://crates.io/crates/dotenv-vault) [![msrv -1.64.0](https://img.shields.io/badge/msrv-1.64.0-dea584.svg?logo=rust)](https://github.com/rust-lang/rust/releases/tag/1.64.0) +1.65.0](https://img.shields.io/badge/msrv-1.65.0-dea584.svg?logo=rust)](https://github.com/rust-lang/rust/releases/tag/1.65.0) [![ci](https://github.com/Minebomber/dotenv-vault-rs/actions/workflows/ci.yml/badge.svg)](https://github.com/Minebomber/dotenv-vault-rs/actions/workflows/ci.yml) [![docs](https://img.shields.io/docsrs/dotenv-vault?logo=docs.rs)](https://docs.rs/dotenv-vault/) From dc5bdbf66987372b45f0488d0ef23dbc34053e05 Mon Sep 17 00:00:00 2001 From: Amin Yahyaabadi Date: Sun, 5 May 2024 18:15:03 -0700 Subject: [PATCH 11/11] ci: update MSRV to 1.73.0 --- .github/workflows/ci.yml | 2 +- Cargo.toml | 2 +- README.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 34e8a46..78ec265 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: false matrix: - rust: [stable, beta, nightly, 1.65.0] + rust: [stable, beta, nightly, 1.73.0] steps: - uses: actions/checkout@v3 diff --git a/Cargo.toml b/Cargo.toml index 4fba2d4..aef99ff 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ keywords = ["dotenv", "env", "environment", "settings", "vault"] categories = ["config"] license = "MIT" edition = "2021" -rust-version = "1.65.0" +rust-version = "1.73.0" [[bin]] name = "dotenv-vault" diff --git a/README.md b/README.md index a43a34b..85a8445 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ [![crates.io](https://img.shields.io/crates/v/dotenv-vault.svg)](https://crates.io/crates/dotenv-vault) [![msrv -1.65.0](https://img.shields.io/badge/msrv-1.65.0-dea584.svg?logo=rust)](https://github.com/rust-lang/rust/releases/tag/1.65.0) +1.73.0](https://img.shields.io/badge/msrv-1.73.0-dea584.svg?logo=rust)](https://github.com/rust-lang/rust/releases/tag/1.73.0) [![ci](https://github.com/Minebomber/dotenv-vault-rs/actions/workflows/ci.yml/badge.svg)](https://github.com/Minebomber/dotenv-vault-rs/actions/workflows/ci.yml) [![docs](https://img.shields.io/docsrs/dotenv-vault?logo=docs.rs)](https://docs.rs/dotenv-vault/)