feat: v1.5.3, environment support vec string

This commit is contained in:
2023-12-19 23:25:11 +08:00
parent 343a6f5fac
commit 0b09630635
3 changed files with 14 additions and 3 deletions

2
Cargo.lock generated
View File

@@ -1700,7 +1700,7 @@ dependencies = [
[[package]]
name = "tiny-encrypt"
version = "1.5.2"
version = "1.5.3"
dependencies = [
"aes-gcm-stream",
"base64",

View File

@@ -1,6 +1,6 @@
[package]
name = "tiny-encrypt"
version = "1.5.2"
version = "1.5.3"
edition = "2021"
license = "MIT"
description = "A simple and tiny file encrypt tool"

View File

@@ -36,12 +36,19 @@ use crate::spec::TinyEncryptEnvelopType;
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TinyEncryptConfig {
pub environment: Option<HashMap<String, String>>,
pub environment: Option<HashMap<String, StringOrVecString>>,
pub namespaces: Option<HashMap<String, String>>,
pub envelops: Vec<TinyEncryptConfigEnvelop>,
pub profiles: HashMap<String, Vec<String>>,
}
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(untagged)]
pub enum StringOrVecString {
String(String),
Vec(Vec<String>),
}
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct TinyEncryptConfigEnvelop {
@@ -81,6 +88,10 @@ impl TinyEncryptConfig {
if let Some(environment) = &config.environment {
for (k, v) in environment {
let v = match v {
StringOrVecString::String(s) => { s.to_string() }
StringOrVecString::Vec(vs) => { vs.join(",") }
};
debugging!("Set env: {}={}", k, v);
env::set_var(k, v);
}