@@ -18,6 +18,7 @@ package workspaces
1818
1919import (
2020 "fmt"
21+ "path"
2122
2223 kubefloworgv1beta1 "github.com/kubeflow/notebooks/workspaces/controller/api/v1beta1"
2324 "k8s.io/utils/ptr"
@@ -124,16 +125,17 @@ func NewWorkspaceModelFromWorkspace(ws *kubefloworgv1beta1.Workspace, wsk *kubef
124125 // https://github.com/kubeflow/notebooks/issues/38
125126 LastProbe : nil ,
126127 },
128+ Services : buildServicesList (ws , wsk ),
127129 }
128130 return workspaceModel
129131}
130132
131- func buildPortsList (ws * kubefloworgv1beta1.Workspace , wsk * kubefloworgv1beta1.WorkspaceKind ) []ImagePort {
132- var ports []ImagePort
133+ func buildServicesList (ws * kubefloworgv1beta1.Workspace , wsk * kubefloworgv1beta1.WorkspaceKind ) []Service {
134+ //nolint:prealloc
135+ var services []Service
133136
134- // Return an empty list if wsk is nil.
135137 if ! wskExists (wsk ) {
136- return ports
138+ return services
137139 }
138140
139141 // Get the image configuration from the WorkspaceKind's PodTemplate options.
@@ -145,20 +147,22 @@ func buildPortsList(ws *kubefloworgv1beta1.Workspace, wsk *kubefloworgv1beta1.Wo
145147 }
146148 firstPort := val .Spec .Ports [0 ]
147149 portStr := fmt .Sprintf ("%d" , firstPort .Port )
148- id := firstPort .Id
149150 displayName := firstPort .DisplayName
150151 if displayName == "" {
151152 displayName = val .Id
152153 }
153- imagePort := ImagePort {
154- ID : id ,
155- DisplayName : displayName ,
156- Port : portStr ,
154+ basePath := "/workspace"
155+ notebookPath := path .Join (basePath , ws .Namespace , ws .Name , portStr )
156+ service := Service {
157+ HttpService : & HttpService {
158+ DisplayName : displayName ,
159+ HttpPath : notebookPath ,
160+ },
157161 }
158- ports = append (ports , imagePort )
162+ services = append (services , service )
159163 }
160164
161- return ports
165+ return services
162166}
163167
164168func wskExists (wsk * kubefloworgv1beta1.WorkspaceKind ) bool {
@@ -251,7 +255,6 @@ func buildImageConfig(ws *kubefloworgv1beta1.Workspace, wsk *kubefloworgv1beta1.
251255 Current : currentImageConfig ,
252256 Desired : desiredImageConfig ,
253257 RedirectChain : redirectChain ,
254- Ports : buildPortsList (ws , wsk ),
255258 }
256259}
257260
0 commit comments