89
89
90
90
// Defines memory limits to be set on the pods
91
91
// Is generic to enable adding custom configuration for specific runtimes or products
92
- #[ derive( Clone , Debug , Deserialize , Default , Merge , JsonSchema , PartialEq , Serialize , Eq ) ]
92
+ #[ derive( Clone , Debug , Deserialize , Default , Merge , JsonSchema , PartialEq , Serialize ) ]
93
93
#[ merge( path_overrides( merge = "crate::config::merge" ) ) ]
94
94
#[ serde( rename_all = "camelCase" ) ]
95
95
pub struct MemoryLimits < T >
98
98
{
99
99
// The maximum amount of memory that should be available
100
100
// Should in most cases be mapped to resources.limits.memory
101
- pub limit : Option < String > ,
101
+ pub limit : Option < Quantity > ,
102
102
// Additional options that may be required
103
103
#[ serde( default ) ]
104
104
pub runtime_limits : T ,
@@ -117,9 +117,9 @@ pub struct NoRuntimeLimits {}
117
117
#[ merge( path_overrides( merge = "crate::config::merge" ) ) ]
118
118
#[ serde( rename_all = "camelCase" ) ]
119
119
pub struct JvmHeapLimits {
120
- pub max : Option < String > ,
120
+ pub max : Option < Quantity > ,
121
121
#[ serde( default , skip_serializing_if = "Option::is_none" ) ]
122
- pub min : Option < String > ,
122
+ pub min : Option < Quantity > ,
123
123
}
124
124
125
125
// Cpu limits
@@ -128,16 +128,16 @@ pub struct JvmHeapLimits {
128
128
#[ merge( path_overrides( merge = "crate::config::merge" ) ) ]
129
129
#[ serde( rename_all = "camelCase" ) ]
130
130
pub struct CpuLimits {
131
- pub min : Option < String > ,
132
- pub max : Option < String > ,
131
+ pub min : Option < Quantity > ,
132
+ pub max : Option < Quantity > ,
133
133
}
134
134
135
135
// Struct that exposes the values for a PVC which the user should be able to influence
136
136
#[ derive( Clone , Debug , Default , Deserialize , Merge , JsonSchema , PartialEq , Serialize ) ]
137
137
#[ merge( path_overrides( merge = "crate::config::merge" ) ) ]
138
138
#[ serde( rename_all = "camelCase" ) ]
139
139
pub struct PvcConfig {
140
- pub capacity : Option < String > ,
140
+ pub capacity : Option < Quantity > ,
141
141
#[ serde( default , skip_serializing_if = "Option::is_none" ) ]
142
142
pub storage_class : Option < String > ,
143
143
#[ serde( default , skip_serializing_if = "Option::is_none" ) ]
@@ -160,7 +160,7 @@ impl PvcConfig {
160
160
requests : Some ( {
161
161
let mut map = BTreeMap :: new ( ) ;
162
162
if let Some ( capacity) = & self . capacity {
163
- map. insert ( "storage" . to_string ( ) , Quantity ( capacity. to_string ( ) ) ) ;
163
+ map. insert ( "storage" . to_string ( ) , capacity. clone ( ) ) ;
164
164
}
165
165
map
166
166
} ) ,
@@ -184,15 +184,15 @@ where
184
184
let mut limits = BTreeMap :: new ( ) ;
185
185
let mut requests = BTreeMap :: new ( ) ;
186
186
if let Some ( memory_limit) = self . memory . limit {
187
- limits. insert ( "memory" . to_string ( ) , Quantity ( memory_limit. to_string ( ) ) ) ;
188
- requests. insert ( "memory" . to_string ( ) , Quantity ( memory_limit) ) ;
187
+ limits. insert ( "memory" . to_string ( ) , memory_limit. clone ( ) ) ;
188
+ requests. insert ( "memory" . to_string ( ) , memory_limit) ;
189
189
}
190
190
191
191
if let Some ( cpu_max) = self . cpu . max {
192
- limits. insert ( "cpu" . to_string ( ) , Quantity ( cpu_max) ) ;
192
+ limits. insert ( "cpu" . to_string ( ) , cpu_max) ;
193
193
}
194
194
if let Some ( cpu_min) = self . cpu . min {
195
- requests. insert ( "cpu" . to_string ( ) , Quantity ( cpu_min) ) ;
195
+ requests. insert ( "cpu" . to_string ( ) , cpu_min) ;
196
196
}
197
197
198
198
ResourceRequirements {
0 commit comments