Skip to content

Commit 280613c

Browse files
committed
frontend: Improve cluster metadata for UI
Signed-off-by: Vincent T <[email protected]>
1 parent df93c1c commit 280613c

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

backend/cmd/headlamp.go

+7
Original file line numberDiff line numberDiff line change
@@ -1178,6 +1178,13 @@ func (c *HeadlampConfig) getClusters() []Cluster {
11781178
"source": context.SourceStr(),
11791179
"namespace": context.KubeContext.Namespace,
11801180
"extensions": context.KubeContext.Extensions,
1181+
"origin": map[string]interface{}{
1182+
"kubeconfig": func() string {
1183+
path, _ := c.getKubeConfigPath(context.SourceStr())
1184+
return path
1185+
}(),
1186+
},
1187+
"originalName": context.Name,
11811188
},
11821189
})
11831190
}

frontend/src/components/App/Home/index.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,8 @@ function HomeComponent(props: HomeComponentProps) {
246246
*/
247247
function getOrigin(cluster: Cluster): string {
248248
if (cluster.meta_data?.source === 'kubeconfig') {
249-
const kubeconfigPath = process.env.KUBECONFIG ?? '~/.kube/config';
249+
const sourcePath = cluster.meta_data?.origin?.kubeconfig;
250+
const kubeconfigPath = process.env.KUBECONFIG ?? sourcePath;
250251
return `Kubeconfig: ${kubeconfigPath}`;
251252
} else if (cluster.meta_data?.source === 'dynamic_cluster') {
252253
return t('translation|Plugin');

frontend/src/components/App/Settings/SettingsCluster.tsx

+17-1
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,22 @@ export default function SettingsCluster() {
314314
);
315315
}
316316

317+
function ClusterName() {
318+
console.log('this cluster info: ', clusterInfo);
319+
const originalName = clusterInfo?.meta_data?.originalName;
320+
321+
return (
322+
<>
323+
t('translation|Name')
324+
{originalName && (
325+
<Typography variant="body2" color="textSecondary">
326+
Original name of cluster: {originalName}
327+
</Typography>
328+
)}
329+
</>
330+
);
331+
}
332+
317333
return (
318334
<>
319335
<SectionBox
@@ -336,7 +352,7 @@ export default function SettingsCluster() {
336352
<NameValueTable
337353
rows={[
338354
{
339-
name: t('translation|Name'),
355+
name: <ClusterName />,
340356
value: (
341357
<TextField
342358
onChange={event => {

0 commit comments

Comments
 (0)