1+ use anyhow:: { anyhow, Context } ;
12use stackable_operator:: {
23 k8s_openapi:: api:: { apps:: v1:: Deployment , core:: v1:: Toleration } ,
3- kube:: api:: { DynamicObject , GroupVersionKind } ,
4+ kube:: {
5+ api:: { DynamicObject , GroupVersionKind } ,
6+ ResourceExt ,
7+ } ,
48} ;
59
610use crate :: data:: get_or_create;
@@ -14,13 +18,19 @@ pub(super) fn maybe_copy_tolerations(
1418 target_gvk : & GroupVersionKind ,
1519) -> anyhow:: Result < ( ) > {
1620 if target_gvk. kind == "DaemonSet" {
21+ let tname = target. name_any ( ) ;
1722 if let Some ( tolerations) = deployment_tolerations ( source) {
1823 let path = "template/spec/tolerations" . split ( "/" ) ;
19- * get_or_create ( target. data . pointer_mut ( "/spec" ) . unwrap ( ) , path) ? =
20- serde_json:: json!( tolerations
21- . iter( )
22- . map( |t| serde_json:: json!( t) )
23- . collect:: <Vec <serde_json:: Value >>( ) ) ;
24+ * get_or_create (
25+ target
26+ . data
27+ . pointer_mut ( "/spec" )
28+ . context ( anyhow ! ( "DaemonSet named [{tname}] has empty .spec" ) ) ?,
29+ path,
30+ ) ? = serde_json:: json!( tolerations
31+ . iter( )
32+ . map( |t| serde_json:: json!( t) )
33+ . collect:: <Vec <serde_json:: Value >>( ) ) ;
2434 }
2535 }
2636
0 commit comments