From 831e0c58020a597e9de684d7940c2a8410c0868e Mon Sep 17 00:00:00 2001 From: Niladri Halder Date: Fri, 22 Dec 2023 07:03:25 +0000 Subject: [PATCH] refactor(upgrade-job): replace &Path with AsRef Signed-off-by: Niladri Halder --- k8s/upgrade/src/bin/upgrade-job/helm/yaml/yq.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/k8s/upgrade/src/bin/upgrade-job/helm/yaml/yq.rs b/k8s/upgrade/src/bin/upgrade-job/helm/yaml/yq.rs index c22db44a5..9869d826a 100644 --- a/k8s/upgrade/src/bin/upgrade-job/helm/yaml/yq.rs +++ b/k8s/upgrade/src/bin/upgrade-job/helm/yaml/yq.rs @@ -177,9 +177,10 @@ impl YqV4 { } /// This sets in-place yaml values in yaml files. - pub(crate) fn set_value(&self, key: YamlKey, value: V, filepath: &Path) -> Result<()> + pub(crate) fn set_value(&self, key: YamlKey, value: V, filepath: P) -> Result<()> where V: Display + Sized, + P: AsRef, { // Command for use during yq file update let mut command = self.command(); @@ -209,7 +210,7 @@ impl YqV4 { let yq_set_args = vec_to_strings![ "-i", format!(r#"{} = {value}"#, key.as_str()), - filepath.to_string_lossy() + filepath.as_ref().to_string_lossy() ]; let yq_set_output = command .args(yq_set_args.clone()) @@ -234,16 +235,20 @@ impl YqV4 { } /// This sets yaml objects to a file from the same yaml object in another file. - pub(crate) fn set_obj(&self, key: YamlKey, obj_source: &Path, filepath: &Path) -> Result<()> { + pub(crate) fn set_obj(&self, key: YamlKey, obj_source: P, filepath: Q) -> Result<()> + where + P: AsRef, + Q: AsRef, + { let yq_set_obj_args = vec_to_strings![ "-i", format!( r#"{} = load("{}"){}"#, key.as_str(), - obj_source.to_string_lossy(), + obj_source.as_ref().to_string_lossy(), key.as_str() ), - filepath.to_string_lossy() + filepath.as_ref().to_string_lossy() ]; let yq_set_obj_output = self .command()