Skip to content

Commit

Permalink
the keys must be a list, and secret is a bool with default False
Browse files Browse the repository at this point in the history
Signed-off-by: vsoch <vsoch@users.noreply.github.com>
  • Loading branch information
vsoch committed Mar 26, 2021
1 parent 9f354a6 commit 1fa779d
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/spack/spack/binary_distribution.py
Original file line number Diff line number Diff line change
Expand Up @@ -1542,7 +1542,7 @@ def push_keys(*mirrors, **kwargs):
export_target = os.path.join(prefix, filename)

# Export public keys (private is set to False)
spack.util.gpg.export_keys(export_target, False, fingerprint)
spack.util.gpg.export_keys(export_target, [fingerprint])

# If mirror is local, the above export writes directly to the
# mirror (export_target points directly to the mirror).
Expand Down
7 changes: 3 additions & 4 deletions lib/spack/spack/cmd/gpg.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,19 +127,18 @@ def gpg_create(args):
new_sec_keys = set(spack.util.gpg.signing_keys())
new_keys = new_sec_keys.difference(old_sec_keys)

# False/True indicates public/secret key to export
if args.export:
spack.util.gpg.export_keys(args.export, False, *new_keys)
spack.util.gpg.export_keys(args.export, new_keys)
if args.secret:
spack.util.gpg.export_keys(args.secret, True, *new_keys)
spack.util.gpg.export_keys(args.secret, new_keys, secret=True)


def gpg_export(args):
"""export a gpg key, optionally including secret key."""
keys = args.keys
if not keys:
keys = spack.util.gpg.signing_keys()
spack.util.gpg.export_keys(args.location, args.secret, *keys)
spack.util.gpg.export_keys(args.location, keys, args.secret)


def gpg_list(args):
Expand Down
2 changes: 1 addition & 1 deletion lib/spack/spack/util/gpg.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ def public_keys(self, *args):
*args, output=str)
return parse_public_keys_output(output)

def export_keys(self, location, secret, *keys):
def export_keys(self, location, keys, secret=False):
if secret:
self("--export-secret-keys", "--armor", "--output", location, *keys)
else:
Expand Down
2 changes: 1 addition & 1 deletion share/spack/spack-completion.bash
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,7 @@ _spack_gpg_sign() {
_spack_gpg_create() {
if $list_options
then
SPACK_COMPREPLY="-h --help --comment --expires --export"
SPACK_COMPREPLY="-h --help --comment --expires --export --export-secret"
else
SPACK_COMPREPLY=""
fi
Expand Down

0 comments on commit 1fa779d

Please sign in to comment.