Applied first configuration

This commit is contained in:
2023-05-08 17:20:54 +02:00
parent 073c91fe0d
commit 268f9a47cd
5 changed files with 70 additions and 42 deletions

View File

@@ -88,8 +88,22 @@ async fn apply_bucket(b: &MinioBucket, client: &Client) -> anyhow::Result<()> {
password: read_secret_str(&user_secret, SECRET_MINIO_BUCKET_SECRET_KEY)?,
};
println!("{:?}", service);
println!("{:?}", user);
log::debug!("Create or update bucket...");
service.bucket_apply(&b.spec).await?;
let policy_name = format!("bucket-{}", b.spec.name);
log::debug!("Create or update policy '{policy_name}'...");
let policy_content =
include_str!("policy_template.json").replace("{{ bucket }}", b.spec.name.as_str());
service.policy_apply(&policy_name, &policy_content).await?;
log::debug!("Create or update user '{}'...", user.username);
service.user_apply(&user).await?;
log::debug!("Attach policy '{policy_name}' to user...");
service.policy_attach_user(&user, &policy_name).await?;
log::debug!("Successfully applied desired configuration!");
Ok(())
}