Skip to content

Commit

Permalink
fix devbox get runtime. (#5030)
Browse files Browse the repository at this point in the history
Signed-off-by: yy <[email protected]>
  • Loading branch information
lingdie authored Sep 3, 2024
1 parent 306bbda commit 4e13ab5
Show file tree
Hide file tree
Showing 9 changed files with 281 additions and 236 deletions.
2 changes: 2 additions & 0 deletions controllers/devbox/api/v1alpha1/devbox_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ type ResourceList map[ResourceName]resource.Quantity
type RuntimeRef struct {
// +kubebuilder:validation:Required
Name string `json:"name"`
// +kubebuilder:validation:Required
Namespace string `json:"namespace"`
}

type NetworkSpec struct {
Expand Down
4 changes: 4 additions & 0 deletions controllers/devbox/api/v1alpha1/devboxrelease_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ const (
DevboxReleasePhaseFailed DevboxReleasePhase = "Failed"
)

// +kubebuilder:printcolumn:name="DevboxName",type="string",JSONPath=".spec.devboxName"
// +kubebuilder:printcolumn:name="NewTag",type="string",JSONPath=".spec.newTag"
// +kubebuilder:printcolumn:name="Phase",type="string",JSONPath=".status.phase"

// DevBoxReleaseStatus defines the observed state of DevBoxRelease
type DevBoxReleaseStatus struct {
// +kubebuilder:validation:Optional
Expand Down
255 changes: 129 additions & 126 deletions controllers/devbox/config/crd/bases/devbox.sealos.io_devboxes.yaml

Large diffs are not rendered by default.

158 changes: 79 additions & 79 deletions controllers/devbox/config/crd/bases/devbox.sealos.io_runtimes.yaml

Large diffs are not rendered by default.

50 changes: 25 additions & 25 deletions controllers/devbox/config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ rules:
- apiGroups:
- ""
resources:
- events
- events
verbs:
- '*'
- '*'
- apiGroups:
- ""
- ""
resources:
- pods
- pods
verbs:
- '*'
- '*'
- apiGroups:
- ""
resources:
Expand All @@ -43,13 +43,13 @@ rules:
resources:
- secrets
verbs:
- '*'
- '*'
- apiGroups:
- ""
resources:
- services
verbs:
- '*'
- '*'
- apiGroups:
- devbox.sealos.io
resources:
Expand Down Expand Up @@ -103,26 +103,26 @@ rules:
- patch
- update
- apiGroups:
- devbox.sealos.io
- devbox.sealos.io
resources:
- runtimeclasses
- runtimeclasses
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- devbox.sealos.io
- devbox.sealos.io
resources:
- runtimes
- runtimes
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- create
- delete
- get
- list
- patch
- update
- watch
12 changes: 8 additions & 4 deletions controllers/devbox/config/samples/devbox_v1alpha1_runtime.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ apiVersion: devbox.sealos.io/v1alpha1
kind: Runtime
metadata:
name: go-1-22-5
namespace: devbox-system
spec:
classRef: go
title: go1.22.5
description: go1.22.5
config:
image: ghcr.io/cbluebird/devbox/go1.22.5:9259f1
image: ghcr.io/cbluebird/devbox/go1.22.5:2f4067
category:
- ubuntu
- go
Expand All @@ -30,12 +31,13 @@ apiVersion: devbox.sealos.io/v1alpha1
kind: Runtime
metadata:
name: go-1-23-0
namespace: devbox-system
spec:
classRef: go
title: go1.23.0
description: go1.23.0
config:
image: ghcr.io/cbluebird/devbox/go1.23.0:9259f1
image: ghcr.io/cbluebird/devbox/go1.23.0:2f4067
category:
- ubuntu
- go
Expand All @@ -44,12 +46,13 @@ apiVersion: devbox.sealos.io/v1alpha1
kind: Runtime
metadata:
name: gin
namespace: devbox-system
spec:
classRef: gin
title: gin
description: gin
config:
image: ghcr.io/cbluebird/devbox/gin:9259f1
image: ghcr.io/cbluebird/devbox/gin:2f4067
category:
- ubuntu
- go
Expand All @@ -59,12 +62,13 @@ apiVersion: devbox.sealos.io/v1alpha1
kind: Runtime
metadata:
name: spring-boot
namespace: devbox-system
spec:
classRef: spring-boot
title: Spring Boot
description: Spring Boot
config:
image: ghcr.io/cbluebird/devbox/spring-boot:9259f1
image: ghcr.io/cbluebird/devbox/spring-boot:2f4067
category:
- ubuntu
- java
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ apiVersion: devbox.sealos.io/v1alpha1
kind: RuntimeClass
metadata:
name: go
namespace: devbox-system
spec:
kind: Language
title: go
Expand All @@ -25,6 +26,7 @@ apiVersion: devbox.sealos.io/v1alpha1
kind: RuntimeClass
metadata:
name: gin
namespace: devbox-system
spec:
kind: Framework
title: gin
Expand All @@ -34,6 +36,7 @@ apiVersion: devbox.sealos.io/v1alpha1
kind: RuntimeClass
metadata:
name: java
namespace: devbox-system
spec:
kind: Language
title: java
Expand All @@ -43,6 +46,7 @@ apiVersion: devbox.sealos.io/v1alpha1
kind: RuntimeClass
metadata:
name: spring-boot
namespace: devbox-system
spec:
kind: Framework
title: Spring Boot
Expand All @@ -52,6 +56,7 @@ apiVersion: devbox.sealos.io/v1alpha1
kind: RuntimeClass
metadata:
name: python
namespace: devbox-system
spec:
kind: Language
title: python
Expand All @@ -61,6 +66,7 @@ apiVersion: devbox.sealos.io/v1alpha1
kind: RuntimeClass
metadata:
name: nodejs
namespace: devbox-system
spec:
kind: Language
title: node.js
Expand Down
28 changes: 27 additions & 1 deletion controllers/devbox/deploy/manifests/deploy.yaml.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -2673,8 +2673,11 @@ spec:
properties:
name:
type: string
namespace:
type: string
required:
- name
- namespace
type: object
squash:
default: false
Expand Down Expand Up @@ -2725,7 +2728,6 @@ spec:
workingDir:
type: string
required:
- network
- resource
- runtimeRef
- state
Expand Down Expand Up @@ -5093,6 +5095,30 @@ rules:
- get
- patch
- update
- apiGroups:
- devbox.sealos.io
resources:
- runtimeclasses
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- devbox.sealos.io
resources:
- runtimes
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func (r *DevboxReconciler) syncPod(ctx context.Context, devbox *devboxv1alpha1.D
return fmt.Errorf("more than one pod found")
}
runtime := &devboxv1alpha1.Runtime{}
if err := r.Get(ctx, client.ObjectKey{Namespace: devbox.Namespace, Name: devbox.Spec.RuntimeRef.Name}, runtime); err != nil {
if err := r.Get(ctx, client.ObjectKey{Namespace: devbox.Spec.RuntimeRef.Namespace, Name: devbox.Spec.RuntimeRef.Name}, runtime); err != nil {
return err
}

Expand Down

0 comments on commit 4e13ab5

Please sign in to comment.