indico: use systemd-creds
Signed-off-by: Jeltz <jeltz@federez.net>
This commit is contained in:
parent
6c627daa51
commit
5d32735063
4 changed files with 27 additions and 21 deletions
|
@ -8,8 +8,10 @@ from json import load
|
|||
PROLOGUE = (
|
||||
"import functools as _functools\n"
|
||||
"@_functools.cache\n"
|
||||
"def _read_file(name):\n"
|
||||
" with open(name) as fd:\n"
|
||||
"def _read_cred(name):\n"
|
||||
" import os\n"
|
||||
" dir = os.environ['CREDENTIALS_DIRECTORY']\n"
|
||||
" with open(os.path.join(dir, name)) as fd:\n"
|
||||
" return fd.read()\n"
|
||||
)
|
||||
|
||||
|
@ -27,8 +29,8 @@ def make_value(value):
|
|||
for k, v in value["_value"].items()
|
||||
]
|
||||
return f"{{{','.join(items)}}}"
|
||||
case "read-file":
|
||||
return f"_read_file({repr(value['_value'])})"
|
||||
case "read-cred":
|
||||
return f"_read_cred({repr(value['_value'])})"
|
||||
case _:
|
||||
raise ValueError("Unknown data type")
|
||||
|
||||
|
|
|
@ -32,8 +32,8 @@ rec {
|
|||
|
||||
_mkVars = lib.mapAttrs (_: _mkValue);
|
||||
|
||||
mkReadFile = path:
|
||||
_mkPy "read-file" (if lib.isStringLike path then
|
||||
mkReadCred = path:
|
||||
_mkPy "read-cred" (if lib.isStringLike path then
|
||||
path
|
||||
else
|
||||
abort "invalid path type");
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue