]> xenbits.xensource.com Git - people/royger/osstest.git/commitdiff
mg-anoint: Support mg-anoint retrieve --tolerate-unprepared
authorIan Jackson <ian.jackson@eu.citrix.com>
Thu, 17 May 2018 11:05:48 +0000 (12:05 +0100)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Wed, 23 May 2018 16:13:28 +0000 (17:13 +0100)
make-*-flight is going to want this.

Signed-off-by: Ian Jackson <Ian.Jackson@eu.citrix.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
mg-anoint

index 522cbddb0c5e741b6b4926a28427b2e179dca70f..d09124b3066ba9300d0b2f4275895d8384b9c452 100755 (executable)
--- a/mg-anoint
+++ b/mg-anoint
 #        --allow-blessed=BLESSING,...       default is from `prepare'
 #        --allow-job-status=STATUS,...      default is only `pass'
 #
-#  ./mg-anoint retrieve REFKEY
+#  ./mg-anoint retrieve [--tolerate-unprepared] REFKEY
 #      => FLIGHT JOB
 #         if nothing anointed yet, prints nothing and exits 0
 #         if anointment not prepared, fails
+#      With --tolerate-unprepared, it is not an error if nothing is
+#      reported because the anointment has not been prepared.
 #
 #  ./mg-anoint list-prepared REFKEY-GLOB
 #      => possibly empty list of REFKEYs
@@ -294,6 +296,11 @@ END
 }    
 
 sub cmd_retrieve {
+    my $tolerate_unprepared;
+    if (@ARGV && $ARGV[0] eq '--tolerate-unprepared') {
+       shift @ARGV;
+       $tolerate_unprepared = 1;
+    }
     die unless @ARGV==1;
     die if $ARGV[0] =~ m/^-/;
     my ($refkey) = @ARGV;
@@ -305,7 +312,8 @@ sub cmd_retrieve {
         @o = ();
         $task_q->execute($refkey);
        my ($task) = $task_q->fetchrow_array();
-       die "no such anointment kind \`$refkey'" unless defined $task;
+       die "no such anointment kind \`$refkey'"
+           unless defined $task or $tolerate_unprepared;
 
        $mostrecent_q->execute($task);
        my $row = $mostrecent_q->fetchrow_hashref();