Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "deduplicate GCP IAM bindings" #1048

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading