ci: update token retrieval method for gantt charts
When the gantt chart service was first implemented, the read_token() function would attempt to read from the default token file if the token argument was missing. Now it's necessary to call a separate function to look in the default token file, so if the token argument is not provided, expressly call get_token_from_default_dir(). Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32637>
This commit is contained in:

committed by
Deb_1543

parent
0366eebe3e
commit
6331de400b
@@ -16,7 +16,8 @@ import plotly.graph_objs as go
|
||||
from gitlab import Gitlab, base
|
||||
from gitlab.v4.objects import ProjectPipeline
|
||||
from gitlab_common import (GITLAB_URL, get_gitlab_pipeline_from_url,
|
||||
pretty_duration, read_token)
|
||||
get_token_from_default_dir, pretty_duration,
|
||||
read_token)
|
||||
|
||||
|
||||
def calculate_queued_at(job) -> datetime:
|
||||
@@ -157,6 +158,9 @@ def main(
|
||||
output: str | None,
|
||||
ci_timeout: float = 60,
|
||||
):
|
||||
if token is None:
|
||||
token = get_token_from_default_dir()
|
||||
|
||||
token = read_token(token)
|
||||
gl = Gitlab(url=GITLAB_URL, private_token=token, retry_transient_errors=True)
|
||||
|
||||
|
@@ -21,7 +21,8 @@ from ci_gantt_chart import generate_gantt_chart
|
||||
from gitlab import Gitlab
|
||||
from gitlab.base import RESTObject
|
||||
from gitlab.v4.objects import Project, ProjectPipeline
|
||||
from gitlab_common import GITLAB_URL, get_gitlab_pipeline_from_url, read_token
|
||||
from gitlab_common import (GITLAB_URL, get_gitlab_pipeline_from_url,
|
||||
get_token_from_default_dir, read_token)
|
||||
|
||||
|
||||
class MockGanttExit(Exception):
|
||||
@@ -115,6 +116,9 @@ def main(
|
||||
ci_timeout: float = 60,
|
||||
):
|
||||
log.basicConfig(level=log.INFO)
|
||||
if token is None:
|
||||
token = get_token_from_default_dir()
|
||||
|
||||
token = read_token(token)
|
||||
gl = Gitlab(url=GITLAB_URL, private_token=token, retry_transient_errors=True)
|
||||
|
||||
|
Reference in New Issue
Block a user