feat(ws): update JSON field names to camelCase in types and README. (#214)

Signed-off-by: Eder Ignatowicz <ignatowicz@gmail.com>
This commit is contained in:
Eder Ignatowicz 2025-02-24 01:40:46 -05:00 committed by GitHub
parent b981275b81
commit 365c44bef2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 50 additions and 50 deletions

View File

@ -91,9 +91,9 @@ curl -X POST http://localhost:4000/api/v1/workspaces/default \
"name": "dora", "name": "dora",
"kind": "jupyterlab", "kind": "jupyterlab",
"paused": false, "paused": false,
"defer_updates": false, "deferUpdates": false,
"pod_template": { "podTemplate": {
"pod_metadata": { "podMetadata": {
"labels": { "labels": {
"app": "dora" "app": "dora"
}, },
@ -105,15 +105,15 @@ curl -X POST http://localhost:4000/api/v1/workspaces/default \
"home": "workspace-home-bella", "home": "workspace-home-bella",
"data": [ "data": [
{ {
"pvc_name": "workspace-data-bella", "pvcName": "workspace-data-bella",
"mount_path": "/data/my-data", "mountPath": "/data/my-data",
"read_only": false "readOnly": false
} }
] ]
}, },
"options": { "options": {
"image_config": "jupyterlab_scipy_190", "imageConfig": "jupyterlab_scipy_190",
"pod_config": "tiny_cpu" "podConfig": "tiny_cpu"
} }
} }
} }

View File

@ -18,7 +18,7 @@ package health_check
type HealthCheck struct { type HealthCheck struct {
Status ServiceStatus `json:"status"` Status ServiceStatus `json:"status"`
SystemInfo SystemInfo `json:"system_info"` SystemInfo SystemInfo `json:"systemInfo"`
} }
type SystemInfo struct { type SystemInfo struct {

View File

@ -18,14 +18,14 @@ package workspacekinds
type WorkspaceKind struct { type WorkspaceKind struct {
Name string `json:"name"` Name string `json:"name"`
DisplayName string `json:"display_name"` DisplayName string `json:"displayName"`
Description string `json:"description"` Description string `json:"description"`
Deprecated bool `json:"deprecated"` Deprecated bool `json:"deprecated"`
DeprecationMessage string `json:"deprecation_message"` DeprecationMessage string `json:"deprecationMessage"`
Hidden bool `json:"hidden"` Hidden bool `json:"hidden"`
Icon ImageRef `json:"icon"` Icon ImageRef `json:"icon"`
Logo ImageRef `json:"logo"` Logo ImageRef `json:"logo"`
PodTemplate PodTemplate `json:"pod_template"` PodTemplate PodTemplate `json:"podTemplate"`
} }
type ImageRef struct { type ImageRef struct {
@ -33,8 +33,8 @@ type ImageRef struct {
} }
type PodTemplate struct { type PodTemplate struct {
PodMetadata PodMetadata `json:"pod_metadata"` PodMetadata PodMetadata `json:"podMetadata"`
VolumeMounts PodVolumeMounts `json:"volume_mounts"` VolumeMounts PodVolumeMounts `json:"volumeMounts"`
Options PodTemplateOptions `json:"options"` Options PodTemplateOptions `json:"options"`
} }
@ -48,8 +48,8 @@ type PodVolumeMounts struct {
} }
type PodTemplateOptions struct { type PodTemplateOptions struct {
ImageConfig ImageConfig `json:"image_config"` ImageConfig ImageConfig `json:"imageConfig"`
PodConfig PodConfig `json:"pod_config"` PodConfig PodConfig `json:"podConfig"`
} }
type ImageConfig struct { type ImageConfig struct {

View File

@ -21,13 +21,13 @@ package workspaces
type Workspace struct { type Workspace struct {
Name string `json:"name"` Name string `json:"name"`
Namespace string `json:"namespace"` Namespace string `json:"namespace"`
WorkspaceKind WorkspaceKindInfo `json:"workspace_kind"` WorkspaceKind WorkspaceKindInfo `json:"workspaceKind"`
DeferUpdates bool `json:"defer_updates"` DeferUpdates bool `json:"deferUpdates"`
Paused bool `json:"paused"` Paused bool `json:"paused"`
PausedTime int64 `json:"paused_time"` PausedTime int64 `json:"pausedTime"`
State WorkspaceState `json:"state"` State WorkspaceState `json:"state"`
StateMessage string `json:"state_message"` StateMessage string `json:"stateMessage"`
PodTemplate PodTemplate `json:"pod_template"` PodTemplate PodTemplate `json:"podTemplate"`
Activity Activity `json:"activity"` Activity Activity `json:"activity"`
} }
@ -54,7 +54,7 @@ type ImageRef struct {
} }
type PodTemplate struct { type PodTemplate struct {
PodMetadata PodMetadata `json:"pod_metadata"` PodMetadata PodMetadata `json:"podMetadata"`
Volumes PodVolumes `json:"volumes"` Volumes PodVolumes `json:"volumes"`
Options PodTemplateOptions `json:"options"` Options PodTemplateOptions `json:"options"`
} }
@ -70,31 +70,31 @@ type PodVolumes struct {
} }
type PodVolumeInfo struct { type PodVolumeInfo struct {
PVCName string `json:"pvc_name"` PVCName string `json:"pvcName"`
MountPath string `json:"mount_path"` MountPath string `json:"mountPath"`
ReadOnly bool `json:"read_only"` ReadOnly bool `json:"readOnly"`
} }
type PodTemplateOptions struct { type PodTemplateOptions struct {
ImageConfig ImageConfig `json:"image_config"` ImageConfig ImageConfig `json:"imageConfig"`
PodConfig PodConfig `json:"pod_config"` PodConfig PodConfig `json:"podConfig"`
} }
type ImageConfig struct { type ImageConfig struct {
Current OptionInfo `json:"current"` Current OptionInfo `json:"current"`
Desired *OptionInfo `json:"desired,omitempty"` Desired *OptionInfo `json:"desired,omitempty"`
RedirectChain []RedirectStep `json:"redirect_chain,omitempty"` RedirectChain []RedirectStep `json:"redirectChain,omitempty"`
} }
type PodConfig struct { type PodConfig struct {
Current OptionInfo `json:"current"` Current OptionInfo `json:"current"`
Desired *OptionInfo `json:"desired,omitempty"` Desired *OptionInfo `json:"desired,omitempty"`
RedirectChain []RedirectStep `json:"redirect_chain,omitempty"` RedirectChain []RedirectStep `json:"redirectChain,omitempty"`
} }
type OptionInfo struct { type OptionInfo struct {
Id string `json:"id"` Id string `json:"id"`
DisplayName string `json:"display_name"` DisplayName string `json:"displayName"`
Description string `json:"description"` Description string `json:"description"`
Labels []OptionLabel `json:"labels"` Labels []OptionLabel `json:"labels"`
} }
@ -105,8 +105,8 @@ type OptionLabel struct {
} }
type RedirectStep struct { type RedirectStep struct {
SourceId string `json:"source_id"` SourceId string `json:"sourceId"`
TargetId string `json:"target_id"` TargetId string `json:"targetId"`
Message *RedirectMessage `json:"message,omitempty"` Message *RedirectMessage `json:"message,omitempty"`
} }
@ -124,14 +124,14 @@ const (
) )
type Activity struct { type Activity struct {
LastActivity int64 `json:"last_activity"` // Unix Epoch time LastActivity int64 `json:"lastActivity"` // Unix Epoch time
LastUpdate int64 `json:"last_update"` // Unix Epoch time LastUpdate int64 `json:"lastUpdate"` // Unix Epoch time
LastProbe *LastProbeInfo `json:"last_probe,omitempty"` LastProbe *LastProbeInfo `json:"lastProbe,omitempty"`
} }
type LastProbeInfo struct { type LastProbeInfo struct {
StartTimeMs int64 `json:"start_time_ms"` // Unix Epoch time in milliseconds StartTimeMs int64 `json:"startTimeMs"` // Unix Epoch time in milliseconds
EndTimeMs int64 `json:"end_time_ms"` // Unix Epoch time in milliseconds EndTimeMs int64 `json:"endTimeMs"` // Unix Epoch time in milliseconds
Result ProbeResult `json:"result"` Result ProbeResult `json:"result"`
Message string `json:"message"` Message string `json:"message"`
} }

