Skip to content

Commit ceec598

Browse files
author
rafriat
committed
--amend
Signed-off-by: rafriat <[email protected]>
1 parent 7421ad0 commit ceec598

File tree

5 files changed

+78
-45
lines changed

5 files changed

+78
-45
lines changed

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

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,10 @@ func NewWorkspaceKindModelFromWorkspaceKind(wsk *kubefloworgv1beta1.WorkspaceKin
6262
Hidden: ptr.Deref(wsk.Spec.Spawner.Hidden, false),
6363
Icon: iconRef,
6464
Logo: logoRef,
65-
Workspaces: wsk.Status.Workspaces,
65+
//TODO: add namespaceMetrics
66+
ClusterMetrics: clusterMetrics{
67+
Workspaces: wsk.Status.Workspaces,
68+
},
6669
PodTemplate: PodTemplate{
6770
PodMetadata: PodMetadata{
6871
Labels: podLabels,
@@ -104,7 +107,9 @@ func buildImageConfigValues(imageConfig kubefloworgv1beta1.ImageConfig, statusIm
104107
Labels: buildOptionLabels(option.Spawner.Labels),
105108
Hidden: ptr.Deref(option.Spawner.Hidden, false),
106109
Redirect: buildOptionRedirect(option.Redirect),
107-
Workspaces: statusImageConfigMap[option.Id],
110+
ClusterMetrics: clusterMetrics{
111+
Workspaces: statusImageConfigMap[option.Id],
112+
},
108113
}
109114
}
110115
return imageConfigValues
@@ -121,7 +126,9 @@ func buildPodConfigValues(podConfig kubefloworgv1beta1.PodConfig, statusPodConfi
121126
Labels: buildOptionLabels(option.Spawner.Labels),
122127
Hidden: ptr.Deref(option.Spawner.Hidden, false),
123128
Redirect: buildOptionRedirect(option.Redirect),
124-
Workspaces: statusPodConfigMap[option.Id],
129+
ClusterMetrics: clusterMetrics{
130+
Workspaces: statusPodConfigMap[option.Id],
131+
},
125132
}
126133
}
127134
return podConfigValues

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

Lines changed: 29 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,21 @@ limitations under the License.
1717
package workspacekinds
1818

1919
type WorkspaceKind struct {
20-
Name string `json:"name"`
21-
DisplayName string `json:"displayName"`
22-
Description string `json:"description"`
23-
Deprecated bool `json:"deprecated"`
24-
DeprecationMessage string `json:"deprecationMessage"`
25-
Hidden bool `json:"hidden"`
26-
Icon ImageRef `json:"icon"`
27-
Logo ImageRef `json:"logo"`
28-
Workspaces int32 `json:"workspacesCount"`
29-
PodTemplate PodTemplate `json:"podTemplate"`
20+
Name string `json:"name"`
21+
DisplayName string `json:"displayName"`
22+
Description string `json:"description"`
23+
Deprecated bool `json:"deprecated"`
24+
DeprecationMessage string `json:"deprecationMessage"`
25+
Hidden bool `json:"hidden"`
26+
Icon ImageRef `json:"icon"`
27+
Logo ImageRef `json:"logo"`
28+
ClusterMetrics clusterMetrics `json:"clusterMetrics,omitempty"`
29+
PodTemplate PodTemplate `json:"podTemplate"`
30+
//TODO: add namespaceMetrics
31+
}
32+
33+
type clusterMetrics struct {
34+
Workspaces int32 `json:"workspacesCount"`
3035
}
3136

3237
type ImageRef struct {
@@ -59,13 +64,13 @@ type ImageConfig struct {
5964
}
6065

6166
type ImageConfigValue struct {
62-
Id string `json:"id"`
63-
DisplayName string `json:"displayName"`
64-
Description string `json:"description"`
65-
Labels []OptionLabel `json:"labels"`
66-
Hidden bool `json:"hidden"`
67-
Redirect *OptionRedirect `json:"redirect,omitempty"`
68-
Workspaces int32 `json:"workspacesCount"`
67+
Id string `json:"id"`
68+
DisplayName string `json:"displayName"`
69+
Description string `json:"description"`
70+
Labels []OptionLabel `json:"labels"`
71+
Hidden bool `json:"hidden"`
72+
Redirect *OptionRedirect `json:"redirect,omitempty"`
73+
ClusterMetrics clusterMetrics `json:"clusterMetrics"`
6974
}
7075

7176
type PodConfig struct {
@@ -74,13 +79,13 @@ type PodConfig struct {
7479
}
7580

7681
type PodConfigValue struct {
77-
Id string `json:"id"`
78-
DisplayName string `json:"displayName"`
79-
Description string `json:"description"`
80-
Labels []OptionLabel `json:"labels"`
81-
Hidden bool `json:"hidden"`
82-
Redirect *OptionRedirect `json:"redirect,omitempty"`
83-
Workspaces int32 `json:"workspacesCount"`
82+
Id string `json:"id"`
83+
DisplayName string `json:"displayName"`
84+
Description string `json:"description"`
85+
Labels []OptionLabel `json:"labels"`
86+
Hidden bool `json:"hidden"`
87+
Redirect *OptionRedirect `json:"redirect,omitempty"`
88+
ClusterMetrics clusterMetrics `json:"clusterMetrics"`
8489
}
8590

8691
type OptionLabel struct {

workspaces/backend/openapi/docs.go

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,9 @@ const docTemplate = `{
720720
"workspacekinds.ImageConfigValue": {
721721
"type": "object",
722722
"properties": {
723+
"clusterMetrics": {
724+
"$ref": "#/definitions/workspacekinds.clusterMetrics"
725+
},
723726
"description": {
724727
"type": "string"
725728
},
@@ -740,9 +743,6 @@ const docTemplate = `{
740743
},
741744
"redirect": {
742745
"$ref": "#/definitions/workspacekinds.OptionRedirect"
743-
},
744-
"workspacesCount": {
745-
"type": "integer"
746746
}
747747
}
748748
},
@@ -793,6 +793,9 @@ const docTemplate = `{
793793
"workspacekinds.PodConfigValue": {
794794
"type": "object",
795795
"properties": {
796+
"clusterMetrics": {
797+
"$ref": "#/definitions/workspacekinds.clusterMetrics"
798+
},
796799
"description": {
797800
"type": "string"
798801
},
@@ -813,9 +816,6 @@ const docTemplate = `{
813816
},
814817
"redirect": {
815818
"$ref": "#/definitions/workspacekinds.OptionRedirect"
816-
},
817-
"workspacesCount": {
818-
"type": "integer"
819819
}
820820
}
821821
},
@@ -896,6 +896,9 @@ const docTemplate = `{
896896
"workspacekinds.WorkspaceKind": {
897897
"type": "object",
898898
"properties": {
899+
"clusterMetrics": {
900+
"$ref": "#/definitions/workspacekinds.clusterMetrics"
901+
},
899902
"deprecated": {
900903
"type": "boolean"
901904
},
@@ -922,7 +925,12 @@ const docTemplate = `{
922925
},
923926
"podTemplate": {
924927
"$ref": "#/definitions/workspacekinds.PodTemplate"
925-
},
928+
}
929+
}
930+
},
931+
"workspacekinds.clusterMetrics": {
932+
"type": "object",
933+
"properties": {
926934
"workspacesCount": {
927935
"type": "integer"
928936
}

workspaces/backend/openapi/swagger.json

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,9 @@
718718
"workspacekinds.ImageConfigValue": {
719719
"type": "object",
720720
"properties": {
721+
"clusterMetrics": {
722+
"$ref": "#/definitions/workspacekinds.clusterMetrics"
723+
},
721724
"description": {
722725
"type": "string"
723726
},
@@ -738,9 +741,6 @@
738741
},
739742
"redirect": {
740743
"$ref": "#/definitions/workspacekinds.OptionRedirect"
741-
},
742-
"workspacesCount": {
743-
"type": "integer"
744744
}
745745
}
746746
},
@@ -791,6 +791,9 @@
791791
"workspacekinds.PodConfigValue": {
792792
"type": "object",
793793
"properties": {
794+
"clusterMetrics": {
795+
"$ref": "#/definitions/workspacekinds.clusterMetrics"
796+
},
794797
"description": {
795798
"type": "string"
796799
},
@@ -811,9 +814,6 @@
811814
},
812815
"redirect": {
813816
"$ref": "#/definitions/workspacekinds.OptionRedirect"
814-
},
815-
"workspacesCount": {
816-
"type": "integer"
817817
}
818818
}
819819
},
@@ -894,6 +894,9 @@
894894
"workspacekinds.WorkspaceKind": {
895895
"type": "object",
896896
"properties": {
897+
"clusterMetrics": {
898+
"$ref": "#/definitions/workspacekinds.clusterMetrics"
899+
},
897900
"deprecated": {
898901
"type": "boolean"
899902
},
@@ -920,7 +923,12 @@
920923
},
921924
"podTemplate": {
922925
"$ref": "#/definitions/workspacekinds.PodTemplate"
923-
},
926+
}
927+
}
928+
},
929+
"workspacekinds.clusterMetrics": {
930+
"type": "object",
931+
"properties": {
924932
"workspacesCount": {
925933
"type": "integer"
926934
}

workspaces/backend/openapi/swagger.yaml

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ definitions:
126126
type: object
127127
workspacekinds.ImageConfigValue:
128128
properties:
129+
clusterMetrics:
130+
$ref: '#/definitions/workspacekinds.clusterMetrics'
129131
description:
130132
type: string
131133
displayName:
@@ -140,8 +142,6 @@ definitions:
140142
type: array
141143
redirect:
142144
$ref: '#/definitions/workspacekinds.OptionRedirect'
143-
workspacesCount:
144-
type: integer
145145
type: object
146146
workspacekinds.ImageRef:
147147
properties:
@@ -173,6 +173,8 @@ definitions:
173173
type: object
174174
workspacekinds.PodConfigValue:
175175
properties:
176+
clusterMetrics:
177+
$ref: '#/definitions/workspacekinds.clusterMetrics'
176178
description:
177179
type: string
178180
displayName:
@@ -187,8 +189,6 @@ definitions:
187189
type: array
188190
redirect:
189191
$ref: '#/definitions/workspacekinds.OptionRedirect'
190-
workspacesCount:
191-
type: integer
192192
type: object
193193
workspacekinds.PodMetadata:
194194
properties:
@@ -241,6 +241,8 @@ definitions:
241241
- RedirectMessageLevelDanger
242242
workspacekinds.WorkspaceKind:
243243
properties:
244+
clusterMetrics:
245+
$ref: '#/definitions/workspacekinds.clusterMetrics'
244246
deprecated:
245247
type: boolean
246248
deprecationMessage:
@@ -259,6 +261,9 @@ definitions:
259261
type: string
260262
podTemplate:
261263
$ref: '#/definitions/workspacekinds.PodTemplate'
264+
type: object
265+
workspacekinds.clusterMetrics:
266+
properties:
262267
workspacesCount:
263268
type: integer
264269
type: object

0 commit comments

Comments
 (0)