Skip to content

Commit

Permalink
feat: add jwt secret in devbox secret.
Browse files Browse the repository at this point in the history
  • Loading branch information
lingdie committed Oct 22, 2024
1 parent e2cf303 commit 1027c55
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions controllers/devbox/internal/controller/devbox_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,15 @@ func (r *DevboxReconciler) syncSecret(ctx context.Context, devbox *devboxv1alpha
err := r.Get(ctx, client.ObjectKey{Namespace: devbox.Namespace, Name: devbox.Name}, devboxSecret)
if err == nil {
// Secret already exists, no need to create

// TODO: delete this code after we have a way to sync secret to devbox
// check if SEALOS_DEVBOX_JWT_SECRET is exist, if not exist, create it
if _, ok := devboxSecret.Data["SEALOS_DEVBOX_JWT_SECRET"]; !ok {
devboxSecret.Data["SEALOS_DEVBOX_JWT_SECRET"] = []byte(rand.String(32))
if err := r.Update(ctx, devboxSecret); err != nil {
return fmt.Errorf("failed to update secret: %w", err)
}
}
return nil
}
if client.IgnoreNotFound(err) != nil {
Expand All @@ -186,6 +195,7 @@ func (r *DevboxReconciler) syncSecret(ctx context.Context, devbox *devboxv1alpha
ObjectMeta: objectMeta,
Data: map[string][]byte{
"SEALOS_DEVBOX_PASSWORD": []byte(rand.String(12)),
"SEALOS_DEVBOX_JWT_SECRET": []byte(rand.String(32)),
"SEALOS_DEVBOX_PUBLIC_KEY": publicKey,
"SEALOS_DEVBOX_PRIVATE_KEY": privateKey,
},
Expand Down

0 comments on commit 1027c55

Please sign in to comment.