View File

@ -27,12 +27,12 @@ type WorkspaceCreate struct {
Name string `json:"name"` Name string `json:"name"`
Kind string `json:"kind"` Kind string `json:"kind"`
Paused bool `json:"paused"` Paused bool `json:"paused"`
DeferUpdates bool `json:"defer_updates"` DeferUpdates bool `json:"deferUpdates"`
PodTemplate PodTemplateMutate `json:"pod_template"` PodTemplate PodTemplateMutate `json:"podTemplate"`
} }
type PodTemplateMutate struct { type PodTemplateMutate struct {
PodMetadata PodMetadataMutate `json:"pod_metadata"` PodMetadata PodMetadataMutate `json:"podMetadata"`
Volumes PodVolumesMutate `json:"volumes"` Volumes PodVolumesMutate `json:"volumes"`
Options PodTemplateOptionsMutate `json:"options"` Options PodTemplateOptionsMutate `json:"options"`
} }
@ -48,14 +48,14 @@ type PodVolumesMutate struct {
} }
type PodVolumeMount struct { type PodVolumeMount struct {
PVCName string `json:"pvc_name"` PVCName string `json:"pvcName"`
MountPath string `json:"mount_path"` MountPath string `json:"mountPath"`
ReadOnly bool `json:"read_only,omitempty"` ReadOnly bool `json:"readOnly,omitempty"`
} }
type PodTemplateOptionsMutate struct { type PodTemplateOptionsMutate struct {
ImageConfig string `json:"image_config"` ImageConfig string `json:"imageConfig"`
PodConfig string `json:"pod_config"` PodConfig string `json:"podConfig"`
} }
// Validate validates the WorkspaceCreate struct. // 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)...) errs = append(errs, helper.ValidateFieldIsDNS1123Subdomain(kindPath, w.Kind)...)
// validate the image config // 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)...) errs = append(errs, helper.ValidateFieldIsNotEmpty(imageConfigPath, w.PodTemplate.Options.ImageConfig)...)
// validate the pod config // 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)...) errs = append(errs, helper.ValidateFieldIsNotEmpty(podConfigPath, w.PodTemplate.Options.PodConfig)...)
// validate the data volumes // 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 { for i, volume := range w.PodTemplate.Volumes.Data {
volumePath := dataVolumesPath.Index(i) volumePath := dataVolumesPath.Index(i)
errs = append(errs, helper.ValidateFieldIsNotEmpty(volumePath.Child("pvc_name"), volume.PVCName)...) errs = append(errs, helper.ValidateFieldIsNotEmpty(volumePath.Child("pvcName"), volume.PVCName)...)
errs = append(errs, helper.ValidateFieldIsNotEmpty(volumePath.Child("mount_path"), volume.MountPath)...) errs = append(errs, helper.ValidateFieldIsNotEmpty(volumePath.Child("mountPath"), volume.MountPath)...)
} }
return errs return errs