summaryrefslogtreecommitdiff
path: root/gitlab/config.py
diff options
context:
space:
mode:
authorKay-Uwe (Kiwi) Lorenz <kiwi@moduleworks.com>2021-03-06 12:09:20 +0100
committerKay-Uwe (Kiwi) Lorenz <kiwi@moduleworks.com>2021-03-06 12:09:20 +0100
commit8ecf55926f8e345960560e5c5dd6716199cfb0ec (patch)
tree65e80b7d24265ed92601f9fe180e1453bbace6da /gitlab/config.py
parentaa132149558e797332897ec8543a9ac9fb0da09b (diff)
downloadgitlab-8ecf55926f8e345960560e5c5dd6716199cfb0ec.tar.gz
feat: option to add a helper to lookup token
Diffstat (limited to 'gitlab/config.py')
-rw-r--r--gitlab/config.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/gitlab/config.py b/gitlab/config.py
index 710a354..a6f25ac 100644
--- a/gitlab/config.py
+++ b/gitlab/config.py
@@ -17,6 +17,7 @@
import os
import configparser
+import subprocess
from typing import List, Optional, Union
from gitlab.const import USER_AGENT
@@ -150,6 +151,16 @@ class GitlabConfigParser(object):
except Exception:
pass
+ for attr in ("job_token", "http_password", "private_token", "oauth_token"):
+ value = getattr(self, attr)
+ prefix = "lookup:"
+ if isinstance(value, str) and value.lower().strip().startswith(prefix):
+ helper = value[len(prefix) :].strip()
+ value = (
+ subprocess.check_output(helper, shell=True).decode("utf-8").strip()
+ )
+ setattr(self, attr, value)
+
self.api_version = "4"
try:
self.api_version = self._config.get("global", "api_version")