k8s_openapi_ext/ext/
taint.rs

1use super::*;
2
3pub trait TaintExt {
4    fn no_schedule(key: impl ToString) -> Self;
5    fn prefer_no_schedule(key: impl ToString) -> Self;
6    fn no_execute(key: impl ToString) -> Self;
7    fn value(self, value: impl ToString) -> Self;
8}
9
10impl TaintExt for corev1::Taint {
11    fn no_schedule(key: impl ToString) -> Self {
12        let effect = Effect::NoSchedule.to_string();
13        let key = key.to_string();
14        Self {
15            effect,
16            key,
17            ..default()
18        }
19    }
20
21    fn prefer_no_schedule(key: impl ToString) -> Self {
22        let effect = Effect::PreferNoSchedule.to_string();
23        let key = key.to_string();
24        Self {
25            effect,
26            key,
27            ..default()
28        }
29    }
30
31    fn no_execute(key: impl ToString) -> Self {
32        let effect = Effect::NoExecute.to_string();
33        let key = key.to_string();
34        let time_added = Some(metav1::Time::now());
35        Self {
36            effect,
37            key,
38            time_added,
39            ..default()
40        }
41    }
42
43    fn value(self, value: impl ToString) -> Self {
44        Self {
45            value: Some(value.to_string()),
46            ..self
47        }
48    }
49}