Skip to content

Commit 14d4492

Browse files
rafi-ruetcse17RokibulHasan7
authored andcommitted
Fix targetClusterName for spoke cluster
Signed-off-by: rafi-ruetcse17 <rafialam6610@gmail.com>
1 parent a7160ae commit 14d4492

1 file changed

Lines changed: 22 additions & 6 deletions

File tree

  • charts/uik8sappscodecom-featureset-opscenter-observability-editor/ui

charts/uik8sappscodecom-featureset-opscenter-observability-editor/ui/functions.js

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -238,11 +238,19 @@ export const useFunc = (model) => {
238238
return null
239239
}
240240

241+
const getRoute = storeGet('/route')
242+
const spokeCluster = getRoute.params?.spoke
241243
const owner = storeGet('/route/params/user')
242244
const cluster = storeGet('/route/params/cluster')
243-
const { data } = await axios.get(
244-
`/telemetry/${owner}/${monitoringClusterName}/values/appscode-otel-stack?targetClusterName=${cluster}`,
245-
)
245+
let url = `/telemetry/${owner}/${monitoringClusterName}/values/appscode-otel-stack`
246+
if (cluster) {
247+
if (getRoute.fullPath.includes('/hubs/') && spokeCluster) {
248+
url += `?targetClusterName=${encodeURIComponent(spokeCluster)}`
249+
} else {
250+
url += `?targetClusterName=${encodeURIComponent(cluster)}`
251+
}
252+
}
253+
const { data } = await axios.get(url)
246254
return data
247255
}
248256

@@ -441,9 +449,18 @@ export const useFunc = (model) => {
441449
return []
442450
}
443451

452+
const getRoute = storeGet('/route')
453+
const spokeCluster = getRoute.params?.spoke
444454
const owner = storeGet('/route/params/user')
445455
const cluster = storeGet('/route/params/cluster')
446-
let url = `/telemetry/${owner}/monitoring-clusters?targetClusterName=${cluster}`
456+
let url = `/telemetry/${owner}/monitoring-clusters`
457+
if (cluster) {
458+
if (getRoute.fullPath.includes('/hubs/') && spokeCluster) {
459+
url += `?targetClusterName=${encodeURIComponent(spokeCluster)}`
460+
} else {
461+
url += `?targetClusterName=${encodeURIComponent(cluster)}`
462+
}
463+
}
447464
const { data } = await axios.get(url)
448465

449466
return data || []
@@ -461,7 +478,6 @@ export const useFunc = (model) => {
461478
await onEnabledFeaturesChange()
462479
}
463480

464-
465481
return {
466482
hideThisElement,
467483
checkIsResourceLoaded,
@@ -477,6 +493,6 @@ export const useFunc = (model) => {
477493
fetchFeatureSetOptions,
478494
checkIsOtelStackEnabled,
479495
fetchMonitoringClusterOptions,
480-
onMonitoringClusterChange
496+
onMonitoringClusterChange,
481497
}
482498
}

0 commit comments

Comments
 (0)