devops_armory/cloud/gcp/gke/deployment/
models.rs1use serde_derive::{Serialize, Deserialize};
2
3#[derive(Serialize, Deserialize, Default,Debug)]
4pub struct CreateDeployment {
5 pub apiVersion: String,
6 pub kind: String,
7 pub metadata: DeploymentMetadata,
8 pub spec: DeploymentSpec,
9}
10
11#[derive(Serialize, Deserialize, Default,Debug)]
12pub struct DeploymentMetadata {
13 pub name: String,
14 pub labels: DeploymentMetadataLabels,
15 pub namespace: String
16}
17
18#[derive(Serialize, Deserialize, Default,Debug)]
19pub struct DeploymentMetadataLabels {
20 pub app: String
21}
22
23#[derive(Serialize, Deserialize, Default,Debug)]
24pub struct DeploymentSpec {
25 pub strategy: DeploymentSpecStrategy,
26 pub replicas: i32,
27 pub selector: DeploymentSelector,
28 pub template: DeploymentTemplate,
29}
30
31#[derive(Serialize, Deserialize, Default,Debug)]
32pub struct DeploymentSpecStrategy {
33 pub r#type: String,
34 pub rollingUpdate: RollingUpdate
35}
36
37#[derive(Serialize, Deserialize, Default,Debug)]
38pub struct RollingUpdate {
39 pub maxSurge: String,
40 pub maxUnavailable: String,
41}
42
43#[derive(Serialize, Deserialize, Default,Debug)]
44pub struct DeploymentSelector {
45 pub matchLabels: SelectorLabels
46}
47
48#[derive(Serialize, Deserialize, Default,Debug)]
49pub struct SelectorLabels {
50 pub app: String
51}
52
53#[derive(Serialize, Deserialize, Default,Debug)]
54pub struct DeploymentTemplate {
55 pub metadata: DeploymentTemplateMetadata,
56 pub spec: DeploymentTemplateSpec
57}
58
59#[derive(Serialize, Deserialize, Default,Debug)]
60pub struct DeploymentTemplateMetadata {
61 pub labels: DeploymentTemplateMetadataLabels
62}
63
64#[derive(Serialize, Deserialize, Default,Debug)]
65pub struct DeploymentTemplateMetadataLabels {
66 pub app: String
67}
68
69#[derive(Serialize, Deserialize, Default,Debug)]
70pub struct DeploymentTemplateSpec {
71 pub restartPolicy: String,
72 pub dnsPolicy: String,
73 pub terminationGracePeriodSeconds: i64,
74 pub containers: Vec<DeploymentContainers>
75}
76
77#[derive(Serialize, Deserialize, Default,Debug)]
78pub struct DeploymentContainers {
79 pub name: String,
80 pub image: String,
81 pub imagePullPolicy: String,
82 pub command: Vec<String>,
83 pub resources: DeploymentResources,
84 pub ports: Vec<DeploymentPorts>,
85 pub livenessProbe: DeploymentProbe,
86 pub readinessProbe: DeploymentProbe,
87 pub env: Vec<DeploymentEnvs>
88}
89
90#[derive(Serialize, Deserialize, Default,Debug)]
91pub struct DeploymentResources {
92 pub requests: DeploymentResourcesRequests,
93 pub limits: DeploymentResourcesLimits,
94}
95
96#[derive(Serialize, Deserialize, Default,Debug)]
97pub struct DeploymentResourcesRequests {
98 pub memory: String,
99 pub cpu: f32
100}
101
102#[derive(Serialize, Deserialize, Default,Debug)]
103pub struct DeploymentResourcesLimits {
104 pub memory: String,
105 pub cpu: f32
106}
107
108#[derive(Serialize, Deserialize, Default,Debug)]
109pub struct DeploymentProbe {
110 pub failureThreshold: i32,
111 pub httpGet: HttpProbe,
112 pub initialDelaySeconds: i32,
113 pub periodSeconds: i32,
114 pub successThreshold: i8,
115 pub timeoutSeconds: i32
116}
117
118#[derive(Serialize, Deserialize, Default,Debug)]
119pub struct HttpProbe {
120 pub path: String,
121 pub port: i64,
122 pub scheme: String,
123}
124
125#[derive(Serialize, Deserialize, Default,Debug)]
126pub struct DeploymentPorts {
127 pub containerPort: i64,
128 pub protocol: String
129}
130
131#[derive(Serialize, Deserialize, Default,Debug)]
135pub struct UpdateDeployment {
136 pub apiVersion: String,
137 pub kind: String,
138 pub metadata: DeploymentMetadata,
139 pub spec: UpdateDeploymentSpec,
140}
141
142#[derive(Serialize, Deserialize, Default,Debug)]
143pub struct UpdateDeploymentSpec {
144 pub selector: UpdateDeploymentSelector,
145 pub template: UpdateDeploymentTemplate,
146}
147
148#[derive(Serialize, Deserialize, Default,Debug)]
149pub struct UpdateDeploymentSelector {
150 pub matchLabels: UpdateSelectorLabels
151}
152
153#[derive(Serialize, Deserialize, Default,Debug)]
154pub struct UpdateSelectorLabels {
155 pub app: String
156}
157
158#[derive(Serialize, Deserialize, Default,Debug)]
159pub struct UpdateDeploymentTemplate {
160 pub metadata: UpdateDeploymentTemplateMetadata,
161 pub spec: UpdateDeploymentTemplateSpec
162}
163
164#[derive(Serialize, Deserialize, Default,Debug)]
165pub struct UpdateDeploymentTemplateMetadata {
166 pub labels: UpdateDeploymentTemplateMetadataLabels
167}
168
169#[derive(Serialize, Deserialize, Default,Debug)]
170pub struct UpdateDeploymentTemplateMetadataLabels {
171 pub app: String
172}
173
174#[derive(Serialize, Deserialize, Default,Debug)]
175pub struct UpdateDeploymentTemplateSpec {
176 pub containers: Option<Vec<UpdateDeploymentContainers>>
177}
178
179#[derive(Serialize, Deserialize, Default,Debug)]
180pub struct UpdateDeploymentContainers {
181 pub name: String,
182 #[serde(skip_serializing_if = "Option::is_none")]
183 #[serde(default)]
184 pub image: Option<String>,
185 #[serde(skip_serializing_if = "Option::is_none")]
186 #[serde(default)]
187 pub imagePullPolicy: Option<String>,
188 #[serde(skip_serializing_if = "Option::is_none")]
189 #[serde(default)]
190 pub command: Option<Vec<String>>,
191 #[serde(skip_serializing_if = "Option::is_none")]
192 #[serde(default)]
193 pub resources: Option<DeploymentResources>,
194 #[serde(skip_serializing_if = "Option::is_none")]
195 #[serde(default)]
196 pub ports: Option<Vec<DeploymentPorts>>,
197 #[serde(skip_serializing_if = "Option::is_none")]
198 #[serde(default)]
199 pub livenessProbe: Option<DeploymentProbe>,
200 #[serde(skip_serializing_if = "Option::is_none")]
201 #[serde(default)]
202 pub readinessProbe: Option<DeploymentProbe>,
203 #[serde(skip_serializing_if = "Option::is_none")]
204 #[serde(default)]
205 pub env: Option<Vec<DeploymentEnvSpecs>>
206}
207
208#[derive(Serialize, Deserialize, Debug)]
209pub enum DeploymentEnvSpecs {
210 PlainValue(DeploymentEnvs),
211 SecretValue(DeploymentEnvSecret)
212}
213
214#[derive(Serialize, Deserialize, Default,Debug)]
215pub struct DeploymentEnvs {
216 pub name: String,
217 pub value: String
218}
219
220#[derive(Serialize, Deserialize, Default,Debug)]
221pub struct DeploymentEnvSecret {
222 pub name: String,
223 pub valueFrom: SecretValueFrom
224}
225
226#[derive(Serialize, Deserialize, Default,Debug)]
227pub struct SecretValueFrom {
228 pub secretKeyRef: SecretyKeyRef
229}
230
231#[derive(Serialize, Deserialize, Default,Debug)]
232pub struct SecretyKeyRef {
233 pub name: String,
234 pub key: String
235}