Skip to content

Commit 365c44b

Browse files
authored
feat(ws): update JSON field names to camelCase in types and README. (#214)
Signed-off-by: Eder Ignatowicz <ignatowicz@gmail.com>
1 parent b981275 commit 365c44b

File tree

5 files changed

+50
-50
lines changed

5 files changed

+50
-50
lines changed

workspaces/backend/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ curl -X POST http://localhost:4000/api/v1/workspaces/default \
9191
"name": "dora",
9292
"kind": "jupyterlab",
9393
"paused": false,
94-
"defer_updates": false,
95-
"pod_template": {
96-
"pod_metadata": {
94+
"deferUpdates": false,
95+
"podTemplate": {
96+
"podMetadata": {
9797
"labels": {
9898
"app": "dora"
9999
},
@@ -105,15 +105,15 @@ curl -X POST http://localhost:4000/api/v1/workspaces/default \
105105
"home": "workspace-home-bella",
106106
"data": [
107107
{
108-
"pvc_name": "workspace-data-bella",
109-
"mount_path": "/data/my-data",
110-
"read_only": false
108+
"pvcName": "workspace-data-bella",
109+
"mountPath": "/data/my-data",
110+
"readOnly": false
111111
}
112112
]
113113
},
114114
"options": {
115-
"image_config": "jupyterlab_scipy_190",
116-
"pod_config": "tiny_cpu"
115+
"imageConfig": "jupyterlab_scipy_190",
116+
"podConfig": "tiny_cpu"
117117
}
118118
}
119119
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ package health_check
1818

1919
type HealthCheck struct {
2020
Status ServiceStatus `json:"status"`
21-
SystemInfo SystemInfo `json:"system_info"`
21+
SystemInfo SystemInfo `json:"systemInfo"`
2222
}
2323

2424
type SystemInfo struct {

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,23 +18,23 @@ package workspacekinds
1818

1919
type WorkspaceKind struct {
2020
Name string `json:"name"`
21-
DisplayName string `json:"display_name"`
21+
DisplayName string `json:"displayName"`
2222
Description string `json:"description"`
2323
Deprecated bool `json:"deprecated"`
24-
DeprecationMessage string `json:"deprecation_message"`
24+
DeprecationMessage string `json:"deprecationMessage"`
2525
Hidden bool `json:"hidden"`
2626
Icon ImageRef `json:"icon"`
2727
Logo ImageRef `json:"logo"`
28-
PodTemplate PodTemplate `json:"pod_template"`
28+
PodTemplate PodTemplate `json:"podTemplate"`
2929
}
3030

3131
type ImageRef struct {
3232
URL string `json:"url"`
3333
}
3434

3535
type PodTemplate struct {
36-
PodMetadata PodMetadata `json:"pod_metadata"`
37-
VolumeMounts PodVolumeMounts `json:"volume_mounts"`
36+
PodMetadata PodMetadata `json:"podMetadata"`
37+
VolumeMounts PodVolumeMounts `json:"volumeMounts"`
3838
Options PodTemplateOptions `json:"options"`
3939
}
4040

@@ -48,8 +48,8 @@ type PodVolumeMounts struct {
4848
}
4949

5050
type PodTemplateOptions struct {
51-
ImageConfig ImageConfig `json:"image_config"`
52-
PodConfig PodConfig `json:"pod_config"`
51+
ImageConfig ImageConfig `json:"imageConfig"`
52+
PodConfig PodConfig `json:"podConfig"`
5353
}
5454

5555
type ImageConfig struct {

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

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ package workspaces
2121
type Workspace struct {
2222
Name string `json:"name"`
2323
Namespace string `json:"namespace"`
24-
WorkspaceKind WorkspaceKindInfo `json:"workspace_kind"`
25-
DeferUpdates bool `json:"defer_updates"`
24+
WorkspaceKind WorkspaceKindInfo `json:"workspaceKind"`
25+
DeferUpdates bool `json:"deferUpdates"`
2626
Paused bool `json:"paused"`
27-
PausedTime int64 `json:"paused_time"`
27+
PausedTime int64 `json:"pausedTime"`
2828
State WorkspaceState `json:"state"`
29-
StateMessage string `json:"state_message"`
30-
PodTemplate PodTemplate `json:"pod_template"`
29+
StateMessage string `json:"stateMessage"`
30+
PodTemplate PodTemplate `json:"podTemplate"`
3131
Activity Activity `json:"activity"`
3232
}
3333

@@ -54,7 +54,7 @@ type ImageRef struct {
5454
}
5555

5656
type PodTemplate struct {
57-
PodMetadata PodMetadata `json:"pod_metadata"`
57+
PodMetadata PodMetadata `json:"podMetadata"`
5858
Volumes PodVolumes `json:"volumes"`
5959
Options PodTemplateOptions `json:"options"`
6060
}
@@ -70,31 +70,31 @@ type PodVolumes struct {
7070
}
7171

7272
type PodVolumeInfo struct {
73-
PVCName string `json:"pvc_name"`
74-
MountPath string `json:"mount_path"`
75-
ReadOnly bool `json:"read_only"`
73+
PVCName string `json:"pvcName"`
74+
MountPath string `json:"mountPath"`
75+
ReadOnly bool `json:"readOnly"`
7676
}
7777

7878
type PodTemplateOptions struct {
79-
ImageConfig ImageConfig `json:"image_config"`
80-
PodConfig PodConfig `json:"pod_config"`
79+
ImageConfig ImageConfig `json:"imageConfig"`
80+
PodConfig PodConfig `json:"podConfig"`
8181
}
8282

8383
type ImageConfig struct {
8484
Current OptionInfo `json:"current"`
8585
Desired *OptionInfo `json:"desired,omitempty"`
86-
RedirectChain []RedirectStep `json:"redirect_chain,omitempty"`
86+
RedirectChain []RedirectStep `json:"redirectChain,omitempty"`
8787
}
8888

8989
type PodConfig struct {
9090
Current OptionInfo `json:"current"`
9191
Desired *OptionInfo `json:"desired,omitempty"`
92-
RedirectChain []RedirectStep `json:"redirect_chain,omitempty"`
92+
RedirectChain []RedirectStep `json:"redirectChain,omitempty"`
9393
}
9494

9595
type OptionInfo struct {
9696
Id string `json:"id"`
97-
DisplayName string `json:"display_name"`
97+
DisplayName string `json:"displayName"`
9898
Description string `json:"description"`
9999
Labels []OptionLabel `json:"labels"`
100100
}
@@ -105,8 +105,8 @@ type OptionLabel struct {
105105
}
106106

107107
type RedirectStep struct {
108-
SourceId string `json:"source_id"`
109-
TargetId string `json:"target_id"`
108+
SourceId string `json:"sourceId"`
109+
TargetId string `json:"targetId"`
110110
Message *RedirectMessage `json:"message,omitempty"`
111111
}
112112

@@ -124,14 +124,14 @@ const (
124124
)
125125

126126
type Activity struct {
127-
LastActivity int64 `json:"last_activity"` // Unix Epoch time
128-
LastUpdate int64 `json:"last_update"` // Unix Epoch time
129-
LastProbe *LastProbeInfo `json:"last_probe,omitempty"`
127+
LastActivity int64 `json:"lastActivity"` // Unix Epoch time
128+
LastUpdate int64 `json:"lastUpdate"` // Unix Epoch time
129+
LastProbe *LastProbeInfo `json:"lastProbe,omitempty"`
130130
}
131131

132132
type LastProbeInfo struct {
133-
StartTimeMs int64 `json:"start_time_ms"` // Unix Epoch time in milliseconds
134-
EndTimeMs int64 `json:"end_time_ms"` // Unix Epoch time in milliseconds
133+
StartTimeMs int64 `json:"startTimeMs"` // Unix Epoch time in milliseconds
134+
EndTimeMs int64 `json:"endTimeMs"` // Unix Epoch time in milliseconds
135135
Result ProbeResult `json:"result"`
136136
Message string `json:"message"`
137137
}

workspaces/backend/internal/models/workspaces/types_create.go

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,12 @@ type WorkspaceCreate struct {
2727
Name string `json:"name"`
2828
Kind string `json:"kind"`
2929
Paused bool `json:"paused"`
30-
DeferUpdates bool `json:"defer_updates"`
31-
PodTemplate PodTemplateMutate `json:"pod_template"`
30+
DeferUpdates bool `json:"deferUpdates"`
31+
PodTemplate PodTemplateMutate `json:"podTemplate"`
3232
}
3333

3434
type PodTemplateMutate struct {
35-
PodMetadata PodMetadataMutate `json:"pod_metadata"`
35+
PodMetadata PodMetadataMutate `json:"podMetadata"`
3636
Volumes PodVolumesMutate `json:"volumes"`
3737
Options PodTemplateOptionsMutate `json:"options"`
3838
}
@@ -48,14 +48,14 @@ type PodVolumesMutate struct {
4848
}
4949

5050
type PodVolumeMount struct {
51-
PVCName string `json:"pvc_name"`
52-
MountPath string `json:"mount_path"`
53-
ReadOnly bool `json:"read_only,omitempty"`
51+
PVCName string `json:"pvcName"`
52+
MountPath string `json:"mountPath"`
53+
ReadOnly bool `json:"readOnly,omitempty"`
5454
}
5555

5656
type PodTemplateOptionsMutate struct {
57-
ImageConfig string `json:"image_config"`
58-
PodConfig string `json:"pod_config"`
57+
ImageConfig string `json:"imageConfig"`
58+
PodConfig string `json:"podConfig"`
5959
}
6060

6161
// Validate validates the WorkspaceCreate struct.
@@ -72,19 +72,19 @@ func (w *WorkspaceCreate) Validate(prefix *field.Path) []*field.Error {
7272
errs = append(errs, helper.ValidateFieldIsDNS1123Subdomain(kindPath, w.Kind)...)
7373

7474
// validate the image config
75-
imageConfigPath := prefix.Child("pod_template", "options", "image_config")
75+
imageConfigPath := prefix.Child("podTemplate", "options", "imageConfig")
7676
errs = append(errs, helper.ValidateFieldIsNotEmpty(imageConfigPath, w.PodTemplate.Options.ImageConfig)...)
7777

7878
// validate the pod config
79-
podConfigPath := prefix.Child("pod_template", "options", "pod_config")
79+
podConfigPath := prefix.Child("podTemplate", "options", "podConfig")
8080
errs = append(errs, helper.ValidateFieldIsNotEmpty(podConfigPath, w.PodTemplate.Options.PodConfig)...)
8181

8282
// validate the data volumes
83-
dataVolumesPath := prefix.Child("pod_template", "volumes", "data")
83+
dataVolumesPath := prefix.Child("podTemplate", "volumes", "data")
8484
for i, volume := range w.PodTemplate.Volumes.Data {
8585
volumePath := dataVolumesPath.Index(i)
86-
errs = append(errs, helper.ValidateFieldIsNotEmpty(volumePath.Child("pvc_name"), volume.PVCName)...)
87-
errs = append(errs, helper.ValidateFieldIsNotEmpty(volumePath.Child("mount_path"), volume.MountPath)...)
86+
errs = append(errs, helper.ValidateFieldIsNotEmpty(volumePath.Child("pvcName"), volume.PVCName)...)
87+
errs = append(errs, helper.ValidateFieldIsNotEmpty(volumePath.Child("mountPath"), volume.MountPath)...)
8888
}
8989

9090
return errs

0 commit comments

Comments
 (0)