Verified Commit 3d400885 authored by Levente Polyak's avatar Levente Polyak 🚀
Browse files

chore(gitlab): use simpler if let matches to make clippy happy

parent 234a884c
......@@ -514,20 +514,17 @@ impl GitLabGlue {
"",
util::format_gitlab_member_access(group, &user.username, access_level).as_str(),
)?;
match action {
Action::Apply => {
let endpoint = gitlab::api::groups::members::AddGroupMember::builder()
.group(group)
.user(gitlab_id)
.access_level(access_level)
.build()
.unwrap();
gitlab::api::ignore(endpoint)
.query_async(&self.client)
.await
.unwrap();
}
_ => {}
if let Action::Apply = action {
let endpoint = gitlab::api::groups::members::AddGroupMember::builder()
.group(group)
.user(gitlab_id)
.access_level(access_level)
.build()
.unwrap();
gitlab::api::ignore(endpoint)
.query_async(&self.client)
.await
.unwrap();
}
Ok(true)
}
......@@ -549,19 +546,16 @@ impl GitLabGlue {
.as_str(),
"",
)?;
match action {
Action::Apply => {
let endpoint = gitlab::api::groups::members::RemoveGroupMember::builder()
.group(group)
.user(member.id)
.build()
.unwrap();
gitlab::api::ignore(endpoint)
.query_async(&self.client)
.await
.unwrap();
}
_ => {}
if let Action::Apply = action {
let endpoint = gitlab::api::groups::members::RemoveGroupMember::builder()
.group(group)
.user(member.id)
.build()
.unwrap();
gitlab::api::ignore(endpoint)
.query_async(&self.client)
.await
.unwrap();
}
Ok(true)
}
......@@ -597,20 +591,17 @@ impl GitLabGlue {
util::format_gitlab_member_access(group, &user.username, expected_access_level)
.as_str(),
)?;
match action {
Action::Apply => {
let endpoint = gitlab::api::groups::members::EditGroupMember::builder()
.group(group)
.user(group_member.id)
.access_level(expected_access_level)
.build()
.unwrap();
gitlab::api::ignore(endpoint)
.query_async(&self.client)
.await
.unwrap();
}
_ => {}
if let Action::Apply = action {
let endpoint = gitlab::api::groups::members::EditGroupMember::builder()
.group(group)
.user(group_member.id)
.access_level(expected_access_level)
.build()
.unwrap();
gitlab::api::ignore(endpoint)
.query_async(&self.client)
.await
.unwrap();
}
Ok(true)
}
......@@ -666,20 +657,17 @@ impl GitLabGlue {
"",
util::format_gitlab_member_access(project, &user.username, access_level).as_str(),
)?;
match action {
Action::Apply => {
let endpoint = gitlab::api::projects::members::AddProjectMember::builder()
.project(project)
.user(gitlab_id)
.access_level(access_level)
.build()
.unwrap();
gitlab::api::ignore(endpoint)
.query_async(&self.client)
.await
.unwrap();
}
_ => {}
if let Action::Apply = action {
let endpoint = gitlab::api::projects::members::AddProjectMember::builder()
.project(project)
.user(gitlab_id)
.access_level(access_level)
.build()
.unwrap();
gitlab::api::ignore(endpoint)
.query_async(&self.client)
.await
.unwrap();
}
Ok(true)
}
......@@ -703,19 +691,16 @@ impl GitLabGlue {
.as_str(),
"",
)?;
match action {
Action::Apply => {
let endpoint = gitlab::api::projects::members::RemoveProjectMember::builder()
.project(project)
.user(member.id)
.build()
.unwrap();
gitlab::api::ignore(endpoint)
.query_async(&self.client)
.await
.unwrap();
}
_ => {}
if let Action::Apply = action {
let endpoint = gitlab::api::projects::members::RemoveProjectMember::builder()
.project(project)
.user(member.id)
.build()
.unwrap();
gitlab::api::ignore(endpoint)
.query_async(&self.client)
.await
.unwrap();
}
Ok(true)
}
......@@ -753,19 +738,16 @@ impl GitLabGlue {
.as_str(),
util::format_gitlab_member_access(project, &user.username, access_level).as_str(),
)?;
match action {
Action::Apply => {
let endpoint = gitlab::api::projects::members::EditProjectMember::builder()
.project(project)
.user(gitlab_id)
.access_level(access_level)
.build()
.unwrap();
gitlab::api::ignore(endpoint)
.query_async(&self.client)
.await?;
}
_ => {}
if let Action::Apply = action {
let endpoint = gitlab::api::projects::members::EditProjectMember::builder()
.project(project)
.user(gitlab_id)
.access_level(access_level)
.build()
.unwrap();
gitlab::api::ignore(endpoint)
.query_async(&self.client)
.await?;
}
Ok(true)
}
......@@ -823,19 +805,16 @@ impl GitLabGlue {
)
.as_str(),
)?;
match action {
Action::Apply => {
let endpoint = gitlab::api::projects::EditProject::builder()
.project(project.id)
.request_access_enabled(expected_request_access_enabled)
.snippets_access_level(expected_snippets_access_level.as_gitlab_type())
.build()
.unwrap();
gitlab::api::ignore(endpoint)
.query_async(&self.client)
.await?;
}
_ => {}
if let Action::Apply = action {
let endpoint = gitlab::api::projects::EditProject::builder()
.project(project.id)
.request_access_enabled(expected_request_access_enabled)
.snippets_access_level(expected_snippets_access_level.as_gitlab_type())
.build()
.unwrap();
gitlab::api::ignore(endpoint)
.query_async(&self.client)
.await?;
}
Ok(true)
}
......
......@@ -114,44 +114,44 @@ impl Keycloak {
.admin
.realm_groups_get(&self.realm, None, None, None, None)
.await?;
let groups = all_groups
let groups_members = all_groups
.iter()
.filter(|group| root_groups.contains(&group.name.as_ref().unwrap().as_ref()));
let groups_members = groups.into_iter().flat_map(|group| {
let group_name = group.name.as_ref().unwrap();
info!(
"collect members of group {} via {}",
group_name,
group.path.as_ref().unwrap()
);
vec![Box::pin(self.get_group_members(group.clone()))]
.into_iter()
.chain(group.sub_groups.as_ref().unwrap().iter().map(|sub_group| {
info!(
"collect members of sub group {} via {}",
sub_group.name.as_ref().unwrap(),
sub_group.path.as_ref().unwrap()
);
Box::pin(self.get_group_members(sub_group.clone()))
}))
.chain(
group
.sub_groups
.as_ref()
.unwrap()
.iter()
.flat_map(|sub_group| sub_group.sub_groups.as_ref().unwrap())
.map(|sub_group| {
info!(
"collect members of sub group {} via {}",
sub_group.name.as_ref().unwrap(),
sub_group.path.as_ref().unwrap(),
);
Box::pin(self.get_group_members(sub_group.clone()))
}),
)
});
.filter(|group| root_groups.contains(&group.name.as_ref().unwrap().as_ref()))
.flat_map(|group| {
let group_name = group.name.as_ref().unwrap();
info!(
"collect members of group {} via {}",
group_name,
group.path.as_ref().unwrap()
);
vec![Box::pin(self.get_group_members(group.clone()))]
.into_iter()
.chain(group.sub_groups.as_ref().unwrap().iter().map(|sub_group| {
info!(
"collect members of sub group {} via {}",
sub_group.name.as_ref().unwrap(),
sub_group.path.as_ref().unwrap()
);
Box::pin(self.get_group_members(sub_group.clone()))
}))
.chain(
group
.sub_groups
.as_ref()
.unwrap()
.iter()
.flat_map(|sub_group| sub_group.sub_groups.as_ref().unwrap())
.map(|sub_group| {
info!(
"collect members of sub group {} via {}",
sub_group.name.as_ref().unwrap(),
sub_group.path.as_ref().unwrap(),
);
Box::pin(self.get_group_members(sub_group.clone()))
}),
)
});
let group_members = try_join_all(groups_members).await?;
let mut state = self.state.lock().await;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment