Skip to content

Commit

Permalink
feat(ws): update JSON field names to camelCase in types and README. (#…
Browse files Browse the repository at this point in the history
…214)

Signed-off-by: Eder Ignatowicz <ignatowicz@gmail.com>
  • Loading branch information
ederign authored Feb 24, 2025
1 parent b981275 commit 365c44b
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 50 deletions.
16 changes: 8 additions & 8 deletions workspaces/backend/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ curl -X POST http://localhost:4000/api/v1/workspaces/default \
"name": "dora",
"kind": "jupyterlab",
"paused": false,
"defer_updates": false,
"pod_template": {
"pod_metadata": {
"deferUpdates": false,
"podTemplate": {
"podMetadata": {
"labels": {
"app": "dora"
},
Expand All @@ -105,15 +105,15 @@ curl -X POST http://localhost:4000/api/v1/workspaces/default \
"home": "workspace-home-bella",
"data": [
{
"pvc_name": "workspace-data-bella",
"mount_path": "/data/my-data",
"read_only": false
"pvcName": "workspace-data-bella",
"mountPath": "/data/my-data",
"readOnly": false
}
]
},
"options": {
"image_config": "jupyterlab_scipy_190",
"pod_config": "tiny_cpu"
"imageConfig": "jupyterlab_scipy_190",
"podConfig": "tiny_cpu"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion workspaces/backend/internal/models/health_check/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ package health_check

type HealthCheck struct {
Status ServiceStatus `json:"status"`
SystemInfo SystemInfo `json:"system_info"`
SystemInfo SystemInfo `json:"systemInfo"`
}

type SystemInfo struct {
Expand Down
14 changes: 7 additions & 7 deletions workspaces/backend/internal/models/workspacekinds/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,23 @@ package workspacekinds

type WorkspaceKind struct {
Name string `json:"name"`
DisplayName string `json:"display_name"`
DisplayName string `json:"displayName"`
Description string `json:"description"`
Deprecated bool `json:"deprecated"`
DeprecationMessage string `json:"deprecation_message"`
DeprecationMessage string `json:"deprecationMessage"`
Hidden bool `json:"hidden"`
Icon ImageRef `json:"icon"`
Logo ImageRef `json:"logo"`
PodTemplate PodTemplate `json:"pod_template"`
PodTemplate PodTemplate `json:"podTemplate"`
}

type ImageRef struct {
URL string `json:"url"`
}

type PodTemplate struct {
PodMetadata PodMetadata `json:"pod_metadata"`
VolumeMounts PodVolumeMounts `json:"volume_mounts"`
PodMetadata PodMetadata `json:"podMetadata"`
VolumeMounts PodVolumeMounts `json:"volumeMounts"`
Options PodTemplateOptions `json:"options"`
}

Expand All @@ -48,8 +48,8 @@ type PodVolumeMounts struct {
}

type PodTemplateOptions struct {
ImageConfig ImageConfig `json:"image_config"`
PodConfig PodConfig `json:"pod_config"`
ImageConfig ImageConfig `json:"imageConfig"`
PodConfig PodConfig `json:"podConfig"`
}

type ImageConfig struct {
Expand Down
42 changes: 21 additions & 21 deletions workspaces/backend/internal/models/workspaces/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ package workspaces
type Workspace struct {
Name string `json:"name"`
Namespace string `json:"namespace"`
WorkspaceKind WorkspaceKindInfo `json:"workspace_kind"`
DeferUpdates bool `json:"defer_updates"`
WorkspaceKind WorkspaceKindInfo `json:"workspaceKind"`
DeferUpdates bool `json:"deferUpdates"`
Paused bool `json:"paused"`
PausedTime int64 `json:"paused_time"`
PausedTime int64 `json:"pausedTime"`
State WorkspaceState `json:"state"`
StateMessage string `json:"state_message"`
PodTemplate PodTemplate `json:"pod_template"`
StateMessage string `json:"stateMessage"`
PodTemplate PodTemplate `json:"podTemplate"`
Activity Activity `json:"activity"`
}

Expand All @@ -54,7 +54,7 @@ type ImageRef struct {
}

type PodTemplate struct {
PodMetadata PodMetadata `json:"pod_metadata"`
PodMetadata PodMetadata `json:"podMetadata"`
Volumes PodVolumes `json:"volumes"`
Options PodTemplateOptions `json:"options"`
}
Expand All @@ -70,31 +70,31 @@ type PodVolumes struct {
}

type PodVolumeInfo struct {
PVCName string `json:"pvc_name"`
MountPath string `json:"mount_path"`
ReadOnly bool `json:"read_only"`
PVCName string `json:"pvcName"`
MountPath string `json:"mountPath"`
ReadOnly bool `json:"readOnly"`
}

type PodTemplateOptions struct {
ImageConfig ImageConfig `json:"image_config"`
PodConfig PodConfig `json:"pod_config"`
ImageConfig ImageConfig `json:"imageConfig"`
PodConfig PodConfig `json:"podConfig"`
}

type ImageConfig struct {
Current OptionInfo `json:"current"`
Desired *OptionInfo `json:"desired,omitempty"`
RedirectChain []RedirectStep `json:"redirect_chain,omitempty"`
RedirectChain []RedirectStep `json:"redirectChain,omitempty"`
}

type PodConfig struct {
Current OptionInfo `json:"current"`
Desired *OptionInfo `json:"desired,omitempty"`
RedirectChain []RedirectStep `json:"redirect_chain,omitempty"`
RedirectChain []RedirectStep `json:"redirectChain,omitempty"`
}

type OptionInfo struct {
Id string `json:"id"`
DisplayName string `json:"display_name"`
DisplayName string `json:"displayName"`
Description string `json:"description"`
Labels []OptionLabel `json:"labels"`
}
Expand All @@ -105,8 +105,8 @@ type OptionLabel struct {
}

type RedirectStep struct {
SourceId string `json:"source_id"`
TargetId string `json:"target_id"`
SourceId string `json:"sourceId"`
TargetId string `json:"targetId"`
Message *RedirectMessage `json:"message,omitempty"`
}

Expand All @@ -124,14 +124,14 @@ const (
)

type Activity struct {
LastActivity int64 `json:"last_activity"` // Unix Epoch time
LastUpdate int64 `json:"last_update"` // Unix Epoch time
LastProbe *LastProbeInfo `json:"last_probe,omitempty"`
LastActivity int64 `json:"lastActivity"` // Unix Epoch time
LastUpdate int64 `json:"lastUpdate"` // Unix Epoch time
LastProbe *LastProbeInfo `json:"lastProbe,omitempty"`
}

type LastProbeInfo struct {
StartTimeMs int64 `json:"start_time_ms"` // Unix Epoch time in milliseconds
EndTimeMs int64 `json:"end_time_ms"` // Unix Epoch time in milliseconds
StartTimeMs int64 `json:"startTimeMs"` // Unix Epoch time in milliseconds
EndTimeMs int64 `json:"endTimeMs"` // Unix Epoch time in milliseconds
Result ProbeResult `json:"result"`
Message string `json:"message"`
}
Expand Down
26 changes: 13 additions & 13 deletions workspaces/backend/internal/models/workspaces/types_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ type WorkspaceCreate struct {
Name string `json:"name"`
Kind string `json:"kind"`
Paused bool `json:"paused"`
DeferUpdates bool `json:"defer_updates"`
PodTemplate PodTemplateMutate `json:"pod_template"`
DeferUpdates bool `json:"deferUpdates"`
PodTemplate PodTemplateMutate `json:"podTemplate"`
}

type PodTemplateMutate struct {
PodMetadata PodMetadataMutate `json:"pod_metadata"`
PodMetadata PodMetadataMutate `json:"podMetadata"`
Volumes PodVolumesMutate `json:"volumes"`
Options PodTemplateOptionsMutate `json:"options"`
}
Expand All @@ -48,14 +48,14 @@ type PodVolumesMutate struct {
}

type PodVolumeMount struct {
PVCName string `json:"pvc_name"`
MountPath string `json:"mount_path"`
ReadOnly bool `json:"read_only,omitempty"`
PVCName string `json:"pvcName"`
MountPath string `json:"mountPath"`
ReadOnly bool `json:"readOnly,omitempty"`
}

type PodTemplateOptionsMutate struct {
ImageConfig string `json:"image_config"`
PodConfig string `json:"pod_config"`
ImageConfig string `json:"imageConfig"`
PodConfig string `json:"podConfig"`
}

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

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

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

// validate the data volumes
dataVolumesPath := prefix.Child("pod_template", "volumes", "data")
dataVolumesPath := prefix.Child("podTemplate", "volumes", "data")
for i, volume := range w.PodTemplate.Volumes.Data {
volumePath := dataVolumesPath.Index(i)
errs = append(errs, helper.ValidateFieldIsNotEmpty(volumePath.Child("pvc_name"), volume.PVCName)...)
errs = append(errs, helper.ValidateFieldIsNotEmpty(volumePath.Child("mount_path"), volume.MountPath)...)
errs = append(errs, helper.ValidateFieldIsNotEmpty(volumePath.Child("pvcName"), volume.PVCName)...)
errs = append(errs, helper.ValidateFieldIsNotEmpty(volumePath.Child("mountPath"), volume.MountPath)...)
}

return errs
Expand Down

0 comments on commit 365c44b

Please # to comment.