Expose Python commands to shell signer mode param 99/14799/1 v0.21.0
authorThanh Ha <thanh.ha@linuxfoundation.org>
Wed, 6 Mar 2019 16:56:13 +0000 (11:56 -0500)
committerThanh Ha <thanh.ha@linuxfoundation.org>
Wed, 6 Mar 2019 16:56:54 +0000 (11:56 -0500)
Change-Id: I3202f9b30d24ace82d583cf6b92c12fef0c3c85c
Signed-off-by: Thanh Ha <thanh.ha@linuxfoundation.org>
lftools/cli/sign.py
shell/sign

index 256d13c..c399750 100644 (file)
@@ -28,10 +28,13 @@ def sign(ctx):
 
 @click.command(name='dir')
 @click.argument('directory')
+@click.option(
+    '-m', '--mode', type=str, default='parallel',
+    help='Signing mode serial|parallel')
 @click.pass_context
-def directory(ctx, directory):
+def directory(ctx, directory, mode):
     """GPG signs all of the files in a directory."""
-    status = subprocess.call(['sign', 'dir', directory])
+    status = subprocess.call(['sign', 'dir', directory, mode])
     sys.exit(status)
 
 
@@ -41,24 +44,30 @@ def directory(ctx, directory):
     '-d', '--sign-dir', type=str,
     default=None,
     help='Local directory to clone repository. (default /tmp/gpg-signatures.*)')
+@click.option(
+    '-m', '--mode', type=str, default='parallel',
+    help='Signing mode serial|parallel')
 @click.option(
     '-w', '--sign-with', type=str, default='gpg',
     help='Sign artifacts with GPG or Sigul. (default gpg)')
 @click.pass_context
-def nexus(ctx, sign_dir, sign_with, nexus_repo_url):
+def nexus(ctx, sign_dir, sign_with, nexus_repo_url, mode):
     """Fetch and GPG or Sigul sign a Nexus repo."""
     if not sign_dir:
         sign_dir = tempfile.mkdtemp(prefix='gpg-signatures.')
-    status = subprocess.call(['sign', 'nexus', '-d', sign_dir, '-w', sign_with, nexus_repo_url])
+    status = subprocess.call(['sign', 'nexus', '-d', sign_dir, '-m', mode, '-w', sign_with, nexus_repo_url])
     sys.exit(status)
 
 
 @click.command(name='sigul')
 @click.argument('directory')
+@click.option(
+    '-m', '--mode', type=str, default='parallel',
+    help='Signing mode serial|parallel')
 @click.pass_context
-def sigul(ctx, directory):
+def sigul(ctx, directory, mode):
     """Sigul signs all of the files in a directory."""
-    status = subprocess.call(['sign', 'sigul', directory])
+    status = subprocess.call(['sign', 'sigul', directory, mode])
     sys.exit(status)
 
 
@@ -70,6 +79,9 @@ def sigul(ctx, directory):
     '-d', '--sign-dir', type=str,
     default=None,
     help='Local directory to clone repository. (default /tmp/gpg-signatures.*)')
+@click.option(
+    '-m', '--mode', type=str, default='parallel',
+    help='Signing mode serial|parallel')
 @click.option(
     '-r', '--root-domain', type=str, default='org',
     help='Root download path of staging repo. (default org)')
@@ -77,7 +89,7 @@ def sigul(ctx, directory):
     '-w', '--sign-with', type=str, default='gpg',
     help='Sign artifacts with GPG or Sigul. (default gpg)')
 @click.pass_context
-def deploy_nexus(ctx, nexus_url, nexus_repo, staging_profile_id, sign_dir, sign_with, root_domain):
+def deploy_nexus(ctx, nexus_url, nexus_repo, staging_profile_id, sign_dir, sign_with, root_domain, mode):
     """Sign artifacts from a Nexus repo then upload to a staging repo.
 
     This is a porcelain command that ties the lftools sign and deploy tools
@@ -96,7 +108,7 @@ def deploy_nexus(ctx, nexus_url, nexus_repo, staging_profile_id, sign_dir, sign_
     if not sign_dir:
         sign_dir = tempfile.mkdtemp(prefix='gpg-signatures.')
 
-    status = subprocess.call(['sign', 'nexus', '-d', sign_dir, '-w', sign_with, nexus_repo_url])
+    status = subprocess.call(['sign', 'nexus', '-d', sign_dir, '-m', mode, '-w', sign_with, nexus_repo_url])
     if status:
         sys.exit(status)
 
index 4ef50a0..23e22ec 100755 (executable)
@@ -62,7 +62,9 @@ sign_dir() {
     #
     # Parameters:
     #
+    #     <signer>: gpg|sigul
     #     <directory>: The directory to find and sign artifacts.
+    #     <mode>: serial|parallel
     local signer="$1"
     local dir="$2"
 
@@ -168,7 +170,7 @@ sign_nexus() {
     # /tmp/gpg-signatures.XXXXXXXXXX unless the -d parameter is passed to
     # override.
     local signer='gpg'
-    while getopts d:w:h o; do
+    while getopts d:m:w:h o; do
       case "$o" in
         h)
             sign_nexus_usage
@@ -180,6 +182,10 @@ sign_nexus() {
             mkdir -p "$sign_dir"
             ;;
 
+        m)
+            local sign_mode="$OPTARG"
+            ;;
+
         w)
             if [[ "$OPTARG" =~ ^(gpg|sigul)$ ]]
             then
@@ -244,9 +250,9 @@ sign_nexus() {
     echo "Signing artifacts..."
     if [ "$signer" == "gpg" ]
     then
-        sign_dir 'gpg' "$sign_dir"
+        sign_dir 'gpg' "$sign_dir" "$sign_mode"
     else
-        sign_dir 'sigul' "$sign_dir"
+        sign_dir 'sigul' "$sign_dir" "$sign_mode"
     fi
 
     echo "Removing non-signature files..."