monosecret 0.4.0

Declarative secrets, every environment, any provider
Documentation
//! Registry entries for providers omitted by Cargo feature selection.
//!
//! The implementation modules cannot be compiled without their optional
//! dependencies, but their identity remains part of Monosecret's provider
//! registry so using one produces an actionable feature error.

use super::catalog;

macro_rules! disabled {
	($feature:literal, $metadata:ident) => {
		crate::register_disabled_provider! {
			feature: $feature,
			metadata: &catalog::$metadata,
		}
	};
}

#[cfg(not(feature = "aac"))]
disabled!("aac", AAC);
#[cfg(not(feature = "age"))]
disabled!("age", AGE);
#[cfg(not(feature = "akv"))]
disabled!("akv", AKV);
#[cfg(not(feature = "awsps"))]
disabled!("awsps", AWSPS);
#[cfg(not(feature = "awssm"))]
disabled!("awssm", AWSSM);
#[cfg(not(feature = "bw"))]
disabled!("bw", BW);
#[cfg(not(feature = "bws"))]
disabled!("bws", BWS);
#[cfg(not(feature = "cloudflare"))]
disabled!("cloudflare", CLOUDFLARE);
#[cfg(not(feature = "doppler"))]
disabled!("doppler", DOPPLER);
#[cfg(not(feature = "ejson"))]
disabled!("ejson", EJSON);
#[cfg(not(feature = "gcsm"))]
disabled!("gcsm", GCSM);
#[cfg(not(feature = "infisical"))]
disabled!("infisical", INFISICAL);
#[cfg(not(feature = "kdbx"))]
disabled!("kdbx", KDBX);
#[cfg(not(feature = "keeper"))]
disabled!("keeper", KEEPER);
#[cfg(not(feature = "keyring"))]
disabled!("keyring", KEYRING);
#[cfg(not(feature = "kubernetes"))]
disabled!("kubernetes", KUBERNETES);
#[cfg(not(feature = "openbao"))]
disabled!("openbao", OPENBAO);
#[cfg(not(feature = "scaleway"))]
disabled!("scaleway", SCALEWAY);
#[cfg(not(feature = "setec"))]
disabled!("setec", SETEC);
#[cfg(not(feature = "sops"))]
disabled!("sops", SOPS);
#[cfg(not(feature = "vault"))]
disabled!("vault", VAULT);

#[cfg(test)]
mod tests {
	#[test]
	#[cfg(not(feature = "keyring"))]
	fn disabled_provider_is_known_and_reports_its_feature() {
		assert!(super::super::spec_names_known_provider("keyring://").unwrap());
		let error = match Box::<dyn super::super::Provider>::try_from("keyring://") {
			Ok(_) => panic!("disabled provider unexpectedly constructed"),
			Err(error) => error,
		};
		assert!(matches!(
			error,
			crate::MonosecretError::ProviderFeatureDisabled {
				ref provider,
				feature: "keyring"
			} if provider == "keyring"
		));
	}

	#[test]
	#[cfg(not(feature = "setec"))]
	fn disabled_setec_provider_reports_its_feature() {
		let spec = "setec://secrets.example.ts.net";
		assert!(super::super::spec_names_known_provider(spec).unwrap());
		let error = match Box::<dyn super::super::Provider>::try_from(spec) {
			Ok(_) => panic!("disabled setec provider unexpectedly constructed"),
			Err(error) => error,
		};
		assert!(matches!(
			error,
			crate::MonosecretError::ProviderFeatureDisabled {
				ref provider,
				feature: "setec"
			} if provider == "setec"
		));
	}
}