@@ -38,8 +38,9 @@ import (
3838
3939// workspaceInfo contains workspace path and type information.
4040type workspaceInfo struct {
41- Path logicalcluster.Path
42- Type * tenancyv1alpha1.WorkspaceTypeReference
41+ Path logicalcluster.Path
42+ Type * tenancyv1alpha1.WorkspaceTypeReference
43+ Cluster string
4344}
4445
4546// TreeOptions contains options for displaying the workspace tree.
@@ -170,17 +171,25 @@ func (o *TreeOptions) runInteractive(ctx context.Context, currentWorkspace logic
170171
171172func (o * TreeOptions ) populateInteractiveNodeBubble (ctx context.Context , node * treeNode , workspace logicalcluster.Path , workspaceName string , currentWorkspace logicalcluster.Path , currentNode * * treeNode ) error {
172173 var workspaceType * tenancyv1alpha1.WorkspaceTypeReference
174+ var workspaceCluster string
173175 if parent , hasParent := workspace .Parent (); hasParent {
174176 workspaceBaseName := workspace .Base ()
175177 ws , err := o .kcpClusterClient .Cluster (parent ).TenancyV1alpha1 ().Workspaces ().Get (ctx , workspaceBaseName , metav1.GetOptions {})
176- if err == nil && ws .Spec .Type != nil {
177- workspaceType = ws .Spec .Type
178+ if err == nil {
179+ if ws .Spec .Type != nil {
180+ workspaceType = ws .Spec .Type
181+ }
182+ workspaceCluster = ws .Spec .Cluster
178183 }
179184 }
185+ if workspaceCluster == "" {
186+ workspaceCluster = workspace .Base ()
187+ }
180188
181189 wsInfo := & workspaceInfo {
182- Path : workspace ,
183- Type : workspaceType ,
190+ Path : workspace ,
191+ Type : workspaceType ,
192+ Cluster : workspaceCluster ,
184193 }
185194
186195 node .info = wsInfo
@@ -210,8 +219,9 @@ func (o *TreeOptions) populateInteractiveNodeBubble(ctx context.Context, node *t
210219 }
211220
212221 childWorkspaceInfo := & workspaceInfo {
213- Path : childPath ,
214- Type : ws .Spec .Type ,
222+ Path : childPath ,
223+ Type : ws .Spec .Type ,
224+ Cluster : ws .Spec .Cluster ,
215225 }
216226
217227 childNode := & treeNode {
0 commit comments