From 765a8108fd2d014b4899701a2d19cb87c02345a5 Mon Sep 17 00:00:00 2001 From: Pierre Hubert Date: Mon, 8 May 2023 17:26:42 +0200 Subject: [PATCH] Fix indempotence issue with policy attach --- src/minio.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/minio.rs b/src/minio.rs index 6e8c7de..aca6c70 100644 --- a/src/minio.rs +++ b/src/minio.rs @@ -531,6 +531,15 @@ impl MinioService { /// Attach a user to a policy pub async fn policy_attach_user(&self, user: &MinioUser, policy: &str) -> anyhow::Result<()> { + // Check if the policy has already been attached to the user + if self + .policy_attach_get_user_list(user) + .await? + .contains(&policy.to_string()) + { + return Ok(()); + } + let res = self .exec_mc_cmd::(&[ "admin",