Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RF(BF): credential defined in environment vars takes precedence #2960

Merged
merged 2 commits into from
Oct 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions datalad/support/external_versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ class ExternalVersions(object):
'gitdb',
'humanize',
'iso8601',
'keyring',
'keyrings.alt',
'msgpack',
'mutagen',
'patool',
Expand Down
10 changes: 5 additions & 5 deletions datalad/support/keyring_.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,11 @@ def _get_service_name(cls, name):

# proxy few methods of interest explicitly, to be rebound to the module's
def get(self, name, field):
# consult environment, might be provided there
val = self._keyring.get_password(self._get_service_name(name), field)
if val is None:
val = os.environ.get(('DATALAD_%s_%s' % (name, field)).replace('-', '_'), None)
return val
# consult environment, might be provided there and should take precedence
env_var = ('DATALAD_%s_%s' % (name, field)).replace('-', '_')
if env_var in os.environ:
return os.environ[env_var]
return self._keyring.get_password(self._get_service_name(name), field)

def set(self, name, field, value):
return self._keyring.set_password(self._get_service_name(name), field, value)
Expand Down