@@ -14,9 +14,11 @@ pub struct TypeMeta {
1414 pub kind : String ,
1515}
1616
17- #[ derive( Debug , Serialize , Deserialize , Clone ) ]
17+ #[ derive( Debug , Serialize , Deserialize , Clone , PartialEq , Eq ) ]
1818pub struct ObjectMeta {
1919 pub name : String ,
20+ #[ serde( default ) ]
21+ pub uid : Option < String > ,
2022 #[ serde( default = "default_namespace" ) ]
2123 pub namespace : String ,
2224 #[ serde( default ) ]
@@ -29,7 +31,7 @@ fn default_namespace() -> String {
2931 "default" . to_string ( )
3032}
3133
32- #[ derive( Debug , Serialize , Deserialize , Clone ) ]
34+ #[ derive( Debug , Serialize , Deserialize , Clone , PartialEq , Eq ) ]
3335pub struct PodSpec {
3436 //if pod is distributed to a node ,then this field should be filled with node-id
3537 #[ serde( default ) ]
@@ -42,18 +44,18 @@ pub struct PodSpec {
4244 pub tolerations : Vec < Toleration > ,
4345}
4446
45- #[ derive( Debug , Serialize , Deserialize , Clone ) ]
47+ #[ derive( Debug , Serialize , Deserialize , Clone , PartialEq , Eq ) ]
4648pub struct ContainerRes {
4749 pub limits : Option < Resource > ,
4850}
4951
50- #[ derive( Debug , Serialize , Deserialize , Clone ) ]
52+ #[ derive( Debug , Serialize , Deserialize , Clone , PartialEq , Eq ) ]
5153pub struct Resource {
5254 pub cpu : Option < String > ,
5355 pub memory : Option < String > ,
5456}
5557
56- #[ derive( Debug , Serialize , Deserialize , Clone ) ]
58+ #[ derive( Debug , Serialize , Deserialize , Clone , PartialEq , Eq ) ]
5759pub struct ContainerSpec {
5860 pub name : String ,
5961
@@ -68,7 +70,7 @@ pub struct ContainerSpec {
6870 pub resources : Option < ContainerRes > ,
6971}
7072
71- #[ derive( Debug , Serialize , Deserialize , Clone ) ]
73+ #[ derive( Debug , Serialize , Deserialize , Clone , PartialEq , Eq ) ]
7274pub struct Port {
7375 #[ serde( rename = "containerPort" ) ]
7476 pub container_port : i32 ,
@@ -96,13 +98,13 @@ pub struct PodTask {
9698 pub status : PodStatus ,
9799}
98100
99- #[ derive( Debug , Serialize , Deserialize , Clone , Default ) ]
101+ #[ derive( Debug , Serialize , Deserialize , Clone , Default , PartialEq , Eq ) ]
100102pub struct PodStatus {
101103 #[ serde( rename = "podIP" ) ]
102104 pub pod_ip : Option < String > ,
103105}
104106
105- #[ derive( Debug , Serialize , Deserialize , Clone , Default ) ]
107+ #[ derive( Debug , Serialize , Deserialize , Clone , Default , PartialEq , Eq ) ]
106108pub struct Toleration {
107109 /// Empty means match all taint keys.
108110 pub key : Option < TaintKey > ,
@@ -131,7 +133,7 @@ impl Toleration {
131133 }
132134 }
133135}
134- #[ derive( Debug , Serialize , Deserialize , Clone ) ]
136+ #[ derive( Debug , Serialize , Deserialize , Clone , PartialEq , Eq ) ]
135137pub enum TolerationOperator {
136138 Exists ,
137139 Equal ,
@@ -322,3 +324,71 @@ pub struct ServiceTask {
322324 pub metadata : ObjectMeta ,
323325 pub spec : ServiceSpec ,
324326}
327+
328+ #[ derive( Debug , Serialize , Deserialize , Clone , Default , PartialEq , Eq ) ]
329+ pub struct LabelSelector {
330+ #[ serde( rename = "matchLabels" , default ) ]
331+ pub match_labels : HashMap < String , String > ,
332+
333+ #[ serde( rename = "matchExpressions" , default ) ]
334+ pub match_expressions : Vec < LabelSelectorRequirement > ,
335+ }
336+
337+ #[ derive( Debug , Serialize , Deserialize , Clone , PartialEq , Eq ) ]
338+ pub struct LabelSelectorRequirement {
339+ pub key : String ,
340+ pub operator : LabelSelectorOperator ,
341+ #[ serde( default ) ]
342+ pub values : Vec < String > ,
343+ }
344+
345+ #[ derive( Debug , Serialize , Deserialize , Clone , PartialEq , Eq ) ]
346+ #[ serde( rename_all = "PascalCase" ) ]
347+ pub enum LabelSelectorOperator {
348+ In ,
349+ NotIn ,
350+ Exists ,
351+ DoesNotExist ,
352+ }
353+
354+ fn default_replicas ( ) -> i32 {
355+ 1
356+ }
357+
358+ #[ derive( Debug , Serialize , Deserialize , Clone , PartialEq , Eq ) ]
359+ pub struct PodTemplateSpec {
360+ pub metadata : ObjectMeta ,
361+ pub spec : PodSpec ,
362+ }
363+
364+ #[ derive( Debug , Serialize , Deserialize , Clone , PartialEq , Eq ) ]
365+ pub struct ReplicaSetSpec {
366+ #[ serde( default = "default_replicas" ) ]
367+ pub replicas : i32 ,
368+ pub selector : LabelSelector ,
369+ pub template : PodTemplateSpec ,
370+ }
371+
372+ #[ derive( Debug , Serialize , Deserialize , Clone , Default ) ]
373+ pub struct ReplicaSetStatus {
374+ #[ serde( default ) ]
375+ pub replicas : i32 ,
376+ #[ serde( rename = "fullyLabeledReplicas" , default ) ]
377+ pub fully_labeled_replicas : i32 ,
378+ #[ serde( rename = "readyReplicas" , default ) ]
379+ pub ready_replicas : i32 ,
380+ #[ serde( rename = "availableReplicas" , default ) ]
381+ pub available_replicas : i32 ,
382+ }
383+
384+ #[ derive( Debug , Serialize , Deserialize , Clone ) ]
385+ pub struct ReplicaSet {
386+ #[ serde( rename = "apiVersion" ) ]
387+ pub api_version : String ,
388+ #[ serde( rename = "kind" ) ]
389+ pub kind : String ,
390+ pub metadata : ObjectMeta ,
391+ pub spec : ReplicaSetSpec ,
392+ #[ serde( default ) ]
393+ pub status : ReplicaSetStatus ,
394+ }
0 commit comments