use std::process::Command;
use std::sync::atomic::{AtomicUsize, Ordering};

static CONFIG_COUNTER: AtomicUsize = AtomicUsize::new(0);

pub(crate) fn bucketwarden() -> Command {
    Command::new(env!("CARGO_BIN_EXE_bucketwarden"))
}

pub(crate) fn operator_config() -> std::path::PathBuf {
    let index = CONFIG_COUNTER.fetch_add(1, Ordering::Relaxed);
    let path = std::env::temp_dir().join(format!(
        "bucketwarden-operator-{}-{index}.json",
        std::process::id()
    ));
    std::fs::write(
        &path,
        r#"{"key_id":"test-key","key_material":"secret","clock_epoch_seconds":42}"#,
    )
    .unwrap();
    path
}
