fix(hub): resolve 'vdev' version badge and align it under the Hub title
- The Hub header badge could render 'vdev' because the runtime /etc/nixos/VERSION lookup fell back to the literal string 'dev' when the file was missing (e.g. dev/test environments, or before the Nix-generated config carried a version at all). - modules/core/sovran-hub.nix now reads the repo's VERSION file at Nix eval time and bakes a real semantic version (sovran_version) into the generated config.json and a VERSION file shipped with the package, so the Hub always has a solid value to display. - server.py's _get_sovran_version() now reads that baked-in sovran_version first, and explicitly rejects a literal 'dev' value from any of its file-based fallbacks so the badge never shows 'vdev' again. - templates/index.html + header.css: wrapped the title and the version badge in a '.title-group' column so the version badge sits directly underneath 'Sovran_SystemsOS Hub', left-aligned with it. Co-authored-by: arena-agent <297053741+arena-agent@users.noreply.github.com>
This commit is contained in:
co-authored by
arena-agent
parent
ddba59cce8
commit
a8ff366992
@@ -2275,18 +2275,39 @@ async def api_logout(request: Request):
|
||||
|
||||
|
||||
def _get_sovran_version() -> str:
|
||||
"""Read the OS version from the VERSION file."""
|
||||
"""Read the OS version to display in the Hub header.
|
||||
|
||||
Resolution order (first match wins):
|
||||
1. ``sovran_version`` baked into the Nix-generated config.json — this
|
||||
is the authoritative, build-time value and is what's used on a
|
||||
real Sovran_SystemsOS install.
|
||||
2. ``/etc/nixos/VERSION`` — present on an installed system.
|
||||
3. A ``VERSION`` file shipped next to this package (installed by the
|
||||
Nix build) or in the repo root (local development checkout).
|
||||
4. A hard-coded fallback so the badge never renders a broken/empty
|
||||
value such as the old "vdev" placeholder.
|
||||
"""
|
||||
try:
|
||||
with open("/etc/nixos/VERSION", "r") as f:
|
||||
return f.read().strip()
|
||||
except FileNotFoundError:
|
||||
try:
|
||||
with open("VERSION", "r") as f: # fallback for development
|
||||
return f.read().strip()
|
||||
except FileNotFoundError:
|
||||
return "dev"
|
||||
version = load_config().get("sovran_version")
|
||||
if version:
|
||||
return str(version).strip().lstrip("vV")
|
||||
except Exception:
|
||||
return "dev"
|
||||
pass
|
||||
|
||||
for candidate in (
|
||||
"/etc/nixos/VERSION",
|
||||
os.path.join(os.path.dirname(os.path.abspath(__file__)), "VERSION"),
|
||||
"VERSION",
|
||||
):
|
||||
try:
|
||||
with open(candidate, "r") as f:
|
||||
version = f.read().strip().lstrip("vV")
|
||||
if version and version.lower() != "dev":
|
||||
return version
|
||||
except (FileNotFoundError, OSError):
|
||||
continue
|
||||
|
||||
return "1.0.0"
|
||||
|
||||
|
||||
@app.get("/", response_class=HTMLResponse)
|
||||
|
||||
Reference in New Issue
Block a user