Skip to content

Commit

Permalink
fix(openshift): Support etcd Dashboard
Browse files Browse the repository at this point in the history
which also fixes test coverage 😇
  • Loading branch information
reitzig committed Aug 24, 2023
1 parent e674bff commit 16eba2d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion nice-dev-refs/_manifest.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: "nice-dev-refs"
title: "Nice Developer References"
description: Takes URLs from the clipboard and pastes them as nice links
version: 0.11.0
version: 0.11.1
author: Raphael Reitzig
9 changes: 5 additions & 4 deletions scripts/label_for_url.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,15 @@ def determine_label(input_url: str) -> str:
return f"{namespace}/{resource_name}"
if options := m.group("dashboard_options"): # noqa: RET503 -- false positive
options = dict([option.split("=") for option in options.split("&")])
cluster = f"{options['cluster']}/" if options.get("cluster") else ""
if namespace := options.get("namespace"):
cluster = f"{options['cluster']}/" if options.get("cluster") else ""
resource_type = f"{options['type'].title()}s " if options.get("type") else ""
return f"{cluster}{namespace} > {resource_type}Dashboard"
else:
host = m.group("host")
cluster = f"{options['cluster']}" if options.get("cluster") else ""
host = m.group("host") if not options.get("cluster") else ""
dashboard = prettify(remove_prefix(m.group("dashboard"), "grafana-dashboard-"))
return f"{host} > {dashboard}"
return f"{host}{cluster} > {dashboard}"
elif m := re.search(r"\w+://(www\d*\.)?(?P<path>[^?]+)", input_url):
return m.group("path").strip(" /")
else:
Expand All @@ -244,4 +245,4 @@ def determine_label(input_url: str) -> str:


if __name__ == "__main__":
print(determine_label(sys.argv[1]))
print(determine_label(sys.argv[1])) # pragma: no cover
13 changes: 13 additions & 0 deletions test/test_openshift.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,16 @@ def test_should_label_metrics_dashboard_api() -> None:

# Then:
assert_that(label).is_equal_to("console-openshift.some.org > Api Performance")


def test_should_label_metrics_dashboard_etcd() -> None:
# Given:
url = (
"https://console-openshift.some.org/monitoring/dashboards/" "etcd-dashboard" "?cluster=etcd"
)

# When:
label = determine_label(url)

# Then:
assert_that(label).is_equal_to("etcd > Etcd Dashboard")

0 comments on commit 16eba2d

Please sign in to comment.