-
Notifications
You must be signed in to change notification settings - Fork 73
Description
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Problem
The Ambient UI shows "v0.0.7" on the IT MP+ dev cluster. This value is hardcoded in components/manifests/base/frontend-deployment.yaml:33.
The GitHub Actions workflows hide this problem: after applying manifests, they imperatively run oc set env deployment/frontend VTEAM_VERSION=<sha> to overwrite it. ArgoCD can't do this — it's purely declarative, and would actually revert any imperative env var change on the next sync cycle.
The root cause is that version display is modeled as a deployment-time env var that requires imperative patching, rather than being an intrinsic property of the built artifact.
Solution
Have the backend serve its own version, embedded at compile time via Go ldflags. The frontend queries the backend for the version instead of reading a local env var. This makes the version an immutable property of the backend image — correct regardless of whether the cluster is managed by ArgoCD, GH Actions, or manual kubectl apply.
This also means the backend becomes the single source of version truth for all consumers (UI, CLI, API clients), not just the frontend.
Implementation
1. Backend: add version endpoint
Add a package-level Version variable (default "dev") to the backend's main.go, settable via ldflags. Register a GET /version handler that returns {"version": "<value>"}.
Files:
components/backend/main.go— addvar Version = "dev"components/backend/routes.go— registerGET /versioncomponents/backend/handlers/— add version handler (or inline it in routes)
2. Backend Dockerfile: wire ldflags
Pass -ldflags "-X main.Version=${VERSION}" in the go build command. Accept VERSION as a Docker build arg with a default of "dev".
Files:
components/backend/Dockerfile
3. Local build: pass git info
Update the Makefile (or kind build scripts) to pass --build-arg VERSION=$(git describe --always --dirty) when building the backend image. This gives developers a short SHA like f305fcc or f305fcc-dirty for uncommitted changes.
Files:
Makefile(or wherevermake build-all/make kind-upbuilds images)
4. Frontend: proxy to backend
Change the Next.js /api/version route to fetch from the backend's /version endpoint instead of returning env.VTEAM_VERSION. Remove VTEAM_VERSION from env.ts.
Files:
components/frontend/src/app/api/version/route.ts— fetch from backendcomponents/frontend/src/lib/env.ts— removeVTEAM_VERSION
5. Manifests: remove hardcoded version
Delete the VTEAM_VERSION env var from the frontend deployment manifest.
Files:
components/manifests/base/frontend-deployment.yaml— remove lines 32-33
6. GH Actions: inject version at build time, remove imperative patching
In both workflows, pass --build-arg VERSION=${{ github.sha }} (or the release tag) to the backend image build. Remove all oc set env ... VTEAM_VERSION lines.
Files:
.github/workflows/components-build-deploy.yml— removeVTEAM_VERSIONfrom "Update frontend environment variables" steps (lines 367-370, 446-449); add build arg to backend image build.github/workflows/prod-release-deploy.yaml— removeVTEAM_VERSIONfrom "Update frontend environment variables" step (lines 380-385); add build arg to backend image build
7. Tests
- Backend: add a test for the
/versionendpoint - Frontend: update or remove tests that reference
VTEAM_VERSION
Acceptance criteria
- Backend
GET /versionreturns the version embedded at compile time - Frontend UI displays the backend-reported version
-
VTEAM_VERSIONenv var is removed from manifests, frontend code, and GH Actions - No
oc set envcalls for version remain in any workflow - Local dev (
kind) shows a short git SHA (e.g.f305fccorf305fcc-dirty) - GH Actions stage deploy shows the full git SHA as the version
- GH Actions release deploy shows the release tag (e.g.
v0.1.3) as the version