@@ -128,6 +128,39 @@ func NewWorkspaceModelFromWorkspace(ws *kubefloworgv1beta1.Workspace, wsk *kubef
128
128
return workspaceModel
129
129
}
130
130
131
+ func buildPortsList (ws * kubefloworgv1beta1.Workspace , wsk * kubefloworgv1beta1.WorkspaceKind ) []ImagePort {
132
+ var ports []ImagePort
133
+
134
+ // Return an empty list if wsk is nil.
135
+ if ! wskExists (wsk ) {
136
+ return ports
137
+ }
138
+
139
+ // Get the image configuration from the WorkspaceKind's PodTemplate options.
140
+ imageConfig := wsk .Spec .PodTemplate .Options .ImageConfig
141
+
142
+ for _ , val := range imageConfig .Values {
143
+ if len (val .Spec .Ports ) == 0 {
144
+ continue
145
+ }
146
+ firstPort := val .Spec .Ports [0 ]
147
+ portStr := fmt .Sprintf ("%d" , firstPort .Port )
148
+ id := firstPort .Id
149
+ displayName := firstPort .DisplayName
150
+ if displayName == "" {
151
+ displayName = val .Id
152
+ }
153
+ imagePort := ImagePort {
154
+ ID : id ,
155
+ DisplayName : displayName ,
156
+ Port : portStr ,
157
+ }
158
+ ports = append (ports , imagePort )
159
+ }
160
+
161
+ return ports
162
+ }
163
+
131
164
func wskExists (wsk * kubefloworgv1beta1.WorkspaceKind ) bool {
132
165
return wsk != nil && wsk .UID != ""
133
166
}
@@ -218,6 +251,7 @@ func buildImageConfig(ws *kubefloworgv1beta1.Workspace, wsk *kubefloworgv1beta1.
218
251
Current : currentImageConfig ,
219
252
Desired : desiredImageConfig ,
220
253
RedirectChain : redirectChain ,
254
+ Ports : buildPortsList (ws , wsk ),
221
255
}
222
256
}
223
257
0 commit comments