Skip to content

Commit 69649f0

Browse files
fix: always return icon/logo URL in WS/WSK for now (#964)
* fix: Replace the hardcoded WSK icon URI with cm URL Until #736 from Andy is fully cooked we atleast want to have some way of showing the WSK icons in the upcoming alpha release. Co-authored-by: Mathew Wicks <5735406+thesuperzapper@users.noreply.github.com> Signed-off-by: Christian Heusel <christian@heusel.eu> * mathew: 1 Signed-off-by: Mathew Wicks <5735406+thesuperzapper@users.noreply.github.com> * mathew: 2 Signed-off-by: Mathew Wicks <5735406+thesuperzapper@users.noreply.github.com> --------- Signed-off-by: Christian Heusel <christian@heusel.eu> Signed-off-by: Mathew Wicks <5735406+thesuperzapper@users.noreply.github.com> Co-authored-by: Mathew Wicks <5735406+thesuperzapper@users.noreply.github.com>
1 parent d28250b commit 69649f0

File tree

2 files changed

+26
-23
lines changed

2 files changed

+26
-23
lines changed

workspaces/backend/internal/models/workspacekinds/funcs.go

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ limitations under the License.
1717
package workspacekinds
1818

1919
import (
20-
"fmt"
21-
2220
kubefloworgv1beta1 "github.com/kubeflow/notebooks/workspaces/controller/api/v1beta1"
2321
"k8s.io/utils/ptr"
2422
)
@@ -39,18 +37,15 @@ func NewWorkspaceKindModelFromWorkspaceKind(wsk *kubefloworgv1beta1.WorkspaceKin
3937
statusImageConfigMap := buildOptionMetricsMap(wsk.Status.PodTemplateOptions.ImageConfig)
4038
statusPodConfigMap := buildOptionMetricsMap(wsk.Status.PodTemplateOptions.PodConfig)
4139

42-
// TODO: icons can either be a remote URL or read from a ConfigMap.
43-
// in BOTH cases, we should cache and serve the image under a path on the backend API:
44-
// /api/v1/workspacekinds/{name}/assets/icon
4540
iconRef := ImageRef{
46-
URL: fmt.Sprintf("/workspaces/backend/api/v1/workspacekinds/%s/assets/icon", wsk.Name),
41+
// TODO: icons MUST be either set to remote URL or read from a ConfigMap
42+
// we can remove this fallback once we implement the ConfigMap option.
43+
URL: ptr.Deref(wsk.Spec.Spawner.Icon.Url, "__UNKNOWN_ICON_URL__"),
4744
}
48-
49-
// TODO: logos can either be a remote URL or read from a ConfigMap.
50-
// in BOTH cases, we should cache and serve the image under a path on the backend API:
51-
// /api/v1/workspacekinds/{name}/assets/logo
5245
logoRef := ImageRef{
53-
URL: fmt.Sprintf("/workspaces/backend/api/v1/workspacekinds/%s/assets/logo", wsk.Name),
46+
// TODO: logos MUST be either set to remote URL or read from a ConfigMap
47+
// we can remove this fallback once we implement the ConfigMap option.
48+
URL: ptr.Deref(wsk.Spec.Spawner.Logo.Url, "__UNKNOWN_LOGO_URL__"),
5449
}
5550

5651
return WorkspaceKind{

workspaces/backend/internal/models/workspaces/funcs.go

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ const (
2929
UnknownHomeMountPath = "__UNKNOWN_HOME_MOUNT_PATH__"
3030
UnknownImageConfig = "__UNKNOWN_IMAGE_CONFIG__"
3131
UnknownPodConfig = "__UNKNOWN_POD_CONFIG__"
32+
UnknownIconURL = "__UNKNOWN_ICON_URL__"
33+
UnknownLogoURL = "__UNKNOWN_LOGO_URL__"
3234
)
3335

3436
// NewWorkspaceListItemFromWorkspace creates a WorkspaceListItem model from a Workspace and WorkspaceKind object.
@@ -39,18 +41,20 @@ func NewWorkspaceListItemFromWorkspace(ws *kubefloworgv1beta1.Workspace, wsk *ku
3941
panic("provided WorkspaceKind does not match the Workspace")
4042
}
4143

42-
// TODO: icons can either be a remote URL or read from a ConfigMap.
43-
// in BOTH cases, we should cache and serve the image under a path on the backend API:
44-
// /api/v1/workspacekinds/{name}/assets/icon
45-
iconRef := ImageRef{
46-
URL: fmt.Sprintf("/workspaces/backend/api/v1/workspacekinds/%s/assets/icon", ws.Spec.Kind),
44+
// we only know the icon url if the WorkspaceKind exists
45+
iconURL := UnknownIconURL
46+
if wskExists(wsk) {
47+
// TODO: icons MUST be either set to remote URL or read from a ConfigMap
48+
// we can remove this fallback once we implement the ConfigMap option.
49+
iconURL = ptr.Deref(wsk.Spec.Spawner.Icon.Url, UnknownIconURL)
4750
}
4851

49-
// TODO: logos can either be a remote URL or read from a ConfigMap.
50-
// in BOTH cases, we should cache and serve the image under a path on the backend API:
51-
// /api/v1/workspacekinds/{name}/assets/logo
52-
logoRef := ImageRef{
53-
URL: fmt.Sprintf("/workspaces/backend/api/v1/workspacekinds/%s/assets/logo", ws.Spec.Kind),
52+
// we only know the logo url if the WorkspaceKind exists
53+
logoURL := UnknownLogoURL
54+
if wskExists(wsk) {
55+
// TODO: logos MUST be either set to remote URL or read from a ConfigMap
56+
// we can remove this fallback once we implement the ConfigMap option.
57+
logoURL = ptr.Deref(wsk.Spec.Spawner.Logo.Url, UnknownLogoURL)
5458
}
5559

5660
podLabels := make(map[string]string)
@@ -90,8 +94,12 @@ func NewWorkspaceListItemFromWorkspace(ws *kubefloworgv1beta1.Workspace, wsk *ku
9094
WorkspaceKind: WorkspaceKindInfo{
9195
Name: ws.Spec.Kind,
9296
Missing: !wskExists(wsk),
93-
Icon: iconRef,
94-
Logo: logoRef,
97+
Icon: ImageRef{
98+
URL: iconURL,
99+
},
100+
Logo: ImageRef{
101+
URL: logoURL,
102+
},
95103
},
96104
Paused: ptr.Deref(ws.Spec.Paused, false),
97105
PausedTime: ws.Status.PauseTime,

0 commit comments

Comments
 (0)