Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/components-build-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ jobs:
platforms: ${{ matrix.arch.platform }}
push: true
tags: ${{ matrix.component.image }}:${{ github.sha }}-${{ matrix.arch.suffix }}
build-args: AMBIENT_VERSION=${{ github.sha }}
cache-from: type=gha,scope=${{ matrix.component.name }}-${{ matrix.arch.suffix }}
cache-to: type=gha,mode=max,scope=${{ matrix.component.name }}-${{ matrix.arch.suffix }}

Expand All @@ -208,6 +209,7 @@ jobs:
platforms: ${{ matrix.arch.platform }}
push: false
tags: ${{ matrix.component.image }}:pr-${{ github.event.pull_request.number }}-${{ matrix.arch.suffix }}
build-args: AMBIENT_VERSION=${{ github.sha }}
cache-from: type=gha,scope=${{ matrix.component.name }}-${{ matrix.arch.suffix }}

merge-manifests:
Expand Down Expand Up @@ -366,7 +368,6 @@ jobs:
run: |
oc set env deployment/frontend -n ambient-code -c frontend \
GITHUB_APP_SLUG="ambient-code-stage" \
VTEAM_VERSION="${{ github.sha }}" \
FEEDBACK_URL="https://forms.gle/7XiWrvo6No922DUz6"

- name: Update operator environment variables
Expand Down Expand Up @@ -445,7 +446,6 @@ jobs:
run: |
oc set env deployment/frontend -n ambient-code -c frontend \
GITHUB_APP_SLUG="ambient-code-stage" \
VTEAM_VERSION="${{ github.sha }}" \
FEEDBACK_URL="https://forms.gle/7XiWrvo6No922DUz6"

- name: Determine which components were built
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/prod-release-deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ jobs:
platforms: ${{ matrix.arch.platform }}
push: true
tags: ${{ matrix.component.image }}:${{ needs.release.outputs.new_tag }}-${{ matrix.arch.suffix }}
build-args: AMBIENT_VERSION=${{ needs.release.outputs.new_tag }}
cache-from: type=gha,scope=${{ matrix.component.name }}-${{ matrix.arch.suffix }}
cache-to: type=gha,mode=max,scope=${{ matrix.component.name }}-${{ matrix.arch.suffix }}

Expand Down Expand Up @@ -381,7 +382,6 @@ jobs:
run: |
oc set env deployment/frontend -n ambient-code -c frontend \
GITHUB_APP_SLUG="ambient-code" \
VTEAM_VERSION="${{ needs.release.outputs.new_tag }}" \
FEEDBACK_URL="https://forms.gle/7XiWrvo6No922DUz6"

- name: Update operator environment variables
Expand Down
16 changes: 4 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.PHONY: help setup build-all build-frontend build-backend build-operator build-runner build-state-sync build-public-api build-cli deploy clean check-architecture
.PHONY: local-up local-down local-clean local-status local-rebuild local-reload-backend local-reload-frontend local-reload-operator local-reload-api-server local-sync-version
.PHONY: local-up local-down local-clean local-status local-rebuild local-reload-backend local-reload-frontend local-reload-operator local-reload-api-server
.PHONY: local-dev-token
.PHONY: local-logs local-logs-backend local-logs-frontend local-logs-operator local-shell local-shell-frontend
.PHONY: local-test local-test-dev local-test-quick test-all local-url local-troubleshoot local-port-forward local-stop-port-forward
Expand Down Expand Up @@ -171,6 +171,7 @@ build-frontend: ## Build frontend image
build-backend: ## Build backend image
@echo "$(COLOR_BLUE)▶$(COLOR_RESET) Building backend with $(CONTAINER_ENGINE)..."
@cd components/backend && $(CONTAINER_ENGINE) build $(PLATFORM_FLAG) $(BUILD_FLAGS) \
--build-arg AMBIENT_VERSION=$(shell git describe --tags --always --dirty) \
-t $(BACKEND_IMAGE) .
@echo "$(COLOR_GREEN)✓$(COLOR_RESET) Backend built: $(BACKEND_IMAGE)"

