use crate::cleanup;
use crate::environment::Environment;
use crate::var::Key;
use crate::var::C_HIGH;
use super::var;
use super::Hierarchy;
use super::RetrieveRes;
pub struct VarSource;
impl super::VarSource for VarSource {
fn is_usable(&self, _environment: &mut Environment) -> bool {
true
}
fn hierarchy(&self) -> Hierarchy {
Hierarchy::High
}
fn type_name(&self) -> &'static str {
std::any::type_name::<Self>()
}
fn properties(&self) -> &Vec<String> {
&super::NO_PROPS
}
#[remain::check]
fn retrieve(&self, environment: &mut Environment, key: Key) -> RetrieveRes {
Ok(
#[remain::sorted]
match key {
Key::BuildArch
| Key::BuildDate
| Key::BuildHostingUrl
| Key::BuildOs
| Key::BuildOsFamily
| Key::BuildTag
| Key::Ci
| Key::License
| Key::Licenses
| Key::NameMachineReadable
| Key::RepoCloneUrl
| Key::RepoCloneUrlGit
| Key::RepoCloneUrlHttp
| Key::RepoCloneUrlSsh
| Key::RepoCommitPrefixUrl
| Key::RepoIssuesUrl
| Key::RepoRawVersionedPrefixUrl
| Key::RepoVersionedDirPrefixUrl
| Key::RepoVersionedFilePrefixUrl
| Key::RepoWebUrl
| Key::VersionDate => None,
Key::BuildBranch => var(environment, "BRANCH_NAME", C_HIGH),
Key::BuildNumber => var(environment, "BUILD_NUMBER", C_HIGH),
Key::Name => var(environment, "APP_NAME", C_HIGH),
Key::Version => var(environment, "VERSION", C_HIGH)
.map(|conf_val| cleanup::conf_version(environment, conf_val)), },
)
}
}