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
use super::*;
impl AWSMachineTemplate {
pub fn with_type(name: &str, instance_type: &str) -> Self {
let machine_spec = AWSMachineSpec::with_type(instance_type);
let template = AWSMachineTemplateResource::new(machine_spec);
let spec = AWSMachineTemplateSpec::new(template);
Self::new(name, spec)
}
pub fn t3small(name: &str) -> Self {
Self::with_type(name, "t3small")
}
pub fn m5xlarge(name: &str) -> Self {
Self::with_type(name, "m5xlarge")
}
pub fn ssh_key_name(mut self, name: &str) -> Self {
self.spec.template.spec.ssh_key_name = Some(name.to_string());
self
}
pub fn iam_instance_profile(mut self, iam_instance_profile: &str) -> Self {
self.spec.template.spec.iam_instance_profile = Some(iam_instance_profile.to_string());
self
}
pub fn public_ip(mut self, yes: bool) -> Self {
self.spec.template.spec.public_ip = Some(yes);
self
}
pub fn namespace(self, namespace: &str) -> Self {
Self {
metadata: kube::core::ObjectMeta {
namespace: Some(namespace.to_string()),
..self.metadata
},
..self
}
}
}
impl AWSMachineTemplateSpec {
fn new(template: AWSMachineTemplateResource) -> Self {
Self { template }
}
}
impl AWSMachineTemplateResource {
fn new(spec: AWSMachineSpec) -> Self {
Self {
spec,
..Self::default()
}
}
}
impl AWSMachineSpec {
fn with_type(instnce_type: &str) -> Self {
let instance_type = instnce_type.to_string();
Self {
instance_type,
..Self::default()
}
}
pub fn ssh_key_name(self, ssh_key_name: impl ToString) -> Self {
let ssh_key_name = ssh_key_name.to_string().into();
Self {
ssh_key_name,
..self
}
}
}