Skip to content
Snippets Groups Projects
Commit 545457e9 authored by Arie Peterson's avatar Arie Peterson
Browse files

Include flux git ref in info endpoint

parent 05280804
No related branches found
No related tags found
No related merge requests found
...@@ -62,14 +62,27 @@ def api_info(): ...@@ -62,14 +62,27 @@ def api_info():
if 'version' in data: if 'version' in data:
results['appVersions'][app] = data['version'] results['appVersions'][app] = data['version']
# Get latest released version from gitlab.
git_release = requests.get("https://open.greenhost.net/stackspin/stackspin/-/raw/main/VERSION").text.rstrip()
results['lastRelease'] = git_release
# Get last update time of stackspin GitRepo object on the cluster; that # Get last update time of stackspin GitRepo object on the cluster; that
# tells us when flux last updated the cluster based on changes in the # tells us when flux last updated the cluster based on changes in the
# stackspin git repo. # stackspin git repo.
stackspin_repo = k8s.get_gitrepo('stackspin') stackspin_repo = k8s.get_gitrepo('stackspin')
results['lastUpdated'] = stackspin_repo['status']['artifact']['lastUpdateTime'] results['lastUpdated'] = stackspin_repo['status']['artifact']['lastUpdateTime']
# This is the branch (or other git ref, like tag or commit) that this
# cluster follows.
flux_ref = stackspin_repo['spec']['ref']
results['followingGit'] = {}
results['followingGit']['object'] = stackspin_repo['spec']['ref']
# The `flux_ref` is a structured object, though as far as we've seen always
# a dict with a single entry. (The key can be `branch` or `tag` or
# `commit`.) We need to reduce this to a single string git ref as well.
ref = next(iter(flux_ref.values()))
results['followingGit']['string'] = ref
# Get latest released version from gitlab. Whether it's considered
# "released" depends on which branch we're following, but usually that's
# the `vX` "production" branch.
git_release = requests.get(f"https://open.greenhost.net/stackspin/stackspin/-/raw/{ref}/VERSION").text.rstrip()
results['lastRelease'] = git_release
return jsonify(results) return jsonify(results)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment