From 365c44bef2d20efcaa99f606c2bcc765502ef7ab Mon Sep 17 00:00:00 2001 From: Eder Ignatowicz Date: Mon, 24 Feb 2025 01:40:46 -0500 Subject: [PATCH] feat(ws): update JSON field names to camelCase in types and README. (#214) Signed-off-by: Eder Ignatowicz --- workspaces/backend/README.md | 16 +++---- .../internal/models/health_check/types.go | 2 +- .../internal/models/workspacekinds/types.go | 14 +++---- .../internal/models/workspaces/types.go | 42 +++++++++---------- .../models/workspaces/types_create.go | 26 ++++++------ 5 files changed, 50 insertions(+), 50 deletions(-) diff --git a/workspaces/backend/README.md b/workspaces/backend/README.md index eb088313..04015d1f 100644 --- a/workspaces/backend/README.md +++ b/workspaces/backend/README.md @@ -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" }, @@ -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" } } } diff --git a/workspaces/backend/internal/models/health_check/types.go b/workspaces/backend/internal/models/health_check/types.go index 0105a078..8f33a409 100644 --- a/workspaces/backend/internal/models/health_check/types.go +++ b/workspaces/backend/internal/models/health_check/types.go @@ -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 { diff --git a/workspaces/backend/internal/models/workspacekinds/types.go b/workspaces/backend/internal/models/workspacekinds/types.go index ec30a7bf..c7947ea8 100644 --- a/workspaces/backend/internal/models/workspacekinds/types.go +++ b/workspaces/backend/internal/models/workspacekinds/types.go @@ -18,14 +18,14 @@ 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 { @@ -33,8 +33,8 @@ type ImageRef struct { } 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"` } @@ -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 { diff --git a/workspaces/backend/internal/models/workspaces/types.go b/workspaces/backend/internal/models/workspaces/types.go index b33d8457..752965b6 100644 --- a/workspaces/backend/internal/models/workspaces/types.go +++ b/workspaces/backend/internal/models/workspaces/types.go @@ -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"` } @@ -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"` } @@ -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"` } @@ -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"` } @@ -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"` } diff --git a/workspaces/backend/internal/models/workspaces/types_create.go b/workspaces/backend/internal/models/workspaces/types_create.go index bdc60d7a..19734a4e 100644 --- a/workspaces/backend/internal/models/workspaces/types_create.go +++ b/workspaces/backend/internal/models/workspaces/types_create.go @@ -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"` } @@ -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. @@ -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