Skip to content

Commit

Permalink
Change to class method
Browse files Browse the repository at this point in the history
Fix test
  • Loading branch information
arikalon1 committed Aug 16, 2021
1 parent b955014 commit 0f8e1a5
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
10 changes: 5 additions & 5 deletions src/robusta/integrations/prometheus/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@

class PrometheusDiscovery:
prometheus_url = None
@staticmethod
def find_prometheus_url():
@classmethod
def find_prometheus_url(cls):
"""
Try to autodiscover the url of an in-cluster grafana service
"""
if PrometheusDiscovery.prometheus_url:
return PrometheusDiscovery.prometheus_url
if cls.prometheus_url:
return cls.prometheus_url
prometheus_selectors = ["app=kube-prometheus-stack-prometheus", "app.kubernetes.io/name=prometheus"]
for label_selector in prometheus_selectors:
service_url = find_service_url(label_selector)
if service_url:
PrometheusDiscovery.prometheus_url = service_url
cls.prometheus_url = service_url
return service_url
logging.error("Prometheus url could not be found. Add 'prometheus_url' under global_config")
return None
1 change: 0 additions & 1 deletion tests/utils/robusta_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ def cli_examples(self, playbooks_url: str, slack_channel: str, slack_api_key: st
"--robusta-ui-token",
"test-token",
"--skip-robusta-sink",
"--skip-new",
],
)
assert b"examples downloaded into the playbooks/ directory" in logs
Expand Down

0 comments on commit 0f8e1a5

Please sign in to comment.