@@ -167,7 +167,51 @@ const Env = z
167167 // Schedule toleration settings - scheduled runs tolerate taints on the dedicated pool
168168 // Comma-separated list of tolerations in the format: key=value:effect
169169 // For Exists operator (no value): key:effect
170- KUBERNETES_SCHEDULED_RUN_TOLERATIONS : z . string ( ) . optional ( ) ,
170+ KUBERNETES_SCHEDULED_RUN_TOLERATIONS : z
171+ . string ( )
172+ . transform ( ( val , ctx ) => {
173+ const tolerations = val
174+ . split ( "," )
175+ . map ( ( entry ) => entry . trim ( ) )
176+ . filter ( ( entry ) => entry . length > 0 )
177+ . map ( ( entry ) => {
178+ const colonIdx = entry . lastIndexOf ( ":" ) ;
179+ if ( colonIdx === - 1 ) {
180+ ctx . addIssue ( {
181+ code : z . ZodIssueCode . custom ,
182+ message : `Invalid toleration format (missing effect): "${ entry } "` ,
183+ } ) ;
184+ return z . NEVER ;
185+ }
186+
187+ const effect = entry . slice ( colonIdx + 1 ) ;
188+ const validEffects = [ "NoSchedule" , "NoExecute" , "PreferNoSchedule" ] ;
189+ if ( ! validEffects . includes ( effect ) ) {
190+ ctx . addIssue ( {
191+ code : z . ZodIssueCode . custom ,
192+ message : `Invalid toleration effect "${ effect } " in "${ entry } ". Must be one of: ${ validEffects . join ( ", " ) } ` ,
193+ } ) ;
194+ return z . NEVER ;
195+ }
196+
197+ const keyValue = entry . slice ( 0 , colonIdx ) ;
198+ const eqIdx = keyValue . indexOf ( "=" ) ;
199+
200+ if ( eqIdx === - 1 ) {
201+ return { key : keyValue , operator : "Exists" as const , effect } ;
202+ }
203+
204+ return {
205+ key : keyValue . slice ( 0 , eqIdx ) ,
206+ operator : "Equal" as const ,
207+ value : keyValue . slice ( eqIdx + 1 ) ,
208+ effect,
209+ } ;
210+ } ) ;
211+
212+ return tolerations ;
213+ } )
214+ . optional ( ) ,
171215
172216 // Placement tags settings
173217 PLACEMENT_TAGS_ENABLED : BoolEnv . default ( false ) ,
0 commit comments