Skip to content

Commit

Permalink
fix: RoleRef should be cluster-wide when referencing cluster roles
Browse files Browse the repository at this point in the history
Signed-off-by: Chris Laprun <[email protected]>
  • Loading branch information
metacosm committed Jan 13, 2025
1 parent 66c59b6 commit 38f0aa3
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ void augmentRBACForResources(BuildTimeOperatorConfiguration buildTimeConfigurati
}

private KubernetesRoleBindingBuildItem roleBindingItemFor(RoleBinding binding) {
final var roleRef = convertToQuarkusRoleRef(binding.getRoleRef(), false); // todo: fix
final var roleRef = convertToQuarkusRoleRef(binding.getRoleRef());
final var subjects = binding.getSubjects().stream()
.map(RBACAugmentationStep::convertToQuarkusSubject)
.toArray(Subject[]::new);
Expand All @@ -81,7 +81,7 @@ private KubernetesRoleBindingBuildItem roleBindingItemFor(RoleBinding binding) {
}

private KubernetesClusterRoleBindingBuildItem clusterRoleBindingFor(ClusterRoleBinding binding) {
final var roleRef = convertToQuarkusRoleRef(binding.getRoleRef(), true); // todo: fix
final var roleRef = convertToQuarkusRoleRef(binding.getRoleRef());
final var subjects = binding.getSubjects().stream()
.map(RBACAugmentationStep::convertToQuarkusSubject)
.toArray(Subject[]::new);
Expand All @@ -94,8 +94,8 @@ private static Subject convertToQuarkusSubject(io.fabric8.kubernetes.api.model.r
return new Subject(subject.getApiGroup(), subject.getKind(), subject.getName(), subject.getNamespace());
}

private static RoleRef convertToQuarkusRoleRef(io.fabric8.kubernetes.api.model.rbac.RoleRef roleRef, boolean clusterWide) {
return new RoleRef(roleRef.getName(), clusterWide);
private static RoleRef convertToQuarkusRoleRef(io.fabric8.kubernetes.api.model.rbac.RoleRef roleRef) {
return new RoleRef(roleRef.getName(), AddRoleBindingsDecorator.CLUSTER_ROLE.equals(roleRef.getKind()));
}

private static KubernetesClusterRoleBuildItem clusterRoleBuildItemFrom(ClusterRole clusterRole) {
Expand Down

0 comments on commit 38f0aa3

Please sign in to comment.