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 maplit::{btreemap, convert_args};

use super::*;

impl KubeadmConfigTemplate {
    pub fn aws(name: &str) -> Self {
        let spec = KubeadmConfigTemplateSpec {
            template: KubeadmConfigTemplateResource {
                spec: KubeadmConfigSpec {
                    join_configuration: Some(JoinConfiguration {
                        node_registration: Some(NodeRegistrationOptions {
                            kubelet_extra_args: convert_args!(btreemap!("cloud-provider" => "aws")),
                            name: Some("{{ ds.meta_data.local_hostname }}".to_string()),
                            ..Default::default()
                        }),
                        ..Default::default()
                    }),
                    ..Default::default()
                },
            },
        };
        Self::new(name, spec)
    }

    #[must_use]
    pub fn namespace(self, namespace: &str) -> Self {
        Self {
            metadata: kube::core::ObjectMeta {
                namespace: Some(namespace.to_string()),
                ..self.metadata
            },
            ..self
        }
    }
}