summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cloudinit.rs15
1 files changed, 3 insertions, 12 deletions
diff --git a/src/cloudinit.rs b/src/cloudinit.rs
index f1b56ce..2c521fd 100644
--- a/src/cloudinit.rs
+++ b/src/cloudinit.rs
@@ -129,17 +129,8 @@ impl Metadata {
}
fn cleanup_document(doc: &str) -> String {
- let marker = "---\n";
- let doc = if doc.starts_with(marker) {
- &doc[marker.len()..]
- } else {
- doc
- };
- if doc.ends_with("\n") {
- &doc[..doc.len() - 1]
- } else {
- doc
- };
+ let doc = doc.strip_prefix("---\n").or(Some(doc)).unwrap();
+ let doc = doc.strip_suffix("\n").or(Some(doc)).unwrap();
doc.to_string()
}
@@ -160,7 +151,7 @@ impl Userdata {
ssh_keys: Hostkeys::from(spec),
runcmd: vec![
format!("python3 -c {}", quote(SCRIPT)),
- format!("systemctl reload ssh"),
+ "systemctl reload ssh".to_string(),
],
})
}