virt-v2v/0001-input-output-Use-Optio...

73 lines
2.6 KiB
Diff

From 24fdb088b1856abec0974a428c424fe598597079 Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Sat, 18 Dec 2021 12:01:19 +0000
Subject: [PATCH] input, output: Use Option.may for some Nbdkit calls
Option.may (Nbdkit.add_arg cmd "port") port;
is completely equivalent to:
(match port with
| Some s -> Nbdkit.add_arg cmd "port" s
| None -> ());
Updates: commit d50966c2a480bda033f6e63bb797f86c13d576bd
---
input/nbdkit_curl.ml | 4 +---
input/nbdkit_ssh.ml | 8 ++------
output/output_rhv_upload.ml | 4 +---
3 files changed, 4 insertions(+), 12 deletions(-)
diff --git a/input/nbdkit_curl.ml b/input/nbdkit_curl.ml
index d6793b22..081c598e 100644
--- a/input/nbdkit_curl.ml
+++ b/input/nbdkit_curl.ml
@@ -57,9 +57,7 @@ let create_curl ?bandwidth ?cookie_script ?cookie_script_renew ?cor
(* https://bugzilla.redhat.com/show_bug.cgi?id=1146007#c10 *)
Nbdkit.add_arg cmd "timeout" "2000";
- (match cookie_script with
- | Some s -> Nbdkit.add_arg cmd "cookie-script" s
- | None -> ());
+ Option.may (Nbdkit.add_arg cmd "cookie-script") cookie_script;
(match cookie_script_renew with
| Some i -> Nbdkit.add_arg cmd "cookie-script-renew" (string_of_int i)
| None -> ());
diff --git a/input/nbdkit_ssh.ml b/input/nbdkit_ssh.ml
index ce972d7d..0a6d8425 100644
--- a/input/nbdkit_ssh.ml
+++ b/input/nbdkit_ssh.ml
@@ -61,12 +61,8 @@ let create_ssh ?bandwidth ?cor ~password ?port ~server ?user path =
let cmd = Nbdkit.create "ssh" in
Nbdkit.add_arg cmd "host" server;
Nbdkit.add_arg cmd "path" path;
- (match port with
- | Some s -> Nbdkit.add_arg cmd "port" s
- | None -> ());
- (match user with
- | Some s -> Nbdkit.add_arg cmd "user" s
- | None -> ());
+ Option.may (Nbdkit.add_arg cmd "port") port;
+ Option.may (Nbdkit.add_arg cmd "user") user;
(* Retry filter (if it exists) can be used to get around brief
* interruptions in service. It must be closest to the plugin.
diff --git a/output/output_rhv_upload.ml b/output/output_rhv_upload.ml
index 7cedfff9..91e7be45 100644
--- a/output/output_rhv_upload.ml
+++ b/output/output_rhv_upload.ml
@@ -345,9 +345,7 @@ e command line has to match the number of guest disk images (for this guest: %d)
(* Create the nbdkit instance. *)
Nbdkit.add_arg cmd "size" (Int64.to_string size);
Nbdkit.add_arg cmd "url" destination_url;
- (match rhv_cafile with
- | None -> ()
- | Some cafile -> Nbdkit.add_arg cmd "cafile" cafile);
+ Option.may (Nbdkit.add_arg cmd "cafile") rhv_cafile;
if not rhv_verifypeer then
Nbdkit.add_arg cmd "insecure" "true";
if is_ovirt_host then
--
2.19.1.3.g30247aa5d201