Skip to content

Commit

Permalink
feat: newline and 1p file support (#67)
Browse files Browse the repository at this point in the history
* feat: newline and 1p file support

* chore: bump 0.10.0
  • Loading branch information
zifeo authored Mar 8, 2024
1 parent 6d1885d commit 972466c
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 46 deletions.
34 changes: 17 additions & 17 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,39 @@ resolver = "2"

[package]
name = "lade"
version = "0.9.2-beta.1"
version = "0.10.0"
edition = "2021"
description = "Automatically load secrets from your preferred vault as environment variables, and clear them once your shell command is over."
license = "MPL-2.0"

[dependencies]
anyhow = "1.0.79"
anyhow = "1.0.80"
self_update = { version = "0.39.0", features = [
"archive-tar",
"archive-zip",
"compression-flate2",
"compression-zip-deflate",
"compression-zip-bzip2",
] }
serde = { version = "1.0.196", features = ["derive"] }
serde_yaml = "0.9.31"
clap = { version = "4.4.18", features = ["derive"] }
serde = { version = "1.0.197", features = ["derive"] }
serde_yaml = "0.9.32"
clap = { version = "4.5.2", features = ["derive"] }
regex = "1.10.3"
lade-sdk = { path = "./sdk", version = "0.9.2-beta.1" }
lade-sdk = { path = "./sdk", version = "0.10.0" }
tokio = { version = "1", features = ["full"] }
indexmap = { version = "2.2.2", features = ["serde"] }
clap-verbosity-flag = "2.1.2"
env_logger = "0.11.1"
openssl = { version = "0.10.63", features = ["vendored"] }
serde_json = "1.0.113"
indexmap = { version = "2.2.5", features = ["serde"] }
clap-verbosity-flag = "2.2.0"
env_logger = "0.11.3"
openssl = { version = "0.10.64", features = ["vendored"] }
serde_json = "1.0.114"
futures = "0.3.30"
path-clean = "1.0.1"
directories = "5.0.1"
chrono = { version = "0.4.33", features = ["serde"] }
log = "0.4.20"
semver = "1.0.21"
sysinfo = "0.30.5"
textwrap = "0.16.0"
chrono = { version = "0.4.35", features = ["serde"] }
log = "0.4.21"
semver = "1.0.22"
sysinfo = "0.30.7"
textwrap = "0.16.1"

[dev-dependencies]
assert_cmd = "2.0.13"
assert_cmd = "2.0.14"
9 changes: 7 additions & 2 deletions lade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,28 @@
B1: doppler://api.doppler.com/lade/dev/DOPPLER_A
B2: doppler://api.doppler.com/lade/dev/DOPPLER_B
B3: doppler://api.doppler.com/lade/prd/DOPPLER_B
B4: doppler://api.doppler.com/lade/dev/MULTILINE

^echo c:
C1: infisical://infisical.exponent.ch/63fd114968d64dec0823ac52/test/STORE_FILE
C1: infisical://app.infisical.com/63a2290a0edf8bf1f65e3784/dev/INFISICAL_A
C2: infisical://app.infisical.com/63a2290a0edf8bf1f65e3784/dev/INFISICAL_B
C3: infisical://app.infisical.com/63a2290a0edf8bf1f65e3784/prod/INFISICAL_B
C4: infisical://app.infisical.com/63a2290a0edf8bf1f65e3784/dev/MULTILINE

^echo d:
D1: op://my.1password.eu/Personal/Lade/username
D2: op://my.1password.eu/Personal/Lade/password
D3: op://my.1password.eu/Personal/Lade/with space
D4: op://my.1password.eu/Personal/Lade/file

^echo e:
# vault kv put -address=http://127.0.0.1:8200 -mount=secret password value1=itsasecret value2=itsanotsecret
# export VAULT_TOKEN=token
# vault kv put -address=http://127.0.0.1:8200 -mount=secret password value1=itsasecret value2=itsanotsecret multiline="a\nb"
# vault kv put -address=http://127.0.0.1:8200 -mount=secret org/team value=secret
E1: vault://127.0.0.1:8200/secret/password/value1
E2: vault://127.0.0.1:8200/secret/password/value2
E3: vault://127.0.0.1:8200/secret/org%2Fteam/value
E4: vault://127.0.0.1:8200/secret/password/multiline

^echo f:
F1: file://../lade/examples/sources/config.ini?query=.format
Expand Down
11 changes: 5 additions & 6 deletions scripts/on.bash
Original file line number Diff line number Diff line change
@@ -1,21 +1,20 @@

preexec_lade() {
preexec_lade() {
if [ "$1" = "source off.bash" ]; then
return
fi
LADE="$1"
eval $(lade set $@)
eval "$(lade set $@)"
}

preexec_functions+=(preexec_lade)

precmd_lade() {
if [ -z ${LADE+x} ]; then
return # ensure only runs at postexec
return # ensure only runs at postexec
elif [ "$LADE" = "source on.bash" ]; then
return
fi
eval $(lade unset $@)
fi
eval "$(lade unset $@)"
unset -v LADE
}

Expand Down
4 changes: 2 additions & 2 deletions scripts/on.fish
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@ function preexec_lade --on-event fish_preexec
return
end
set --global LADE "$argv"
eval $(lade set $argv)
eval "$(lade set $argv)"
end

function postexec_lade --on-event fish_postexec
# $argv also exists here in fish, but keeping LADE for consistency
if [ "$LADE" = "source on.fish" ]
return
end
eval $(lade unset $argv)
eval "$(lade unset $argv)"
set --global --erase LADE
end
13 changes: 6 additions & 7 deletions scripts/on.zsh
Original file line number Diff line number Diff line change
@@ -1,29 +1,28 @@

preexec_lade() {
preexec_lade() {
if [ "$1" = "source off.zsh" ]; then
return
fi
LADE=$1
if [ "$(uname)" = "Darwin" ]; then
# bugfix: macOs seems to triple argv
argv=${argv:1:$(( ${#argv[@]} / 3 ))}
argv=${argv:1:$((${#argv[@]} / 3))}
fi
eval $(lade set $argv)
eval "$(lade set $argv)"
}

preexec_functions+=(preexec_lade)

precmd_lade() {
if [ -z ${LADE+x} ]; then
return # ensure only runs at postexec
return # ensure only runs at postexec
elif [ "$LADE" = "source on.zsh" ]; then
return
fi
if [ "$(uname)" = "Darwin" ]; then
# bugfix: macOs seems to triple argv
argv=${argv:1:$(( ${#argv[@]} / 3 ))}
argv=${argv:1:$((${#argv[@]} / 3))}
fi
eval $(lade unset $argv)
eval "$(lade unset $argv)"
unset -v LADE
}

Expand Down
18 changes: 9 additions & 9 deletions sdk/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
[package]
name = "lade-sdk"
version = "0.9.2-beta.1"
version = "0.10.0"
edition = "2021"
description = "Lade SDK"
license = "MPL-2.0"

[dependencies]
access-json = "0.1.0"
anyhow = "1.0.79"
async-process = "2.0.1"
anyhow = "1.0.80"
async-process = "2.1.0"
async-trait = "0.1.77"
directories = "5.0.1"
futures = "0.3.30"
itertools = "0.12.1"
log = "0.4.20"
log = "0.4.21"
once_cell = "1.19.0"
regex = "1.10.3"
rust-ini = "0.20.0"
serde = { version = "1.0.196", features = ["derive"] }
serde_json = "1.0.113"
serde_yaml = "0.9.31"
tempfile = "3.9.0"
serde = { version = "1.0.197", features = ["derive"] }
serde_json = "1.0.114"
serde_yaml = "0.9.32"
tempfile = "3.10.1"
tokio = { version = "1.36.0", features = ["fs"] }
toml = "0.8.9"
toml = "0.8.10"
url = "2.5.0"
urlencoding = "2.1.3"
3 changes: 2 additions & 1 deletion sdk/src/providers/onepassword.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ impl Provider for OnePassword {
Ok(child) => child,
};

let output = String::from_utf8_lossy(&child.stdout).trim().replace('\n', "\\n");
let loaded =
serde_json::from_slice::<Hydration>(&child.stdout).map_err(|err| {
serde_json::from_str::<Hydration>(&output).map_err(|err| {
let stderr = String::from_utf8_lossy(&child.stderr);
if stderr.contains("could not resolve item UUID") {
anyhow!(
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use anyhow::{bail, Ok, Result};
use chrono::{Duration, Utc};
use chrono::{TimeDelta, Utc};
use log::{debug, warn};
use self_update::{backends::github::Update, cargo_crate_version, update::UpdateStatus};
use semver::Version;
Expand Down Expand Up @@ -31,7 +31,7 @@ async fn upgrade_check() -> Result<()> {
debug!("config_path: {:?}", config_path);
let mut local_config = GlobalConfig::load(config_path.clone()).await?;

if local_config.update_check + Duration::days(1) < Utc::now() {
if local_config.update_check + TimeDelta::try_days(1).unwrap() < Utc::now() {
debug!("checking for update");
let current_version = cargo_crate_version!();
let latest = tokio::task::spawn_blocking(move || {
Expand Down

0 comments on commit 972466c

Please sign in to comment.