@@ -114,22 +114,20 @@ async fn main() -> Result<(), anyhow::Error> {
114114 copy_core_dump_composer_to_hostdir ( host_location) ?;
115115 apply_sysctl (
116116 "kernel.core_pattern" ,
117- format ! ( "{}/core_pattern.bak" , host_location ) . as_str ( ) ,
117+ format ! ( "{host_location }/core_pattern.bak" ) . as_str ( ) ,
118118 format ! (
119- "|{}/{} -c=%c -e=%e -p=%p -s=%s -t=%t -d={} -h=%h -E=%E" ,
120- host_location, CDC_NAME , core_dir_command
121- )
119+ "|{host_location}/{CDC_NAME} -c=%c -e=%e -p=%p -s=%s -t=%t -d={core_dir_command} -h=%h -E=%E" )
122120 . as_str ( ) ,
123121 ) ?;
124122 apply_sysctl (
125123 "kernel.core_pipe_limit" ,
126- format ! ( "{}/core_pipe_limit.bak" , host_location ) . as_str ( ) ,
124+ format ! ( "{host_location }/core_pipe_limit.bak" ) . as_str ( ) ,
127125 "128" ,
128126 ) ?;
129127
130128 apply_sysctl (
131129 "fs.suid_dumpable" ,
132- format ! ( "{}/suid_dumpable.bak" , host_location ) . as_str ( ) ,
130+ format ! ( "{host_location }/suid_dumpable.bak" ) . as_str ( ) ,
133131 & suid,
134132 ) ?;
135133
@@ -165,12 +163,12 @@ async fn main() -> Result<(), anyhow::Error> {
165163 let mut i_interval = match interval. parse :: < u64 > ( ) {
166164 Ok ( v) => v,
167165 Err ( e) => {
168- error ! ( "Error parsing interval : {} Error: {}" , interval , e ) ;
169- panic ! ( "Error parsing interval {}" , e ) ;
166+ error ! ( "Error parsing interval : {interval } Error: {e}" ) ;
167+ panic ! ( "Error parsing interval {e}" ) ;
170168 }
171169 } ;
172170 i_interval /= 1000 ;
173- schedule = format ! ( "1/{} * * * * *" , i_interval ) ;
171+ schedule = format ! ( "1/{i_interval } * * * * *" ) ;
174172 if use_inotify == "true" {
175173 warn ! ( "Both schedule and INotify set. Running schedule" )
176174 }
@@ -181,8 +179,8 @@ async fn main() -> Result<(), anyhow::Error> {
181179 let sched = match JobScheduler :: new ( ) . await {
182180 Ok ( v) => v,
183181 Err ( e) => {
184- error ! ( "Schedule Creation Failed with {}" , e ) ;
185- panic ! ( "Schedule Creation Failed with {}" , e )
182+ error ! ( "Schedule Creation Failed with {e}" ) ;
183+ panic ! ( "Schedule Creation Failed with {e}" )
186184 }
187185 } ;
188186
@@ -200,23 +198,23 @@ async fn main() -> Result<(), anyhow::Error> {
200198 } ) {
201199 Ok ( v) => v,
202200 Err ( e) => {
203- error ! ( "Schedule Job Creation with {} failed, {}" , schedule , e ) ;
204- panic ! ( "Schedule Job Creation with {} failed, {}" , schedule , e )
201+ error ! ( "Schedule Job Creation with {schedule } failed, {e}" ) ;
202+ panic ! ( "Schedule Job Creation with {schedule } failed, {e}" )
205203 }
206204 } ;
207205 info ! ( "Created Schedule job: {:?}" , s_job. guid( ) ) ;
208206 match sched. add ( s_job) . await {
209207 Ok ( v) => v,
210208 Err ( e) => {
211- error ! ( "Job Add failed {:#?}" , e ) ;
212- panic ! ( "Job Scheduing failed, {:#?}" , e ) ;
209+ error ! ( "Job Add failed {e :#?}" ) ;
210+ panic ! ( "Job Scheduing failed, {e :#?}" ) ;
213211 }
214212 } ;
215213 match sched. start ( ) . await {
216214 Ok ( v) => v,
217215 Err ( e) => {
218- error ! ( "Schedule Start failed {:#?}" , e ) ;
219- panic ! ( "Schedule Start failed, {:#?}" , e ) ;
216+ error ! ( "Schedule Start failed {e :#?}" ) ;
217+ panic ! ( "Schedule Start failed, {e :#?}" ) ;
220218 }
221219 } ;
222220 loop {
@@ -230,16 +228,16 @@ async fn main() -> Result<(), anyhow::Error> {
230228 let mut inotify = match Inotify :: init ( ) {
231229 Ok ( v) => v,
232230 Err ( e) => {
233- error ! ( "Inotify init failed: {}" , e ) ;
234- panic ! ( "Inotify init failed: {}" , e )
231+ error ! ( "Inotify init failed: {e}" ) ;
232+ panic ! ( "Inotify init failed: {e}" )
235233 }
236234 } ;
237235 info ! ( "INotify Initialised..." ) ;
238236 match inotify. add_watch ( & core_dir_command, WatchMask :: CLOSE ) {
239237 Ok ( _) => { }
240238 Err ( e) => {
241- error ! ( "Add watch failed: {}" , e ) ;
242- panic ! ( "Add watch failed: {}" , e )
239+ error ! ( "Add watch failed: {e}" ) ;
240+ panic ! ( "Add watch failed: {e}" )
243241 }
244242 } ;
245243 info ! ( "INotify watching : {}" , core_dir_command) ;
@@ -426,7 +424,7 @@ fn generate_crio_config(host_location: &str) -> Result<(), std::io::Error> {
426424 . unwrap_or_else ( |_| "unix:///run/containerd/containerd.sock" . to_string ( ) ) ;
427425 let destination = format ! ( "{}/{}" , host_location, "crictl.yaml" ) ;
428426 let mut crictl_file = File :: create ( destination) ?;
429- let text = format ! ( "runtime-endpoint: {}\n image-endpoint: {}\n timeout: 2\n debug: false\n pull-image-on-create: false" , endpoint , endpoint ) ;
427+ let text = format ! ( "runtime-endpoint: {endpoint }\n image-endpoint: {endpoint }\n timeout: 2\n debug: false\n pull-image-on-create: false" ) ;
430428 crictl_file. write_all ( text. as_bytes ( ) ) ?;
431429 crictl_file. flush ( ) ?;
432430 Ok ( ( ) )
@@ -444,14 +442,14 @@ fn copy_core_dump_composer_to_hostdir(host_location: &str) -> Result<(), std::io
444442 let version = env:: var ( "VENDOR" ) . unwrap_or_else ( |_| "default" . to_string ( ) ) ;
445443 match version. to_lowercase ( ) . as_str ( ) {
446444 "default" => {
447- let location = format ! ( "./vendor/default/{}" , CDC_NAME ) ;
448- let destination = format ! ( "{}/{}" , host_location , CDC_NAME ) ;
445+ let location = format ! ( "./vendor/default/{CDC_NAME}" ) ;
446+ let destination = format ! ( "{host_location }/{CDC_NAME}" ) ;
449447 info ! ( "Copying the composer from {} to {}" , location, destination) ;
450448 fs:: copy ( location, destination) ?;
451449 }
452450 "rhel7" => {
453- let location = format ! ( "./vendor/rhel7/{}" , CDC_NAME ) ;
454- let destination = format ! ( "{}/{}" , host_location , CDC_NAME ) ;
451+ let location = format ! ( "./vendor/rhel7/{CDC_NAME}" ) ;
452+ let destination = format ! ( "{host_location }/{CDC_NAME}" ) ;
455453 info ! ( "Copying the composer from {} to {}" , location, destination) ;
456454 fs:: copy ( location, destination) ?;
457455 }
@@ -494,9 +492,7 @@ fn create_env_file(host_location: &str) -> Result<(), std::io::Error> {
494492 info ! ( "Creating {} file with LOG_LEVEL={}" , destination, loglevel) ;
495493 let mut env_file = File :: create ( destination) ?;
496494 let text = format ! (
497- "LOG_LEVEL={}\n IGNORE_CRIO={}\n CRIO_IMAGE_CMD={}\n USE_CRIO_CONF={}\n FILENAME_TEMPLATE={}\n LOG_LENGTH={}\n POD_SELECTOR_LABEL={}\n TIMEOUT={}\n COMPRESSION={}\n CORE_EVENTS={}\n EVENT_DIRECTORY={}\n " ,
498- loglevel, ignore_crio, crio_image, use_crio_config, filename_template, log_length, pod_selector_label, timeout, compression, core_events, event_directory
499- ) ;
495+ "LOG_LEVEL={loglevel}\n IGNORE_CRIO={ignore_crio}\n CRIO_IMAGE_CMD={crio_image}\n USE_CRIO_CONF={use_crio_config}\n FILENAME_TEMPLATE={filename_template}\n LOG_LENGTH={log_length}\n POD_SELECTOR_LABEL={pod_selector_label}\n TIMEOUT={timeout}\n COMPRESSION={compression}\n CORE_EVENTS={core_events}\n EVENT_DIRECTORY={event_directory}\n " ) ;
500496 info ! ( "Writing composer .env \n {}" , text) ;
501497 env_file. write_all ( text. as_bytes ( ) ) ?;
502498 env_file. flush ( ) ?;
@@ -537,7 +533,7 @@ fn apply_sysctl(name: &str, location: &str, value: &str) -> Result<(), anyhow::E
537533}
538534
539535fn overwrite_sysctl ( name : & str , value : & str ) -> Result < ( ) , anyhow:: Error > {
540- let s = format ! ( "{}={}" , name , value ) ;
536+ let s = format ! ( "{name }={value}" ) ;
541537 let output = Command :: new ( "sysctl" )
542538 . env ( "PATH" , get_path ( ) )
543539 . args ( [ "-w" , s. as_str ( ) ] )
@@ -557,11 +553,11 @@ fn remove() -> Result<(), anyhow::Error> {
557553 restore_sysctl ( "kernel" , "core_pipe_limit" ) ?;
558554 restore_sysctl ( "fs" , "suid_dumpable" ) ?;
559555 let host_dir = env:: var ( "HOST_DIR" ) . unwrap_or_else ( |_| DEFAULT_BASE_DIR . to_string ( ) ) ;
560- let exe = format ! ( "{}/{}" , host_dir , CDC_NAME ) ;
561- let env_file = format ! ( "{}/{}" , host_dir , " .env") ;
562- let crictl_file = format ! ( "{}/{}" , host_dir , " crictl.yaml") ;
563- let composer_file = format ! ( "{}/{}" , host_dir , " composer.log") ;
564- let crictl_exe = format ! ( "{}/{}" , host_dir , " crictl") ;
556+ let exe = format ! ( "{host_dir }/{CDC_NAME}" ) ;
557+ let env_file = format ! ( "{host_dir}/ .env" ) ;
558+ let crictl_file = format ! ( "{host_dir}/ crictl.yaml" ) ;
559+ let composer_file = format ! ( "{host_dir}/ composer.log" ) ;
560+ let crictl_exe = format ! ( "{host_dir}/ crictl" ) ;
565561
566562 fs:: remove_file ( exe) ?;
567563 fs:: remove_file ( env_file) ?;
@@ -581,8 +577,8 @@ fn remove() -> Result<(), anyhow::Error> {
581577fn restore_sysctl ( prefix : & str , name : & str ) -> Result < ( ) , anyhow:: Error > {
582578 info ! ( "Restoring Backup of {}" , name) ;
583579 let host_dir = env:: var ( "HOST_DIR" ) . unwrap_or_else ( |_| DEFAULT_BASE_DIR . to_string ( ) ) ;
584- let file_name = format ! ( "{}/{}.bak" , host_dir , name ) ;
585- let sysctl_name = format ! ( "{}.{}" , prefix , name ) ;
580+ let file_name = format ! ( "{host_dir }/{name }.bak" ) ;
581+ let sysctl_name = format ! ( "{prefix }.{name}" ) ;
586582 let line = fs:: read_to_string ( & file_name) ?;
587583 overwrite_sysctl ( sysctl_name. as_str ( ) , line. as_str ( ) ) ?;
588584 fs:: remove_file ( file_name) ?;
0 commit comments