extern crate futures;
extern crate tokio_core;
extern crate url;
extern crate vault_client;
use vault_client::*;
use std::env;
use std::path::Path;
use std::sync::Arc;
use std::time::Duration;
use futures::Future;
use tokio_core::reactor::Core;
use url::Url;
fn main() {
let mut core = Core::new().unwrap();
let token = Token::try_new(
env::var("VAULT_TOKEN").unwrap(),
Duration::from_secs(10),
Duration::from_secs(2),
).unwrap();
let vault_url = Url::parse(&env::var("VAULT_ADDR").unwrap()).unwrap();
let vault_cert = Path::new("test/certificates/vault.crt");
let cache_file = Path::new("/tmp/vault-agent");
let vault_client = Arc::new(
Client::try_new(
&vault_url,
vault_cert,
token,
cache_file,
core.remote(),
Duration::from_secs(60),
Duration::from_secs(360),
).unwrap(),
);
let vault_client_clone = vault_client.clone();
std::thread::spawn(move || loop {
let result = vault_client_clone.get_certificate("localhost").wait();
println!("{:?}", result);
std::thread::sleep(Duration::from_secs(10));
});
core.run(futures::empty::<(), ()>()).unwrap();
}