summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2022-09-09 07:10:12 +0000
committerLars Wirzenius <liw@liw.fi>2022-09-09 07:10:12 +0000
commit024b1f55d6ff090a38ba697d410165f59a0f9ed6 (patch)
tree05beca8fe80d19ec7e7529389702048eee2ab631
parentbafcd4242edcac67039b0c12fa33f27445bee03d (diff)
parent2a78d1909ba7ccecad6e07a4b988eb77d4385359 (diff)
downloadvmadm-024b1f55d6ff090a38ba697d410165f59a0f9ed6.tar.gz
Merge branch 'fixes' into 'main'
chore: use unwrap_or instead of more complicated structure See merge request larswirzenius/vmadm!60
-rwxr-xr-xcheck31
-rw-r--r--src/cloudinit.rs4
-rw-r--r--src/spec.rs2
-rw-r--r--vmadm.md16
-rw-r--r--vmadm.subplot15
5 files changed, 32 insertions, 36 deletions
diff --git a/check b/check
index 0e48419..a6018e3 100755
--- a/check
+++ b/check
@@ -5,27 +5,24 @@
set -eu
hideok=chronic
-if [ "$#" -gt 0 ]
-then
- case "$1" in
+if [ "$#" -gt 0 ]; then
+ case "$1" in
verbose | -v | --verbose)
- hideok=
- shift
- ;;
- esac
+ hideok=
+ shift
+ ;;
+ esac
fi
-if [ "$#" = 0 ]
-then
- echo "MUST give path to base image for testing" 1>&2
- exit 1
+if [ "$#" = 0 ]; then
+ echo "MUST give path to base image for testing" 1>&2
+ exit 1
fi
base_image="$1"
shift
-got_cargo_cmd()
-{
- cargo --list | grep " $1 " > /dev/null
+got_cargo_cmd() {
+ cargo --list | grep " $1 " >/dev/null
}
$hideok cargo build --all-targets
@@ -33,10 +30,10 @@ got_cargo_cmd clippy && cargo clippy -q
got_cargo_cmd fmt && $hideok cargo fmt -- --check
$hideok cargo test
-subplot docgen vmadm.md -o vmadm.html
-subplot docgen vmadm.md -o vmadm.pdf
+subplot docgen vmadm.subplot -o vmadm.html
+subplot docgen vmadm.subplot -o vmadm.pdf
-subplot codegen vmadm.md -o test.py
+subplot codegen vmadm.subplot -o test.py
rm -f test.log
$hideok python3 test.py --log test.log --env="BASE_IMAGE=$base_image" "$@"
diff --git a/src/cloudinit.rs b/src/cloudinit.rs
index c748dd1..9d14538 100644
--- a/src/cloudinit.rs
+++ b/src/cloudinit.rs
@@ -175,8 +175,8 @@ impl Metadata {
}
fn cleanup_document(doc: &str) -> String {
- let doc = doc.strip_prefix("---\n").or(Some(doc)).unwrap();
- let doc = doc.strip_suffix('\n').or(Some(doc)).unwrap();
+ let doc = doc.strip_prefix("---\n").unwrap_or(doc);
+ let doc = doc.strip_suffix('\n').unwrap_or(doc);
doc.to_string()
}
diff --git a/src/spec.rs b/src/spec.rs
index 332bf94..5f5a28e 100644
--- a/src/spec.rs
+++ b/src/spec.rs
@@ -387,7 +387,7 @@ fn ssh_keys(filenames: &[PathBuf]) -> Result<Vec<String>, SpecificationError> {
let key =
std::fs::read(&filename).map_err(|e| SpecificationError::SshKeyRead(filename, e))?;
let key = String::from_utf8(key)?;
- let key = key.strip_suffix('\n').or(Some(&key)).unwrap();
+ let key = key.strip_suffix('\n').unwrap_or(&key);
keys.push(key.to_string());
}
Ok(keys)
diff --git a/vmadm.md b/vmadm.md
index e24e0db..7d5ae96 100644
--- a/vmadm.md
+++ b/vmadm.md
@@ -1,19 +1,3 @@
----
-title: "vmadm &ndash; virtual machine administration"
-author: "Lars Wirzenius"
-bindings:
- - subplot/vmadm.yaml
- - lib/files.yaml
- - lib/runcmd.yaml
-impls:
- python:
- - subplot/vmadm.py
- - lib/files.py
- - lib/runcmd.py
-classes:
-- json
-...
-
# Data files for scenarios
This section has some data files used by scenarios.
diff --git a/vmadm.subplot b/vmadm.subplot
new file mode 100644
index 0000000..ef76a9e
--- /dev/null
+++ b/vmadm.subplot
@@ -0,0 +1,15 @@
+title: "vmadm &ndash; virtual machine administration"
+author: "Lars Wirzenius"
+markdowns:
+ - vmadm.md
+bindings:
+ - subplot/vmadm.yaml
+ - lib/files.yaml
+ - lib/runcmd.yaml
+impls:
+ python:
+ - subplot/vmadm.py
+ - lib/files.py
+ - lib/runcmd.py
+classes:
+- json