GeezerVison is showing github.com — feat: option to add a helper to lookup token · python-gitlab/python-gitlab@8ecf559
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: docs/cli-usage.rst +1-1Lines changed: 1 addition & 1 deletion - Display the source diff
- Display the rich diff
| Original file line number | Diff line number | Diff line change |
|---|
@@ -48,7 +48,7 @@ example: |
48 | 48 |
|
49 | 49 | [elsewhere] |
50 | 50 | url = http://else.whe.re:8080 |
51 | | - private_token = CkqsjqcQSFH5FQKDccu4 |
| 51 | + private_token = lookup: pass show path/to/password |
52 | 52 | timeout = 1 |
53 | 53 |
|
54 | 54 | The ``default`` option of the ``[global]`` section defines the GitLab server to |
|
Collapse file
Copy file name to clipboardExpand all lines: gitlab/config.py +11Lines changed: 11 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
|
17 | 17 |
|
18 | 18 | import os |
19 | 19 | import configparser |
| 20 | +import subprocess |
20 | 21 | from typing import List, Optional, Union |
21 | 22 |
|
22 | 23 | from gitlab.const import USER_AGENT |
@@ -150,6 +151,16 @@ def __init__( |
150 | 151 | except Exception: |
151 | 152 | pass |
152 | 153 |
|
| 154 | + for attr in ("job_token", "http_password", "private_token", "oauth_token"): |
| 155 | + value = getattr(self, attr) |
| 156 | + prefix = "lookup:" |
| 157 | + if isinstance(value, str) and value.lower().strip().startswith(prefix): |
| 158 | + helper = value[len(prefix) :].strip() |
| 159 | + value = ( |
| 160 | + subprocess.check_output(helper, shell=True).decode("utf-8").strip() |
| 161 | + ) |
| 162 | + setattr(self, attr, value) |
| 163 | + |
153 | 164 | self.api_version = "4" |
154 | 165 | try: |
155 | 166 | self.api_version = self._config.get("global", "api_version") |
|