stop hardcoding the s3 region and endpoint url

This commit is contained in:
Armaël Guéneau 2024-04-10 18:46:49 +02:00
parent afccf9d7bb
commit 085755eebc

View file

@ -1,4 +1,3 @@
use aws_config::Region;
use aws_sdk_s3 as s3; use aws_sdk_s3 as s3;
use eyre::{OptionExt, WrapErr}; use eyre::{OptionExt, WrapErr};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
@ -11,9 +10,6 @@ const RESTIC_ALARM_BUCKET: &str = "restic-alarm-state";
const RESTIC_ALARM_STATE_FILE: &str = "state.toml"; const RESTIC_ALARM_STATE_FILE: &str = "state.toml";
const RESTIC_ALARM_WATCH_DIR: &str = "watch/"; const RESTIC_ALARM_WATCH_DIR: &str = "watch/";
const S3_REGION: &str = "infracoll";
const S3_ENDPOINT: &str = "http://garage.isomorphis.me:3900";
#[derive(Serialize, Deserialize, Clone, Debug)] #[derive(Serialize, Deserialize, Clone, Debug)]
struct State { struct State {
last_alert: HashMap<String, u64>, last_alert: HashMap<String, u64>,
@ -246,8 +242,6 @@ async fn check_repo(client: &s3::Client, state: &mut State, repo: &str) -> eyre:
async fn main() -> eyre::Result<()> { async fn main() -> eyre::Result<()> {
let sdk_config = aws_config::load_from_env().await; let sdk_config = aws_config::load_from_env().await;
let config = aws_sdk_s3::config::Builder::from(&sdk_config) let config = aws_sdk_s3::config::Builder::from(&sdk_config)
.region(Region::new(S3_REGION))
.endpoint_url(S3_ENDPOINT)
.force_path_style(true) .force_path_style(true)
.build(); .build();
let client = aws_sdk_s3::Client::from_conf(config); let client = aws_sdk_s3::Client::from_conf(config);