use serde::Deserialize; use tokio::runtime::LocalRuntime; #[cfg(feature = "secrets")] use vaultrs::{ client::{VaultClient, VaultClientSettingsBuilder}, error::ClientError, kv2, }; #[derive(Debug, Deserialize)] struct MALKey { clientid: String, clientsecret: String, } impl Default for MALKey { fn default() -> Self { MALKey { clientid: "UNSET".into(), clientsecret: "UNSET".into(), } } } fn main() { println!("cargo::rerun-if-changed=build.rs"); #[allow(unused_variables)] let runtime = LocalRuntime::new().expect("Local runtime failed to setup"); let mut data = MALKey::default(); #[cfg(feature = "mal")] { let client = VaultClient::new( VaultClientSettingsBuilder::default() .build() .unwrap(), ) .unwrap(); let secret: Result = runtime.block_on(async { kv2::read(&client, "builds", "myanimelist").await }); match secret { Ok(vaultdata) => data = vaultdata, Err(error) => { println!("cargo::warning=Failed to get secret from the vault: {}", error.to_string()); }, }; } println!("cargo::rustc-env=MAL_CLIENTID={}\ncargo::rustc-env=MAL_CLIENTSECRET={}", data.clientid, data.clientsecret); }