diff --git a/backend/areas/__init__.py b/backend/areas/__init__.py index f14dde52497f710c9906eb95db2b0ce4bc4a2978..363d4e35a557dbc18ce191fd4e61a185a8b10720 100644 --- a/backend/areas/__init__.py +++ b/backend/areas/__init__.py @@ -62,14 +62,27 @@ def api_info(): if 'version' in data: 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 # tells us when flux last updated the cluster based on changes in the # stackspin git repo. stackspin_repo = k8s.get_gitrepo('stackspin') 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)