mirror of https://github.com/borgbackup/borg.git
Merge pull request #3104 from enkore/issue/3103
init: fix wrong encryption choices in command line parser
This commit is contained in:
commit
ebd811b352
|
@ -40,7 +40,7 @@ from .archive import FilesystemObjectProcessors, MetadataCollector, ChunksProces
|
||||||
from .cache import Cache, assert_secure
|
from .cache import Cache, assert_secure
|
||||||
from .constants import * # NOQA
|
from .constants import * # NOQA
|
||||||
from .compress import CompressionSpec
|
from .compress import CompressionSpec
|
||||||
from .crypto.key import key_creator, tam_required_file, tam_required, RepoKey, PassphraseKey
|
from .crypto.key import key_creator, key_argument_names, tam_required_file, tam_required, RepoKey, PassphraseKey
|
||||||
from .crypto.keymanager import KeyManager
|
from .crypto.keymanager import KeyManager
|
||||||
from .helpers import EXIT_SUCCESS, EXIT_WARNING, EXIT_ERROR
|
from .helpers import EXIT_SUCCESS, EXIT_WARNING, EXIT_ERROR
|
||||||
from .helpers import Error, NoManifestError, set_ec
|
from .helpers import Error, NoManifestError, set_ec
|
||||||
|
@ -2383,7 +2383,7 @@ class Archiver:
|
||||||
type=location_validator(archive=False),
|
type=location_validator(archive=False),
|
||||||
help='repository to create')
|
help='repository to create')
|
||||||
subparser.add_argument('-e', '--encryption', metavar='MODE', dest='encryption', required=True,
|
subparser.add_argument('-e', '--encryption', metavar='MODE', dest='encryption', required=True,
|
||||||
choices=('none', 'keyfile', 'repokey', 'keyfile-blake2', 'repokey-blake2', 'authenticated'),
|
choices=key_argument_names(),
|
||||||
help='select encryption key mode **(required)**')
|
help='select encryption key mode **(required)**')
|
||||||
subparser.add_argument('--append-only', dest='append_only', action='store_true',
|
subparser.add_argument('--append-only', dest='append_only', action='store_true',
|
||||||
help='create an append-only mode repository')
|
help='create an append-only mode repository')
|
||||||
|
|
|
@ -103,11 +103,16 @@ class KeyBlobStorage:
|
||||||
def key_creator(repository, args):
|
def key_creator(repository, args):
|
||||||
for key in AVAILABLE_KEY_TYPES:
|
for key in AVAILABLE_KEY_TYPES:
|
||||||
if key.ARG_NAME == args.encryption:
|
if key.ARG_NAME == args.encryption:
|
||||||
|
assert key.ARG_NAME is not None
|
||||||
return key.create(repository, args)
|
return key.create(repository, args)
|
||||||
else:
|
else:
|
||||||
raise ValueError('Invalid encryption mode "%s"' % args.encryption)
|
raise ValueError('Invalid encryption mode "%s"' % args.encryption)
|
||||||
|
|
||||||
|
|
||||||
|
def key_argument_names():
|
||||||
|
return [key.ARG_NAME for key in AVAILABLE_KEY_TYPES if key.ARG_NAME]
|
||||||
|
|
||||||
|
|
||||||
def identify_key(manifest_data):
|
def identify_key(manifest_data):
|
||||||
key_type = manifest_data[0]
|
key_type = manifest_data[0]
|
||||||
if key_type == PassphraseKey.TYPE:
|
if key_type == PassphraseKey.TYPE:
|
||||||
|
|
Loading…
Reference in New Issue