pub enum ConfigValue {
Inline(String),
Env(String),
}Expand description
A config value written inline or read from an environment variable.
With the serde feature it deserializes from "literal" or
{ env = "VAR_NAME" }, the same shape drizzle-kit and the CLI accept
for dbCredentials.url.
§Examples
use drizzle_types::ConfigValue;
let url = ConfigValue::Inline("postgres://localhost/app".into());
assert_eq!(url.resolve().unwrap(), "postgres://localhost/app");Variants§
Inline(String)
Value written inline in the config file.
Env(String)
Name of the environment variable to resolve.
Implementations§
Source§impl ConfigValue
impl ConfigValue
Sourcepub fn resolve(&self) -> Result<String, ConfigValueError>
pub fn resolve(&self) -> Result<String, ConfigValueError>
Returns the value, reading the environment variable for ConfigValue::Env.
§Errors
Returns ConfigValueError::NotPresent if this is a ConfigValue::Env pointing
to a variable that is not set, or ConfigValueError::NotUnicode if the
variable is set but contains invalid UTF-8.
Sourcepub fn resolve_optional(&self) -> Result<Option<String>, ConfigValueError>
pub fn resolve_optional(&self) -> Result<Option<String>, ConfigValueError>
Returns the value, or None when a ConfigValue::Env variable is unset.
§Errors
Returns ConfigValueError::NotUnicode if the env var is set but contains
invalid UTF-8. Missing env vars resolve to Ok(None).