Skip to content

Commit

Permalink
Annotate credentials with source backend label
Browse files Browse the repository at this point in the history
With this, we can now communicate to users what credentials are legacy
and behave different from others.

Closes datalad#246
  • Loading branch information
mih committed Feb 18, 2023
1 parent d1793a3 commit 8a5b9e2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions datalad_next/commands/credentials.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,8 @@ def custom_result_renderer(res, **kwargs):
'✓' if res.get('cred_secret') else '✗',
)

if res.pop('from_backend', None) == 'legacy':
res['type'] = 'legacy-credential'
if 'message' not in res:
# give the names of all properties
# but avoid duplicating the type, hide the prefix,
Expand Down
6 changes: 4 additions & 2 deletions datalad_next/credman/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,15 +500,17 @@ def query_(self, **kwargs):
done = set()
known_credentials = set((n, None) for n in self._get_known_credential_names())
from itertools import chain
for name, type_hint in chain(
for name, legacy_type_hint in chain(
_yield_legacy_credential_names(),
known_credentials):
if name in done:
continue
done.add(name)
cred = self.get(name, _prompt=None, _type_hint=type_hint)
cred = self.get(name, _prompt=None, _type_hint=legacy_type_hint)
if not cred:
continue
if legacy_type_hint is not None:
cred['_from_backend'] = 'legacy'
if not kwargs:
yield (name, cred)
else:
Expand Down

0 comments on commit 8a5b9e2

Please sign in to comment.