Commit 001e8825 authored by Christophe Benz's avatar Christophe Benz

Lint schedules

parent a6e3b1b9
Pipeline #165860 passed with stage
in 4 minutes and 8 seconds
......@@ -379,6 +379,20 @@ def json_data_url(base_url: str, provider_slug: str):
class DashboardGenerator:
args: argparse.Namespace
def check_schedule(self, schedule: ProjectPipelineSchedule, provider_slug: str):
problems = []
maintainer = self.fetcher_metadata_by_slug.get(provider_slug, {}).get(
"maintainer"
)
owner = schedule.owner["username"]
if maintainer is not None and owner != maintainer:
problems.append(
f"Schedule owner {owner!r} is different from fetcher maintainer {maintainer!r}"
)
return problems
def fetch(self):
args = self.args
......@@ -492,7 +506,10 @@ class DashboardGenerator:
logger.info("Fetch GitLab CI pipeline schedules of all fetchers...")
return {
provider_slug: project.pipelineschedules.list()
provider_slug: [
(schedule, self.check_schedule(schedule, provider_slug))
for schedule in project.pipelineschedules.list()
]
for provider_slug, project in self.project_by_slug.items()
}
......
......@@ -82,9 +82,9 @@
</a>
</th>
<td>
{% for schedule in fetcher.schedules %}
<a href="{{ schedule_url(args.gitlab_base_url, fetcher.project, schedule) }}" data-toggle="tooltip" data-html="true" data-placement="auto" title="{{ schedule_tooltip(schedule) }}">
<i class="fas {{ 'fa-check text-success' if schedule.active else 'fa-times text-warning' }}"></i>
{% for schedule, problems in fetcher.schedules %}
<a href="{{ schedule_url(args.gitlab_base_url, fetcher.project, schedule) }}" data-toggle="tooltip" data-html="true" data-placement="auto" title="{{ schedule_tooltip(schedule, problems) }}">
<i class="fas {{ 'fa-exclamation text-danger' if problems is not none else 'fa-times text-warning' if not schedule.active else 'fa-check text-success' }}"></i>
</a>
{% else %}
<a href="{{ schedule_url(args.gitlab_base_url, fetcher.project) }}" data-toggle="tooltip" data-placement="auto" title="No schedule defined">
......
......@@ -5,7 +5,11 @@
</local-time>
{% endmacro %}
{% macro schedule_tooltip(schedule) %}
{% macro schedule_tooltip(schedule, problems) %}
{% if problems is not none %}
problems: {{ ", ".join(problems) }}
<br>
{% endif %}
status: {{ "active" if schedule.active else "inactive" }}
<br>
{% if schedule.active %}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment