Merge "Encrypt: never strip with --infile"
This commit is contained in:
commit
110a460dd2
@ -497,7 +497,8 @@ class ZuulClient():
|
|||||||
required=False, default=None)
|
required=False, default=None)
|
||||||
cmd_encrypt.add_argument('--no-strip', action='store_true',
|
cmd_encrypt.add_argument('--no-strip', action='store_true',
|
||||||
help='Do not strip whitespace from beginning '
|
help='Do not strip whitespace from beginning '
|
||||||
'or end of input.',
|
'or end of input. Ignored when '
|
||||||
|
'--infile is used.',
|
||||||
default=False)
|
default=False)
|
||||||
cmd_encrypt.add_argument('--secret-name',
|
cmd_encrypt.add_argument('--secret-name',
|
||||||
default=None,
|
default=None,
|
||||||
@ -530,7 +531,9 @@ class ZuulClient():
|
|||||||
raise ArgumentException(
|
raise ArgumentException(
|
||||||
'Either provide a public key or a project to continue'
|
'Either provide a public key or a project to continue'
|
||||||
)
|
)
|
||||||
|
strip = not self.args.no_strip
|
||||||
if self.args.infile:
|
if self.args.infile:
|
||||||
|
strip = False
|
||||||
try:
|
try:
|
||||||
with open(self.args.infile) as f:
|
with open(self.args.infile) as f:
|
||||||
plaintext = f.read()
|
plaintext = f.read()
|
||||||
@ -541,7 +544,7 @@ class ZuulClient():
|
|||||||
'Insufficient rights to open %s' % self.args.infile)
|
'Insufficient rights to open %s' % self.args.infile)
|
||||||
else:
|
else:
|
||||||
plaintext = sys.stdin.read()
|
plaintext = sys.stdin.read()
|
||||||
if not self.args.no_strip:
|
if strip:
|
||||||
plaintext = plaintext.strip()
|
plaintext = plaintext.strip()
|
||||||
pubkey_file = tempfile.NamedTemporaryFile(delete=False)
|
pubkey_file = tempfile.NamedTemporaryFile(delete=False)
|
||||||
self.log.debug('Creating temporary key file %s' % pubkey_file.name)
|
self.log.debug('Creating temporary key file %s' % pubkey_file.name)
|
||||||
|
Loading…
Reference in New Issue
Block a user