Expand Down Expand Up @@ -331,7 +332,6 @@ local-up: check-minikube check-kubectl ## Start local development environment (m
@kubectl apply -f components/manifests/base/workspace-pvc.yaml -n $(NAMESPACE) $(QUIET_REDIRECT) || true
@echo "$(COLOR_BLUE)▶$(COLOR_RESET) Step 6.5/8: Configuring operator..."
@$(MAKE) --no-print-directory _create-operator-config
@$(MAKE) --no-print-directory local-sync-version
@echo "$(COLOR_BLUE)▶$(COLOR_RESET) Step 7/8: Deploying services..."
@kubectl apply -f components/manifests/minikube/backend-deployment.yaml $(QUIET_REDIRECT)
@kubectl apply -f components/manifests/minikube/backend-service.yaml $(QUIET_REDIRECT)
Expand Down Expand Up @@ -394,14 +394,6 @@ local-status: check-kubectl ## Show status of local deployment
$(MAKE) --no-print-directory _show-access-info; \
fi

local-sync-version: ## Sync version from git to local deployment manifests
@echo "$(COLOR_BLUE)▶$(COLOR_RESET) Syncing version from git..."
@VERSION=$$(git describe --tags --always 2>/dev/null || echo "dev") && \
echo " Using version: $$VERSION" && \
sed -i.bak "s|value: \"v.*\"|value: \"$$VERSION\"|" \
components/manifests/minikube/frontend-deployment.yaml && \
rm -f components/manifests/minikube/frontend-deployment.yaml.bak && \
echo " $(COLOR_GREEN)✓$(COLOR_RESET) Version synced to $$VERSION"

local-rebuild: check-local-context ## Rebuild and reload all components
@echo "$(COLOR_BOLD)🔄 Rebuilding all components...$(COLOR_RESET)"
Expand All @@ -411,7 +403,7 @@ local-rebuild: check-local-context ## Rebuild and reload all components

local-reload-backend: check-local-context ## Rebuild and reload backend only
@echo "$(COLOR_BLUE)▶$(COLOR_RESET) Rebuilding backend..."
@cd components/backend && $(CONTAINER_ENGINE) build -t $(BACKEND_IMAGE) . >/dev/null 2>&1
@cd components/backend && $(CONTAINER_ENGINE) build --build-arg AMBIENT_VERSION=$(shell git describe --tags --always --dirty) -t $(BACKEND_IMAGE) . >/dev/null 2>&1
@$(CONTAINER_ENGINE) tag $(BACKEND_IMAGE) localhost/$(BACKEND_IMAGE) 2>/dev/null || true
@$(CONTAINER_ENGINE) save -o /tmp/backend-reload.tar localhost/$(BACKEND_IMAGE)
@minikube image load /tmp/backend-reload.tar >/dev/null 2>&1
Expand Down Expand Up @@ -962,7 +954,7 @@ _kind-load-images: ## Internal: Load images into kind cluster

_build-and-load: ## Internal: Build and load images
@echo " Building backend ($(PLATFORM))..."
@$(CONTAINER_ENGINE) build $(PLATFORM_FLAG) -t $(BACKEND_IMAGE) components/backend $(QUIET_REDIRECT)
@$(CONTAINER_ENGINE) build $(PLATFORM_FLAG) --build-arg AMBIENT_VERSION=$(shell git describe --tags --always --dirty) -t $(BACKEND_IMAGE) components/backend $(QUIET_REDIRECT)
@echo " Building frontend ($(PLATFORM))..."
@$(CONTAINER_ENGINE) build $(PLATFORM_FLAG) -t $(FRONTEND_IMAGE) components/frontend $(QUIET_REDIRECT)
@echo " Building operator ($(PLATFORM))..."
Expand Down
5 changes: 3 additions & 2 deletions components/backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,9 @@ RUN go mod download
# Copy the source code
COPY . .

# Build the application
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w" -o main .
# Build the application with version embedded via ldflags
ARG AMBIENT_VERSION=dev
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags="-s -w -X main.GitVersion=${AMBIENT_VERSION}" -o main .

# Final stage
FROM registry.access.redhat.com/ubi9/ubi-minimal:latest
Expand Down
17 changes: 17 additions & 0 deletions components/backend/handlers/version.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package handlers

import (
"net/http"

"github.com/gin-gonic/gin"
)

var version = "dev"

func SetVersion(v string) {
version = v
}

func GetVersion(c *gin.Context) {
c.JSON(http.StatusOK, gin.H{"version": version})
}
53 changes: 53 additions & 0 deletions components/backend/handlers/version_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//go:build test

package handlers

import (
test_constants "ambient-code-backend/tests/constants"
"net/http"

"ambient-code-backend/tests/logger"
"ambient-code-backend/tests/test_utils"

. "github.com/onsi/ginkgo/v2"
)

