From 68b1fa3674b734407904a1f0c4d0621ac3cf846f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20Daba=C5=A1inskas?= Date: Mon, 11 Nov 2024 21:55:46 +0200 Subject: [PATCH 1/2] fix(argocd): update linkUrl logic for multi-instance support Improved the logic for determining ArgoCD instance URL when multiple instances are configured. The function now correctly looks up instance configuration from `appLocatorMethods` when base URL is not set. This change ensures proper URL resolution for deployments with multiple ArgoCD instances by: - Looking up instance config based on instance name - Falling back to instance `url` if `frontendUrl` is not specified - Using global base URL as fallback --- .../src/components/ArgoCDHistoryTable.tsx | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/plugins/frontend/backstage-plugin-argo-cd/src/components/ArgoCDHistoryTable.tsx b/plugins/frontend/backstage-plugin-argo-cd/src/components/ArgoCDHistoryTable.tsx index 5bc259d9c..92053a091 100644 --- a/plugins/frontend/backstage-plugin-argo-cd/src/components/ArgoCDHistoryTable.tsx +++ b/plugins/frontend/backstage-plugin-argo-cd/src/components/ArgoCDHistoryTable.tsx @@ -43,13 +43,25 @@ export const ArgoCDHistoryTable = ({ const configApi = useApi(configApiRef); const namespaced = configApi.getOptionalBoolean('argocd.namespacedApps') ?? false; + const baseUrl = configApi.getOptionalString('argocd.baseUrl'); const supportsMultipleArgoInstances: boolean = Boolean( configApi.getOptionalConfigArray('argocd.appLocatorMethods')?.length, ); - const linkUrl = (row: any) => - supportsMultipleArgoInstances && row.metadata?.instance?.frontendUrl - ? row.metadata?.instance?.frontendUrl - : configApi.getOptionalString('argocd.baseUrl'); + + const linkUrl = (row: any): string | undefined => { + if (supportsMultipleArgoInstances && !baseUrl) { + const instanceConfig = configApi + .getConfigArray('argocd.appLocatorMethods') + .find(value => value.getOptionalString('type') === 'config') + ?.getOptionalConfigArray('instances') + ?.find(value => value.getOptionalString('name') === row?.instance); + return ( + instanceConfig?.getOptionalString('frontendUrl') ?? + instanceConfig?.getOptionalString('url') + ); + } + return baseUrl; + }; const columns: TableColumn[] = [ { From 7520be9eb1c66c319459d27a0534703b4e1a0c20 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomas=20Daba=C5=A1inskas?= Date: Mon, 11 Nov 2024 21:58:21 +0200 Subject: [PATCH 2/2] chore(changeset): update changeset --- .changeset/fresh-pears-fix.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/fresh-pears-fix.md diff --git a/.changeset/fresh-pears-fix.md b/.changeset/fresh-pears-fix.md new file mode 100644 index 000000000..cf2dad119 --- /dev/null +++ b/.changeset/fresh-pears-fix.md @@ -0,0 +1,5 @@ +--- +'@roadiehq/backstage-plugin-argo-cd': patch +--- + +update linkUrl logic in ArgoCDHistory component for multi-instance support