forked from wrenn/wrenn
Refactored to maintain a separate cloud version
Moves 12 packages from internal/ to pkg/ (config, id, validate, events, db, auth, lifecycle, scheduler, channels, audit, service) so they can be imported by the enterprise repo as a Go module dependency. Introduces pkg/cpextension (shared Extension interface + ServerContext) and pkg/cpserver (Run() entrypoint with functional options) so the enterprise main.go can call cpserver.Run(cpserver.WithExtensions(...)) without duplicating the 20-step server bootstrap. Adds db/migrations/embed.go for go:embed access to OSS SQL migrations from the enterprise module. cmd/control-plane/main.go is reduced to a 10-line wrapper around cpserver.Run.
This commit is contained in:
9
db/migrations/20260415134310_add_metadata.sql
Normal file
9
db/migrations/20260415134310_add_metadata.sql
Normal file
@ -0,0 +1,9 @@
|
||||
-- +goose Up
|
||||
ALTER TABLE sandboxes ADD COLUMN metadata JSONB NOT NULL DEFAULT '{}';
|
||||
ALTER TABLE templates ADD COLUMN metadata JSONB NOT NULL DEFAULT '{}';
|
||||
ALTER TABLE template_builds ADD COLUMN metadata JSONB NOT NULL DEFAULT '{}';
|
||||
|
||||
-- +goose Down
|
||||
ALTER TABLE sandboxes DROP COLUMN metadata;
|
||||
ALTER TABLE templates DROP COLUMN metadata;
|
||||
ALTER TABLE template_builds DROP COLUMN metadata;
|
||||
10
db/migrations/embed.go
Normal file
10
db/migrations/embed.go
Normal file
@ -0,0 +1,10 @@
|
||||
// Package migrations embeds the SQL migration files so that external modules
|
||||
// (such as the enterprise edition) can access them programmatically.
|
||||
package migrations
|
||||
|
||||
import "embed"
|
||||
|
||||
// FS contains all SQL migration files.
|
||||
//
|
||||
//go:embed *.sql
|
||||
var FS embed.FS
|
||||
@ -1,6 +1,6 @@
|
||||
-- name: InsertSandbox :one
|
||||
INSERT INTO sandboxes (id, team_id, host_id, template, status, vcpus, memory_mb, timeout_sec, disk_size_mb, template_id, template_team_id)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)
|
||||
INSERT INTO sandboxes (id, team_id, host_id, template, status, vcpus, memory_mb, timeout_sec, disk_size_mb, template_id, template_team_id, metadata)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12)
|
||||
RETURNING *;
|
||||
|
||||
-- name: GetSandbox :one
|
||||
@ -74,6 +74,12 @@ SET status = 'missing',
|
||||
last_updated = NOW()
|
||||
WHERE host_id = $1 AND status IN ('running', 'starting', 'pending');
|
||||
|
||||
-- name: UpdateSandboxMetadata :exec
|
||||
UPDATE sandboxes
|
||||
SET metadata = $2,
|
||||
last_updated = NOW()
|
||||
WHERE id = $1;
|
||||
|
||||
-- name: BulkRestoreRunning :exec
|
||||
-- Called by the reconciler when a host comes back online and its sandboxes are
|
||||
-- confirmed alive. Restores only sandboxes that are in 'missing' state.
|
||||
|
||||
@ -34,5 +34,5 @@ WHERE id = $1;
|
||||
|
||||
-- name: UpdateBuildDefaults :exec
|
||||
UPDATE template_builds
|
||||
SET default_user = $2, default_env = $3
|
||||
SET default_user = $2, default_env = $3, metadata = $4
|
||||
WHERE id = $1;
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
-- name: InsertTemplate :one
|
||||
INSERT INTO templates (id, name, type, vcpus, memory_mb, size_bytes, team_id, default_user, default_env)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9)
|
||||
INSERT INTO templates (id, name, type, vcpus, memory_mb, size_bytes, team_id, default_user, default_env, metadata)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10)
|
||||
RETURNING *;
|
||||
|
||||
-- name: GetTemplate :one
|
||||
|
||||
Reference in New Issue
Block a user