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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
use std::path::Path;
use super::*;
pub trait ProbeExt {
fn http_get(path: impl AsRef<Path>, port: u16) -> Self;
fn tcp_socket(port: u16) -> Self;
fn failure_threshold(self, threshold: i32) -> Self;
fn success_threshold(self, threshold: i32) -> Self;
fn initial_delay_seconds(self, seconds: i32) -> Self;
fn period_seconds(self, seconds: i32) -> Self;
fn timeout_seconds(self, seconds: i32) -> Self;
fn termination_grace_period_seconds(self, seconds: i64) -> Self;
}
impl ProbeExt for corev1::Probe {
fn http_get(path: impl AsRef<Path>, port: u16) -> Self {
let path = Some(path.as_ref().display().to_string());
let port = intstr::IntOrString::Int(port.into());
let http_get = Some(corev1::HTTPGetAction {
path,
port,
..default()
});
Self {
http_get,
..default()
}
}
fn tcp_socket(port: u16) -> Self {
let tcp_socket = Some(corev1::TCPSocketAction {
port: intstr::IntOrString::Int(port.into()),
..default()
});
Self {
tcp_socket,
..default()
}
}
fn failure_threshold(mut self, threshold: i32) -> Self {
self.failure_threshold = Some(threshold);
self
}
fn success_threshold(mut self, threshold: i32) -> Self {
self.success_threshold = Some(threshold);
self
}
fn initial_delay_seconds(mut self, seconds: i32) -> Self {
self.initial_delay_seconds = Some(seconds);
self
}
fn period_seconds(mut self, seconds: i32) -> Self {
self.period_seconds = Some(seconds);
self
}
fn timeout_seconds(mut self, seconds: i32) -> Self {
self.timeout_seconds = Some(seconds);
self
}
fn termination_grace_period_seconds(mut self, seconds: i64) -> Self {
self.termination_grace_period_seconds = Some(seconds);
self
}
}