summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/cli-usage.rst2
-rw-r--r--gitlab/config.py11
2 files changed, 12 insertions, 1 deletions
diff --git a/docs/cli-usage.rst b/docs/cli-usage.rst
index 1c24824..7b14257 100644
--- a/docs/cli-usage.rst
+++ b/docs/cli-usage.rst
@@ -48,7 +48,7 @@ example:
[elsewhere]
url = http://else.whe.re:8080
- private_token = CkqsjqcQSFH5FQKDccu4
+ private_token = lookup: pass show path/to/password
timeout = 1
The ``default`` option of the ``[global]`` section defines the GitLab server to
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")