Skip to content

Commit

Permalink
Merge pull request #124 from consideRatio/pr/fail-warn-loudly
Browse files Browse the repository at this point in the history
Fail loudly if `GRAFANA_TOKEN` or `jsonnet` isn't available
  • Loading branch information
consideRatio authored Apr 13, 2024
2 parents 0345d7f + 6d4b181 commit 9ca195d
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import json
import os
import re
import shutil
import ssl
import subprocess
from copy import deepcopy
Expand Down Expand Up @@ -203,7 +204,25 @@ def main():

args = parser.parse_args()

grafana_token = os.environ['GRAFANA_TOKEN']
# ensure GRAFANA_TOKEN
grafana_token = os.environ.get("GRAFANA_TOKEN")
if not grafana_token:
raise ValueError(
"The environment variable GRAFANA_TOKEN needs to be set in order to deploying dashboards to a Grafana deployment."
)

# ensure jsonnet (go-jsonnet)
if not shutil.which("jsonnet"):
raise ValueError(
"No jsonnet binary was found on path! "
"Install go-jsonnet via https://github.com/google/go-jsonnet/releases."
)
jsonnet_version = subprocess.check_output(["jsonnet", "--version"], text=True)
if "go" not in jsonnet_version.casefold():
print(
"WARNING: The jsonnet binary on path doesn't seem to be go-jsonnet from https://github.com/google/go-jsonnet/releases! "
"Only that jsonnet implementation is known to work."
)

api = partial(
grafana_request,
Expand Down

0 comments on commit 9ca195d

Please sign in to comment.