1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use super::*;
pub trait SubjectExt: Sized {
fn with_kind(name: impl ToString, kind: impl ToString) -> Self;
fn user(name: impl ToString) -> Self {
Self::with_kind(name, "User")
}
fn group(name: impl ToString) -> Self {
Self::with_kind(name, "Group")
}
fn service_account(name: impl ToString) -> Self {
Self::with_kind(name, "ServiceAccount")
}
fn namespace(self, namespace: impl ToString) -> Self;
}
impl SubjectExt for rbacv1::Subject {
fn with_kind(name: impl ToString, kind: impl ToString) -> Self {
let kind = kind.to_string();
let name = name.to_string();
Self {
kind,
name,
..default()
}
}
fn namespace(self, namespace: impl ToString) -> Self {
let namespace = Some(namespace.to_string());
Self { namespace, ..self }
}
}