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
//
// Copyright (c) 2021 RepliXio Ltd. All rights reserved.
// Use is subject to license terms.
//

use super::*;

mod impls;

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct Cluster {
    pub id: Uuid,
    pub name: ClusterName,
    pub namespace: Option<String>,
    pub created: DateTime<Utc>,
    pub modified: DateTime<Utc>,
    #[serde(default)]
    pub locations: ClusterLocations,
    pub helm: Vec<Helm>,
}

#[derive(Clone, Copy, Debug, Serialize, Deserialize, PartialEq, PartialOrd, Hash)]
#[serde(rename_all = "lowercase")]
pub enum Provider {
    Eks,
    Aks,
    Kops,
    Generic,
}

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct CreateClusterDto {
    pub name: ClusterName,
    pub namespace: Option<String>,
    pub provider: Provider,
    pub locations: ClusterLocations,
}

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct ClusterToken {
    pub token: String,
}

#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct ClusterName(pub String);

#[derive(Clone, Debug, Default, Serialize, Deserialize)]
pub struct ClusterLocations {
    #[serde(default)]
    pub aws: Vec<ClusterLocationAws>,
    #[serde(default)]
    pub azure: Vec<ClusterLocationAzure>,
}
#[skip_serializing_none]
#[derive(Clone, Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ClusterLocationAws {
    pub region: AwsRegion,
    pub account_principal: Option<String>,
}

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct ClusterLocationAzure {
    pub region: AzureRegion,
}

#[cfg(test)]
mod tests;