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
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
# For OpenShift, mount ./openshift/kubeconfig.yaml and set KUBECONFIG=/app/.kube-openshift/kubeconfig.yaml.
# For OpenShift, set KUBERNETES_API_URL to your cluster API endpoint.
DEPLOYMENT_IDENTIFIER_RESPONSE_FIELD=petname
# DEPLOYMENT_IDENTIFIER_API_URL=http://host.docker.internal:5123/petname # API endpoint for retrieving deployment identifier
# LABINFO_API_URL=http://host.docker.internal:5123/labinfo # API endpoint for retrieving lab information
# UDF_DEPLOYMENT_API_URL=http://metadata.udf/deployment # API endpoint for UDF deployment metadata
REMOTE_DOCS_REPO_SERVER="https://raw.githubusercontent.com"
REMOTE_DOCS_REPO_API_SERVER="https://api.github.com"
REMOTE_DOCS_REPO_OWNER=f5devcentral
Expand Down
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ services:
start_period: 20s

volumes:
cache:
driver: local
k3s-data:
driver: local
k3s-kubeconfig:
Expand Down
23 changes: 20 additions & 3 deletions src/lib/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,20 @@
export const UDF_DEPLOYMENT_API_URL = "http://metadata.udf/deployment";
export const DEPLOYMENT_IDENTIFIER_API_URL = "http://host.docker.internal:5123/petname";
export const LABINFO_API_URL = "http://host.docker.internal:5123/labinfo";
/**
* Returns the UDF deployment API URL from environment or default.
*/
export function getUdfDeploymentApiUrl(): string {
return process.env.UDF_DEPLOYMENT_API_URL || "http://metadata.udf/deployment";
}

/**
* Returns the deployment identifier API URL from environment or default.
*/
export function getDeploymentIdentifierApiUrl(): string {
return process.env.DEPLOYMENT_IDENTIFIER_API_URL || "http://host.docker.internal:5123/petname";
}

/**
* Returns the LabInfo API URL from environment or default.
*/
export function getLabInfoApiUrl(): string {
return process.env.LABINFO_API_URL || "http://host.docker.internal:5123/labinfo";
}
7 changes: 4 additions & 3 deletions src/lib/deployment-identifier-action.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use server";

import { DEPLOYMENT_IDENTIFIER_API_URL } from "./constants";
import { getDeploymentIdentifierApiUrl } from "./constants";
import { DeploymentIdentifier } from "./types";

function getDeploymentIdentifierResponseField(): string {
Expand All @@ -9,10 +9,11 @@ function getDeploymentIdentifierResponseField(): string {

export async function fetchDeploymentIdentifierServer(): Promise<DeploymentIdentifier> {
try {
const response = await fetch(DEPLOYMENT_IDENTIFIER_API_URL, { cache: "no-store" });
const deploymentIdentifierApiUrl = getDeploymentIdentifierApiUrl();
const response = await fetch(deploymentIdentifierApiUrl, { cache: "no-store" });
if (!response.ok) {
throw new Error(
`Failed to retrieve deployment identifier from ${DEPLOYMENT_IDENTIFIER_API_URL}`
`Failed to retrieve deployment identifier from ${getDeploymentIdentifierApiUrl()}`
);
}

Expand Down
8 changes: 4 additions & 4 deletions src/lib/udf-action.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use server";

import { LABINFO_API_URL, UDF_DEPLOYMENT_API_URL } from "./constants";
import { getLabInfoApiUrl, getUdfDeploymentApiUrl } from "./constants";
import { findValueByKey } from "./object-utils";

async function fetchInfo<T = unknown>(url: string, variableName: string): Promise<T | null> {
Expand All @@ -18,11 +18,11 @@ async function fetchInfo<T = unknown>(url: string, variableName: string): Promis
}

export async function fetchLabInfoServer<T = unknown>(variableName: string): Promise<T | null> {
return await fetchInfo<T>(LABINFO_API_URL, variableName);
return await fetchInfo<T>(getLabInfoApiUrl(), variableName);
}

export async function fetchUDFInfoServer<T = unknown>(variableName: string): Promise<T | null> {
return await fetchInfo<T>(UDF_DEPLOYMENT_API_URL, variableName);
return await fetchInfo<T>(getUdfDeploymentApiUrl(), variableName);
}

export async function fetchUdfComponentWebShellServer(componentName: string | null = null): Promise<string | null> {
Expand All @@ -31,7 +31,7 @@ export async function fetchUdfComponentWebShellServer(componentName: string | nu
return null;
}

const response = await fetch(UDF_DEPLOYMENT_API_URL, { mode: "cors" });
const response = await fetch(getUdfDeploymentApiUrl(), { mode: "cors" });

if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
Expand Down
Loading