Skip to content

Commit

Permalink
Revert "deduplicate GCP IAM bindings" (#1048)
Browse files Browse the repository at this point in the history
  • Loading branch information
nhudson authored Nov 18, 2024
1 parent b467e65 commit 4b5c91b
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 17 deletions.
2 changes: 1 addition & 1 deletion conductor/src/azure/uami_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use azure_error::AzureError;
use azure_identity::TokenCredentialOptions;
use azure_identity::WorkloadIdentityCredential;
use azure_mgmt_authorization;
use azure_mgmt_authorization::models::RoleAssignmentProperties;
use azure_mgmt_authorization::models::{RoleAssignment, RoleAssignmentProperties};
use azure_mgmt_msi::models::{
FederatedIdentityCredential, FederatedIdentityCredentialProperties, Identity, TrackedResource,
};
Expand Down
18 changes: 3 additions & 15 deletions conductor/src/gcp/bucket_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,36 +112,24 @@ impl BucketIamManager {
/// * `condition` - The condition for the binding.
fn update_or_create_binding(&self, policy: &mut Policy, member: &str, condition: Condition) {
let role = self.get_storage_role();

// First, remove any bindings with the same role but different conditions
policy
.bindings
.retain(|b| b.role != role || b.condition.as_ref() == Some(&condition));

// Then find and update matching binding or create new one
if let Some(binding) = self.find_matching_binding(policy, &condition) {
// Update existing binding
if !binding.members.contains(&member.to_string()) {
binding.members.push(member.to_string());
info!("Updated {} to existing binding", member);
info!("Added {} to existing binding.", member);
} else {
warn!(
"Member {} already exists in the binding, no changes made",
"Member {} already exists in the binding. No changes made.",
member
);
}
} else {
// Create new binding
let new_binding = self.create_new_binding(member.to_string(), condition);
policy.bindings.push(new_binding);
info!(
"Created new binding for {} with role {} and condition",
"Created new binding for {} with role {} and condition.",
member, role
);
}

// Clean up any empty bindings
policy.bindings.retain(|b| !b.members.is_empty());
}

/// Finds a matching binding in the policy based on the role and condition.
Expand Down
1 change: 0 additions & 1 deletion conductor/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -993,7 +993,6 @@ async fn init_gcp_storage_workload_identity(
Ok(())
}

#[allow(clippy::too_many_arguments)]
async fn init_azure_storage_workload_identity(
is_azure: bool,
read_msg: &Message<CRUDevent>,
Expand Down

0 comments on commit 4b5c91b

Please sign in to comment.