Skip to content

Commit

Permalink
adding new way to get token
Browse files Browse the repository at this point in the history
  • Loading branch information
paigerube14 authored and chaitanyaenr committed Jul 7, 2022
1 parent c27af88 commit 088dcf2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cerberus/prometheus/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ def initialize_prom_client(distribution, prometheus_url, prometheus_bearer_token
)
prometheus_url = "https://" + url
if distribution == "openshift" and not prometheus_bearer_token:
prometheus_bearer_token = runcommand.invoke("oc -n openshift-monitoring " "sa get-token prometheus-k8s")
prometheus_bearer_token = runcommand.invoke(
"oc -n openshift-monitoring sa get-token prometheus-k8s "
"|| oc create token -n openshift-monitoring prometheus-k8s"
)
if prometheus_url and prometheus_bearer_token:
bearer = "Bearer " + prometheus_bearer_token
headers = {"Authorization": bearer}
Expand Down

0 comments on commit 088dcf2

Please sign in to comment.