Skip to content

Commit

Permalink
Reduce inter-template redundancy (#739)
Browse files Browse the repository at this point in the history
* Reduce inter-template redundancy
* fix wrong br tag
* Add some styling, as well as AOV

---------

Signed-off-by: Matthias Büchse <[email protected]>
  • Loading branch information
mbuechse authored Sep 6, 2024
1 parent c255eb8 commit 0b759af
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 103 deletions.
6 changes: 4 additions & 2 deletions compliance-monitor/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ class ViewType(Enum):

VIEW_DETAIL = {
ViewType.markdown: 'details.md',
ViewType.fragment: 'details.html',
ViewType.fragment: 'details.md',
ViewType.page: 'overview.html',
}
VIEW_TABLE = {
ViewType.markdown: 'overview.md',
ViewType.fragment: 'overview_fragment.html',
ViewType.fragment: 'overview.md',
ViewType.page: 'overview.html',
}
REQUIRED_TEMPLATES = tuple(set(fn for view in (VIEW_DETAIL, VIEW_TABLE) for fn in view.values()))
Expand Down Expand Up @@ -548,6 +548,8 @@ def render_view(view, view_type, results, base_url='/', title=None):
def detail_url(subject, scope): return f"{base_url}page/detail/{subject}/{scope}" # noqa: E306,E704
def report_url(report): return f"{base_url}reports/{report}" # noqa: E306,E704
fragment = templates_map[stage1].render(results=results, detail_url=detail_url, report_url=report_url)
if view_type != ViewType.markdown and stage1.endswith('.md'):
fragment = markdown(fragment, extensions=['extra'])
if stage1 != stage2:
fragment = templates_map[stage2].render(fragment=fragment, title=title)
return Response(content=fragment, media_type=media_type)
Expand Down
34 changes: 0 additions & 34 deletions compliance-monitor/templates/details.html.j2

This file was deleted.

23 changes: 13 additions & 10 deletions compliance-monitor/templates/details.md.j2
Original file line number Diff line number Diff line change
@@ -1,29 +1,32 @@
{% for subject, subject_result in results.items() -%}
# {{ subject }}

{% for scopeuuid, scope_result in subject_result.items() -%}

{% if not scope_result.relevant -%}
## {{ scope_result.name }}

No recent test results available.

{% endif -%}
{% for version in scope_result.relevant -%}
{% set version_result = scope_result.versions[version] -%}
{%- set version_result = scope_result.versions[version] -%}
## {{ scope_result.name }} {{ version }} ({{ version_result.validity }}): {{ version_result.result | verdict }}

{% for target, target_result in version_result.targets.items() -%}
### Target {{ target }}: {{ target_result.result | verdict }}

|---|---|---|
| testcase id | result | description |
|---|---|---|
{% for testcase_id in target_result.testcases -%}
{% set testcase = version_result.testcases[testcase_id] -%}
{% set result = version_result.results[testcase_id].result if testcase_id in version_result.results else 0 -%}
| {{ testcase.id }} | {{ result | verdict }} | {{ testcase.description | trim }} |
{% endfor -%}
|---|---|---|

{% set res = version_result.results[testcase_id] if testcase_id in version_result.results else dict(result=0) -%}
| {% if res.result != 1 %}⚠️ {% endif %}{{ testcase.id }} |
{#- #} {% if res.report -%}
[{{ res.result | verdict_check }}]({{ report_url(res.report) }})
{%- else -%}
{{ res.result | verdict_check }}
{%- endif -%}
{% if res.report %} { title="{{ res.report }} ({{ res.checked_at }})" }{% endif %} {# -#}
| {{ testcase.description | trim }} |
{% endfor %}
{% endfor -%}
{% endfor -%}
{% endfor -%}
Expand Down
6 changes: 6 additions & 0 deletions compliance-monitor/templates/overview.html.j2
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
<!DOCTYPE html>
<html lang="en" dir="ltr">
<style type="text/css">
table {border-collapse:collapse;}
table td, table th {vertical-align:top;padding:0.75rem;border:1px solid #dadde1;}
table th {font-weight:700;background-color:#00000008;}
html {text-rendering:optimizelegibility;font-family:system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,Cantarell,Noto Sans,sans-serif,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol";}
</style>
<head>
<meta charset="utf-8">
<title>{{ title or 'SCS compliance overview' }}</title>
Expand Down
25 changes: 14 additions & 11 deletions compliance-monitor/templates/overview.md.j2
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,25 @@ for the time being to have the highest degree of control
-#}
{% set iaas = '50393e6f-2ae1-4c5c-a62c-3b75f2abef3f' -%}
| Name | Description | Operator | SCS-compatible IaaS | HealthMon |
| ----- | ------------ | --------- | :------------------: | :--------: |
|-------|--------------|-----------|----------------------|:----------:|
| [gx-scs](https://github.com/SovereignCloudStack/docs/blob/main/community/cloud-resources/plusserver-gx-scs.md) | Dev environment provided for SCS & GAIA-X context | plusserver GmbH |
{#- #} [{{ results | passed('gx-scs', iaas) or '–' }}]({{ detail_url('gx-scs', iaas) }}) {# -#}
| [HM](https://health.gx-scs.sovereignit.cloud:3000/) |
| [aov.cloud](https://www.aov.de/) | Community cloud for customers | aov IT.Services GmbH |
{#- #} [{{ results | passed('aov', iaas) or '–' }}]({{ detail_url('aov', iaas) }}) {# -#}
| [HM](https://health.aov.cloud/) |
| [CNDS](https://cnds.io/) | Public cloud for customers | artcodix GmbH |
{#- #} [{{ results | passed('artcodix', iaas) or '–' }}]({{ detail_url('artcodix', iaas) }}) {# -#}
| [HM](https://ohm.muc.cloud.cnds.io/) |
| [pluscloud open](https://www.plusserver.com/en/products/pluscloud-open)<br />- prod1</br>- prod2<br />- prod3<br />- prod4 | Public cloud for customers (4 regions) | plusserver GmbH | &nbsp;<br /> | &nbsp;<br />
{#- #}[{{ results | passed('pco-prod1', iaas) or '–' }}]({{ detail_url('pco-prod1', iaas) }}){# -#}
| [pluscloud open](https://www.plusserver.com/en/products/pluscloud-open)<br />(4 regions) | Public cloud for customers | plusserver GmbH | {# #}
{#- #}prod1: [{{ results | passed('pco-prod1', iaas) or '–' }}]({{ detail_url('pco-prod1', iaas) }}){# -#}
<br />
{#- #}[{{ results | passed('pco-prod2', iaas) or '–' }}]({{ detail_url('pco-prod2', iaas) }}){# -#}
{#- #}prod2: [{{ results | passed('pco-prod2', iaas) or '–' }}]({{ detail_url('pco-prod2', iaas) }}){# -#}
<br />
{#- #}[{{ results | passed('pco-prod3', iaas) or '–' }}]({{ detail_url('pco-prod3', iaas) }}){# -#}
{#- #}prod3: [{{ results | passed('pco-prod3', iaas) or '–' }}]({{ detail_url('pco-prod3', iaas) }}){# -#}
<br />
{#- #}[{{ results | passed('pco-prod4', iaas) or '–' }}]({{ detail_url('pco-prod4', iaas) }}) {# -#}
| &nbsp;<br /> [HM1](https://health.prod1.plusserver.sovereignit.cloud:3000/d/9ltTEmlnk/openstack-health-monitor2?orgId=1&var-mycloud=plus-pco)<br />[HM2](https://health.prod1.plusserver.sovereignit.cloud:3000/d/9ltTEmlnk/openstack-health-monitor2?orgId=1&var-mycloud=plus-prod2)<br />[HM3](https://health.prod1.plusserver.sovereignit.cloud:3000/d/9ltTEmlnk/openstack-health-monitor2?orgId=1&var-mycloud=plus-prod3)<br />[HM4](https://health.prod1.plusserver.sovereignit.cloud:3000/d/9ltTEmlnk/openstack-health-monitor2?orgId=1&var-mycloud=plus-prod4) |
{#- #}prod4: [{{ results | passed('pco-prod4', iaas) or '–' }}]({{ detail_url('pco-prod4', iaas) }}) {# -#}
| [HM1](https://health.prod1.plusserver.sovereignit.cloud:3000/d/9ltTEmlnk/openstack-health-monitor2?orgId=1&var-mycloud=plus-pco)<br />[HM2](https://health.prod1.plusserver.sovereignit.cloud:3000/d/9ltTEmlnk/openstack-health-monitor2?orgId=1&var-mycloud=plus-prod2)<br />[HM3](https://health.prod1.plusserver.sovereignit.cloud:3000/d/9ltTEmlnk/openstack-health-monitor2?orgId=1&var-mycloud=plus-prod3)<br />[HM4](https://health.prod1.plusserver.sovereignit.cloud:3000/d/9ltTEmlnk/openstack-health-monitor2?orgId=1&var-mycloud=plus-prod4) |
| PoC KDO | Cloud PoC for FITKO | KDO Service GmbH / OSISM GmbH |
{#- #} [{{ results | passed('poc-kdo', iaas) or '–' }}]({{ detail_url('poc-kdo', iaas) }}) {# -#}
| (soon) |
Expand All @@ -29,11 +32,11 @@ for the time being to have the highest degree of control
| [REGIO.cloud](https://regio.digital) | Public cloud for customers | OSISM GmbH |
{#- #} [{{ results | passed('regio-a', iaas) or '–' }}]({{ detail_url('regio-a', iaas) }}) {# -#}
| [HM](https://apimon.services.regio.digital/public-dashboards/17cf094a47404398a5b8e35a4a3968d4?orgId=1&refresh=5m) |
| [syseleven](https://www.syseleven.de/en/products-services/openstack-cloud/)<br />- dus2<br />- ham1 | Public OpenStack Cloud (2 SCS regions) | SysEleven GmbH | &nbsp;<br />
{#- #}[{{ results | passed('syseleven-dus2', iaas) or '–' }}]({{ detail_url('syseleven-dus2', iaas) }}){# -#}
| [syseleven](https://www.syseleven.de/en/products-services/openstack-cloud/)<br />(2 SCS regions) | Public OpenStack Cloud | SysEleven GmbH | {# #}
{#- #}dus2: [{{ results | passed('syseleven-dus2', iaas) or '–' }}]({{ detail_url('syseleven-dus2', iaas) }}){# -#}
<br />
{#- #}[{{ results | passed('syseleven-ham1', iaas) or '–' }}]({{ detail_url('syseleven-ham1', iaas) }}) {# -#}
| &nbsp;<br />(soon)<br />(soon) |
{#- #}ham1: [{{ results | passed('syseleven-ham1', iaas) or '–' }}]({{ detail_url('syseleven-ham1', iaas) }}) {# -#}
| (soon)<br />(soon) |
| [Wavestack](https://www.noris.de/wavestack-cloud/) | Public cloud for customers | noris network AG/Wavecon GmbH |
{#- #} [{{ results | passed('wavestack', iaas) or '–' }}]({{ detail_url('wavestack', iaas) }}) {# -#}
| [HM](https://health.wavestack1.sovereignit.cloud:3000/) |
46 changes: 0 additions & 46 deletions compliance-monitor/templates/overview_fragment.html.j2

This file was deleted.

0 comments on commit 0b759af

Please sign in to comment.