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:
parent
b981275b81
commit
365c44bef2
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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"`
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue