k8s_openapi_ext/ext/
cluster_role_binding.rs1use super::*;
2
3pub trait ClusterRoleBindingExt: super::ResourceBuilder {
4 fn new(name: impl ToString, cluster_role: &rbacv1::ClusterRole) -> Self;
5
6 fn subjects(self, subjects: impl IntoIterator<Item = rbacv1::Subject>) -> Self;
7}
8
9impl ClusterRoleBindingExt for rbacv1::ClusterRoleBinding {
10 fn new(name: impl ToString, cluster_role: &rbacv1::ClusterRole) -> Self {
11 let metadata = metadata(name);
12 let role_ref = rbacv1::RoleRef::new(cluster_role);
13 Self {
14 metadata,
15 role_ref,
16 ..default()
18 }
19 }
20
21 fn subjects(self, subjects: impl IntoIterator<Item = rbacv1::Subject>) -> Self {
22 let subjects = Some(subjects.into_iter().collect());
23 Self { subjects, ..self }
24 }
25}