Skip to content

Commit 0a581ec

Browse files
committed
yaml + username
1 parent e5584ca commit 0a581ec

File tree

3 files changed

+12
-29
lines changed

3 files changed

+12
-29
lines changed

.build/.build/hook-keyring.cryptfile.py

Lines changed: 0 additions & 21 deletions
This file was deleted.

user_sync/app.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -569,16 +569,18 @@ def retrieve(config_filename, type):
569569

570570
@credentials.command(help="Allows for easy fetch of stored credentials on any platform.", name="get")
571571
@click.option('-i', '--identifier', prompt='Enter identifier',
572-
help="Name of service you want to get a value for. Username will always be 'user_sync'.")
573-
def get_credential(identifier):
572+
help="Name of service you want to get a value for. Username will always be 'user_sync' unless you specify --username..")
573+
@click.option('-u', '--username', type=str,
574+
help="Alternative username setting, for backwards compatibility only. ")
575+
def get_credential(identifier, username):
574576
"""
575577
Gets the specified credentials from keyring
576578
"""
577579
try:
578580
credential_manager = CredentialManager()
579581
click.echo("Using backend: " + credential_manager.keyring_name)
580582
click.echo("Getting '{0}' from keyring".format(identifier))
581-
credential = credential_manager.get(identifier)
583+
credential = credential_manager.get(identifier, username)
582584
if credential is None:
583585
raise AssertionException("Credential not found for identifier '{0}'".format(identifier))
584586
click.echo(identifier + ': ' + credential)
@@ -592,17 +594,19 @@ def get_credential(identifier):
592594
"Username will always be 'user_sync'. ")
593595
@click.option('-v', '--value', prompt="Enter value", hide_input=True,
594596
help="The value to be stored. You will be prompted for this if not specified. "
595-
"Username will always be 'user_sync'.")
596-
def set_credential(identifier, value):
597+
"Username will always be 'user_sync' unless you specify --username.")
598+
@click.option('-u', '--username', type=str,
599+
help="Alternative username setting, for backwards compatibility only. ")
600+
def set_credential(identifier, value, username):
597601
"""
598602
Sets the specified credentials in keyring
599603
"""
600604
credential_manager = CredentialManager()
601605
click.echo("Using backend: " + credential_manager.keyring_name)
602606
click.echo("Setting '{0}' in keyring".format(identifier))
603-
credential_manager.set(identifier, value)
607+
credential_manager.set(identifier, value, username)
604608
click.echo("Validating...")
605-
result = credential_manager.get(identifier)
609+
result = credential_manager.get(identifier, username)
606610
if result != value:
607611
click.echo("Failed to set credential correctly, stored value was " + str(result))
608612
else:

user_sync/credentials.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import keyrings.cryptfile.cryptfile
88
import six
99
from keyring.errors import KeyringError
10-
from ruamel.yaml import YAML
10+
from ruamel.yaml.main import YAML
1111
from ruamel.yaml.scalarstring import PreservedScalarString as pss
1212

1313
from user_sync import encryption

0 commit comments

Comments
 (0)