use std::env;
use std::io;
use std::path::PathBuf;
use std::result;
pub type Result<T> = result::Result<T, Error>;
#[derive(Debug, thiserror::Error)]
#[non_exhaustive]
pub enum Error {
#[non_exhaustive]
#[error("can't access secure credential '{name}': {source}")]
Credential {
name: String,
#[source]
source: Box<Error>,
},
#[non_exhaustive]
#[error("problem reading file {}: {source}", path.display())]
FileRead {
path: PathBuf,
#[source]
source: Box<Error>,
},
#[non_exhaustive]
#[error("invalid URL {url:?}")]
InvalidUrl {
url: String,
},
#[non_exhaustive]
#[error("I/O error: {0}")]
Io(#[from] io::Error),
#[non_exhaustive]
#[error("could not parse JSON: {0}")]
Json(#[from] serde_json::Error),
#[non_exhaustive]
#[error("no entry for '{name}' in Secretfile")]
MissingEntry {
name: String,
},
#[non_exhaustive]
#[error("the path '{path}' is missing a ':key' component")]
MissingKeyInPath {
path: String,
},
#[non_exhaustive]
#[error("the secret '{secret}' does not have a value for the key '{key}'")]
MissingKeyInSecret {
secret: String,
key: String,
},
#[error("VAULT_ADDR not specified")]
MissingVaultAddr,
#[error("cannot get VAULT_TOKEN, Kubernetes Vault token or ~/.vault_token: {0}")]
MissingVaultToken(Box<Error>),
#[error("no credentials backend available")]
NoBackend,
#[error("can't find home directory")]
NoHomeDirectory,
#[error("path '{path:?}' cannot be represented as Unicode")]
#[non_exhaustive]
NonUnicodePath {
path: PathBuf,
},
#[error("could not parse {input:?}")]
#[non_exhaustive]
Parse {
input: String,
},
#[error("{0}")]
Other(Box<dyn std::error::Error + Send + Sync + 'static>),
#[non_exhaustive]
#[error("can't read Secretfile: {0}")]
Secretfile(Box<Error>),
#[non_exhaustive]
#[error("undefined environment variable {name:?}: {source}")]
UndefinedEnvironmentVariable {
name: String,
#[source]
source: env::VarError,
},
#[non_exhaustive]
#[error("unexpected HTTP status: {status} ({body})")]
UnexpectedHttpStatus {
status: reqwest::StatusCode,
body: String,
},
#[error("could not parse URL: {0}")]
UnparseableUrl(#[from] url::ParseError),
#[non_exhaustive]
#[error("could not access URL '{url}': {source}")]
Url {
url: reqwest::Url,
#[source]
source: Box<Error>,
},
}