var _ = Describe("Version Handler", Label(test_constants.LabelUnit, test_constants.LabelHandlers), func() {
var (
httpUtils *test_utils.HTTPTestUtils
)

BeforeEach(func() {
logger.Log("Setting up Version Handler test")
httpUtils = test_utils.NewHTTPTestUtils()
})

Context("When querying application version", func() {
It("Should return the default version", func() {
context := httpUtils.CreateTestGinContext("GET", "/api/version", nil)

GetVersion(context)

httpUtils.AssertHTTPStatus(http.StatusOK)
httpUtils.AssertJSONContains(map[string]interface{}{
"version": "dev",
})
logger.Log("Version endpoint returned default version")
})

It("Should return a version set via SetVersion", func() {
SetVersion("v1.2.3")
defer SetVersion("dev")

context := httpUtils.CreateTestGinContext("GET", "/api/version", nil)

GetVersion(context)

httpUtils.AssertHTTPStatus(http.StatusOK)
httpUtils.AssertJSONContains(map[string]interface{}{
"version": "v1.2.3",
})
logger.Log("Version endpoint returned configured version")
})
})
})
3 changes: 3 additions & 0 deletions components/backend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ func main() {
return
}

// Expose build version to handlers package
handlers.SetVersion(GitVersion)

// Log build information
logBuildInfo()

Expand Down
3 changes: 3 additions & 0 deletions components/backend/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ func registerRoutes(r *gin.Engine) {
// Cluster info endpoint (public, no auth required)
api.GET("/cluster-info", handlers.GetClusterInfo)

// Version endpoint (public, no auth required)
api.GET("/version", handlers.GetVersion)

// LDAP search endpoints (cluster-scoped, auth-required)
api.GET("/ldap/users", handlers.SearchLDAPUsers)
api.GET("/ldap/users/:uid", handlers.GetLDAPUser)
Expand Down
28 changes: 24 additions & 4 deletions components/frontend/src/app/api/version/route.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,27 @@
import { env } from '@/lib/env';
import { BACKEND_URL } from '@/lib/config';

/**
* GET /api/version
* Proxies to the backend version endpoint
*/
export async function GET() {
return Response.json({
version: env.VTEAM_VERSION,
});
try {
const response = await fetch(`${BACKEND_URL}/version`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
});

if (!response.ok) {
const errorData = await response.json().catch(() => ({ error: 'Unknown error' }));
return Response.json(errorData, { status: response.status });
}

const data = await response.json();
return Response.json(data);
} catch (error) {
console.error('Error fetching version:', error);
return Response.json({ error: 'Failed to fetch version' }, { status: 500 });
}
}
5 changes: 0 additions & 5 deletions components/frontend/src/lib/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ type EnvConfig = {
// GitHub configuration (public)
GITHUB_APP_SLUG: string;

// Version information (public, optional)
VTEAM_VERSION?: string;

// Feedback URL (public, optional)
FEEDBACK_URL?: string;

Expand Down Expand Up @@ -68,7 +65,6 @@ export const env: EnvConfig = {
NODE_ENV: (process.env.NODE_ENV || 'development') as Environment,
BACKEND_URL: getEnv('BACKEND_URL', 'http://localhost:8080/api'),
GITHUB_APP_SLUG: getEnv('GITHUB_APP_SLUG', 'ambient-code-vteam'),
VTEAM_VERSION: getOptionalEnv('VTEAM_VERSION') || 'latest',
FEEDBACK_URL: getOptionalEnv('FEEDBACK_URL'),
OC_TOKEN: getOptionalEnv('OC_TOKEN'),
OC_USER: getOptionalEnv('OC_USER'),
Expand All @@ -86,7 +82,6 @@ export const env: EnvConfig = {
*/
export const publicEnv = {
GITHUB_APP_SLUG: env.GITHUB_APP_SLUG,
VTEAM_VERSION: env.VTEAM_VERSION,
FEEDBACK_URL: env.FEEDBACK_URL,
};

Expand Down
2 changes: 0 additions & 2 deletions components/manifests/base/core/frontend-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ spec:
value: "production"
- name: GITHUB_APP_SLUG
value: "ambient-code"
- name: VTEAM_VERSION
value: "v0.0.7"
# Note: Langfuse feedback now handled by runner, not frontend
# Unleash feature flags (optional - proxy routes disabled when not set)
- name: UNLEASH_URL
Expand Down
Loading