From 32f6973cbd08d4a0b67cb93bd3027baa84455db4 Mon Sep 17 00:00:00 2001 From: yy <56745951+lingdie@users.noreply.github.com> Date: Wed, 23 Oct 2024 16:02:25 +0800 Subject: [PATCH] feat: add runtime version and state. (#5169) * feat: add jwt secret in devbox secret. * add runtime version and state. --- .../devbox/api/v1alpha1/runtime_types.go | 22 ++++++++++++++++-- .../crd/bases/devbox.sealos.io_runtimes.yaml | 23 ++++++++++++++++++- .../devbox/deploy/manifests/deploy.yaml.tmpl | 23 ++++++++++++++++++- 3 files changed, 64 insertions(+), 4 deletions(-) diff --git a/controllers/devbox/api/v1alpha1/runtime_types.go b/controllers/devbox/api/v1alpha1/runtime_types.go index cf1e6bf8045..52791dbf79b 100644 --- a/controllers/devbox/api/v1alpha1/runtime_types.go +++ b/controllers/devbox/api/v1alpha1/runtime_types.go @@ -72,12 +72,19 @@ type Component struct { Version string `json:"version"` } +type RuntimeState string + +const ( + RuntimeStateActive RuntimeState = "active" + RuntimeStateDeprecated RuntimeState = "deprecated" +) + // RuntimeSpec defines the desired state of Runtime type RuntimeSpec struct { - // +kubebuilder:validation:Required - Version string `json:"version"` // +kubebuilder:validation:Required ClassRef string `json:"classRef"` + // +kubebuilder:validation:Required + Version string `json:"version"` // +kubebuilder:validation:Optional Components []Component `json:"components,omitempty"` @@ -88,6 +95,13 @@ type RuntimeSpec struct { // +kubebuilder:validation:Required Config Config `json:"config"` + + // +kubebuilder:validation:Optional + RuntimeVersion string `json:"runtimeVersion,omitempty"` + // +kubebuilder:validation:Optional + // +kubebuilder:validation:Enum=active;deprecated + // +kubebuilder:default=active + State RuntimeState `json:"state,omitempty"` } // RuntimeStatus defines the observed state of Runtime @@ -98,6 +112,10 @@ type RuntimeStatus struct { // +kubebuilder:object:root=true // +kubebuilder:subresource:status +// +kubebuilder:printcolumn:name="Class",type=string,JSONPath=`.spec.classRef` +// +kubebuilder:printcolumn:name="Version",type=string,JSONPath=`.spec.version` +// +kubebuilder:printcolumn:name="RuntimeVersion",type=string,JSONPath=`.spec.runtimeVersion` +// +kubebuilder:printcolumn:name="State",type=string,JSONPath=`.spec.state` // Runtime is the Schema for the runtimes API type Runtime struct { diff --git a/controllers/devbox/config/crd/bases/devbox.sealos.io_runtimes.yaml b/controllers/devbox/config/crd/bases/devbox.sealos.io_runtimes.yaml index bfaaa6eccbf..00ed31895c3 100644 --- a/controllers/devbox/config/crd/bases/devbox.sealos.io_runtimes.yaml +++ b/controllers/devbox/config/crd/bases/devbox.sealos.io_runtimes.yaml @@ -28,7 +28,20 @@ spec: singular: runtime scope: Namespaced versions: - - name: v1alpha1 + - additionalPrinterColumns: + - jsonPath: .spec.classRef + name: Class + type: string + - jsonPath: .spec.version + name: Version + type: string + - jsonPath: .spec.runtimeVersion + name: RuntimeVersion + type: string + - jsonPath: .spec.state + name: State + type: string + name: v1alpha1 schema: openAPIV3Schema: description: Runtime is the Schema for the runtimes API @@ -2002,6 +2015,14 @@ spec: type: object description: type: string + runtimeVersion: + type: string + state: + default: active + enum: + - active + - deprecated + type: string version: type: string required: diff --git a/controllers/devbox/deploy/manifests/deploy.yaml.tmpl b/controllers/devbox/deploy/manifests/deploy.yaml.tmpl index 92d3b7c6a9d..7286e29b5b8 100644 --- a/controllers/devbox/deploy/manifests/deploy.yaml.tmpl +++ b/controllers/devbox/deploy/manifests/deploy.yaml.tmpl @@ -3129,7 +3129,20 @@ spec: singular: runtime scope: Namespaced versions: - - name: v1alpha1 + - additionalPrinterColumns: + - jsonPath: .spec.classRef + name: Class + type: string + - jsonPath: .spec.version + name: Version + type: string + - jsonPath: .spec.runtimeVersion + name: RuntimeVersion + type: string + - jsonPath: .spec.state + name: State + type: string + name: v1alpha1 schema: openAPIV3Schema: description: Runtime is the Schema for the runtimes API @@ -5103,6 +5116,14 @@ spec: type: object description: type: string + runtimeVersion: + type: string + state: + default: active + enum: + - active + - deprecated + type: string version: type: string required: