Skip to content

Commit

Permalink
feat: Allow passing environment variable name as secrets
Browse files Browse the repository at this point in the history
  • Loading branch information
chubei committed Oct 9, 2023
1 parent 0abda7f commit aa7a1bd
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions dozer-cli/src/cli/cloud.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,16 @@ pub enum SecretsCommand {
}

fn parse_key_val(s: &str) -> Result<Secret, Box<dyn Error + Send + Sync + 'static>> {
let pos = s
.find('=')
.ok_or_else(|| format!("invalid KEY=value: no `=` found in `{s}`"))?;

Ok(Secret {
name: s[..pos].parse()?,
value: s[pos + 1..].parse()?,
})
if let Some(pos) = s.find('=') {
Ok(Secret {
name: s[..pos].to_string(),
value: s[pos + 1..].to_string(),
})
} else {
let value = std::env::var(s)?;
Ok(Secret {
name: s.to_string(),
value,
})
}
}

0 comments on commit aa7a1bd

Please sign in to comment.