gary_core/
data.rs

1use serde::{Deserialize, Serialize};
2use std::collections::HashMap;
3
4#[derive(Debug, PartialEq, Serialize, Deserialize)]
5pub struct JoinCluster {
6    pub machine_info: MachineInfo,
7}
8
9/*
10apiVersion: apps/v1
11kind: Deployment
12metadata:
13  name: nginx-deployment
14  labels:
15    app: nginx
16spec:
17  replicas: 3
18  selector:
19    matchLabels:
20      app: nginx
21  template:
22    metadata:
23      labels:
24        app: nginx
25    spec:
26      containers:
27      - name: nginx
28        image: nginx:1.7.9
29        ports:
30        - containerPort: 80
31 * */
32#[derive(Debug, PartialEq, Serialize, Deserialize)]
33pub struct Deployment {
34    #[serde(alias = "apiVersion")]
35    pub version: String,
36    pub kind: String,
37    pub metadata: MetaData,
38    pub spec: DeploymentSpec,
39}
40
41#[derive(Debug, PartialEq, Serialize, Deserialize)]
42pub struct DeploymentSpec {
43    pub replicas: i32,
44    pub template: DeploymentTemplate,
45}
46
47#[derive(Debug, PartialEq, Serialize, Deserialize)]
48pub struct DeploymentTemplate {
49    pub metadata: MetaData,
50    pub spec: Spec,
51}
52
53#[derive(Debug, PartialEq, Serialize, Deserialize)]
54pub struct MetaData {
55    pub name: Option<String>,
56    pub labels: HashMap<String, String>,
57}
58
59#[derive(Debug, PartialEq, Serialize, Deserialize)]
60pub struct Spec {
61    pub containers: Vec<Container>,
62}
63
64#[derive(Debug, PartialEq, Serialize, Deserialize)]
65pub struct Container {
66    pub name: String,
67    pub image: String,
68    pub ports: Vec<Ports>,
69}
70
71#[derive(Debug, PartialEq, Serialize, Deserialize)]
72pub struct Ports {
73    #[serde(alias = "containerPort")]
74    pub container_port: i32,
75}
76
77#[derive(Debug, PartialEq, Serialize, Deserialize)]
78pub struct MachineInfo {
79    pub fqdn: String,
80    pub tags: Vec<String>,
81    pub total_memory: i64,
82    pub used_memory: i64,
83    pub total_cpu: i64,
84    pub used_cpu: i64,
85    pub disk_avlible: i64,
86}