diff --git a/apps/dashboard/lib/audit.ts b/apps/dashboard/lib/audit.ts index bc4de956bb..2a20eaa047 100644 --- a/apps/dashboard/lib/audit.ts +++ b/apps/dashboard/lib/audit.ts @@ -86,7 +86,8 @@ export type UnkeyAuditLog = { | "secret" | "project" | "identity" - | "auditLogBucket"; + | "auditLogBucket" + | "environment"; id: string; name?: string; diff --git a/apps/dashboard/lib/trpc/routers/deploy/project/create.ts b/apps/dashboard/lib/trpc/routers/deploy/project/create.ts index 174698139c..055755dc0b 100644 --- a/apps/dashboard/lib/trpc/routers/deploy/project/create.ts +++ b/apps/dashboard/lib/trpc/routers/deploy/project/create.ts @@ -68,7 +68,6 @@ export const createProject = t.procedure await tx.insert(schema.projects).values({ id: projectId, workspaceId, - partitionId: "part_default", // Default partition for now name: input.name, slug: input.slug, gitRepositoryUrl: input.gitRepositoryUrl || null, @@ -95,6 +94,36 @@ export const createProject = t.procedure userAgent: ctx.audit.userAgent, }, }); + + for (const slug of ["production", "preview"]) { + const environmentId = newId("environment"); + await tx.insert(schema.environments).values({ + id: environmentId, + workspaceId, + projectId, + slug: slug, + }); + await insertAuditLogs(tx, { + workspaceId, + actor: { + type: "user", + id: userId, + }, + event: "environment.create", + description: `Created environment "${slug}" for project "${input.name}"`, + resources: [ + { + type: "environment", + id: environmentId, + name: slug, + }, + ], + context: { + location: ctx.audit.location, + userAgent: ctx.audit.userAgent, + }, + }); + } }); } catch (txErr) { console.error({ diff --git a/apps/dashboard/lib/trpc/routers/deploy/project/list.ts b/apps/dashboard/lib/trpc/routers/deploy/project/list.ts index ab99f7479b..ab16576dca 100644 --- a/apps/dashboard/lib/trpc/routers/deploy/project/list.ts +++ b/apps/dashboard/lib/trpc/routers/deploy/project/list.ts @@ -104,13 +104,13 @@ export const queryProjects = t.procedure queryConditions.push( exists( db - .select({ projectId: schema.routes.projectId }) - .from(schema.routes) + .select({ projectId: schema.domains.projectId }) + .from(schema.domains) .where( and( - eq(schema.routes.workspaceId, ctx.workspace.id), - eq(schema.routes.projectId, schema.projects.id), - like(schema.routes.hostname, searchValue), + eq(schema.domains.workspaceId, ctx.workspace.id), + eq(schema.domains.projectId, schema.projects.id), + like(schema.domains.domain, searchValue), ), ), ), @@ -165,16 +165,16 @@ export const queryProjects = t.procedure // Fetch hostnames for all projects - only .unkey.app domains const hostnamesResult = projectIds.length > 0 - ? await db.query.routes.findMany({ + ? await db.query.domains.findMany({ where: and( - eq(schema.routes.workspaceId, ctx.workspace.id), - inArray(schema.routes.projectId, projectIds), - like(schema.routes.hostname, "%.unkey.app"), + eq(schema.domains.workspaceId, ctx.workspace.id), + inArray(schema.domains.projectId, projectIds), + like(schema.domains.domain, "%.unkey.app"), ), columns: { id: true, projectId: true, - hostname: true, + domain: true, }, orderBy: [desc(schema.projects.updatedAt), desc(schema.projects.createdAt)], }) @@ -183,12 +183,18 @@ export const queryProjects = t.procedure // Group hostnames by projectId const hostnamesByProject = hostnamesResult.reduce( (acc, hostname) => { - if (!acc[hostname.projectId]) { - acc[hostname.projectId] = []; + // Make typescript happy, we already ensure this is the case in the drizzle query + const projectId = hostname.projectId; + if (!projectId) { + return acc; } - acc[hostname.projectId].push({ + + if (!acc[projectId]) { + acc[projectId] = []; + } + acc[projectId].push({ id: hostname.id, - hostname: hostname.hostname, + hostname: hostname.domain, }); return acc; }, diff --git a/apps/dashboard/lib/trpc/routers/deployment/getById.ts b/apps/dashboard/lib/trpc/routers/deployment/getById.ts index d6e238bad2..160a5ff36e 100644 --- a/apps/dashboard/lib/trpc/routers/deployment/getById.ts +++ b/apps/dashboard/lib/trpc/routers/deployment/getById.ts @@ -15,6 +15,9 @@ export const getById = t.procedure try { // Get deployment information const deployment = await db.query.deployments.findFirst({ + with: { + environment: { columns: { slug: true } }, + }, where: (table, { eq, and }) => and(eq(table.id, input.deploymentId), eq(table.workspaceId, ctx.workspace.id)), }); @@ -31,7 +34,7 @@ export const getById = t.procedure status: deployment.status, gitCommitSha: deployment.gitCommitSha, gitBranch: deployment.gitBranch, - environment: deployment.environment, + environment: deployment.environment?.slug ?? "", createdAt: deployment.createdAt, updatedAt: deployment.updatedAt, }; diff --git a/apps/dashboard/lib/trpc/routers/deployment/getOpenApiDiff.ts b/apps/dashboard/lib/trpc/routers/deployment/getOpenApiDiff.ts index c39e732eff..1ae22b8344 100644 --- a/apps/dashboard/lib/trpc/routers/deployment/getOpenApiDiff.ts +++ b/apps/dashboard/lib/trpc/routers/deployment/getOpenApiDiff.ts @@ -25,11 +25,11 @@ export const getOpenApiDiff = t.procedure openapiSpec: true, gitCommitSha: true, gitBranch: true, - environment: true, // TODO: add this column //gitCommitMessage: true, }, with: { + environment: true, project: { columns: { id: true, @@ -47,10 +47,10 @@ export const getOpenApiDiff = t.procedure openapiSpec: true, gitCommitSha: true, gitBranch: true, - environment: true, //gitCommitMessage: true, }, with: { + environment: true, project: { columns: { id: true, diff --git a/apps/dashboard/lib/trpc/routers/deployment/list.ts b/apps/dashboard/lib/trpc/routers/deployment/list.ts index 85e8dbc32c..1f69bce500 100644 --- a/apps/dashboard/lib/trpc/routers/deployment/list.ts +++ b/apps/dashboard/lib/trpc/routers/deployment/list.ts @@ -12,7 +12,8 @@ export const listDeployments = t.procedure where: (table, { eq }) => eq(table.workspaceId, ctx.workspace.id), orderBy: (table, { desc }) => [desc(table.createdAt)], with: { - project: true, + environment: { columns: { slug: true } }, + project: { columns: { id: true, name: true, slug: true } }, }, }); @@ -22,9 +23,7 @@ export const listDeployments = t.procedure status: deployment.status, gitCommitSha: deployment.gitCommitSha, gitBranch: deployment.gitBranch, - environment: deployment.environment, - rootfsImageId: deployment.rootfsImageId, - buildId: deployment.buildId, + environment: deployment.environment.slug, createdAt: deployment.createdAt, updatedAt: deployment.updatedAt, project: deployment.project diff --git a/apps/dashboard/lib/trpc/routers/deployment/listByEnvironment.ts b/apps/dashboard/lib/trpc/routers/deployment/listByEnvironment.ts index bff10b6d1a..863d035e78 100644 --- a/apps/dashboard/lib/trpc/routers/deployment/listByEnvironment.ts +++ b/apps/dashboard/lib/trpc/routers/deployment/listByEnvironment.ts @@ -9,7 +9,7 @@ export const listByEnvironment = t.procedure .input( z.object({ projectId: z.string(), - environment: z.enum(["production", "preview"]), + environmentId: z.string(), }), ) .query(async ({ input, ctx }) => { @@ -30,7 +30,7 @@ export const listByEnvironment = t.procedure // Get all deployments for this project and environment const deployments = await db.query.deployments.findMany({ where: (table, { eq, and }) => - and(eq(table.projectId, input.projectId), eq(table.environment, input.environment)), + and(eq(table.projectId, input.projectId), eq(table.environmentId, input.environmentId)), orderBy: (table, { desc }) => [desc(table.createdAt)], }); diff --git a/apps/dashboard/lib/trpc/routers/deployment/listByProject.ts b/apps/dashboard/lib/trpc/routers/deployment/listByProject.ts index bd190ee747..6cabf2a857 100644 --- a/apps/dashboard/lib/trpc/routers/deployment/listByProject.ts +++ b/apps/dashboard/lib/trpc/routers/deployment/listByProject.ts @@ -31,7 +31,8 @@ export const listByProject = t.procedure where: (table, { eq }) => eq(table.projectId, input.projectId), orderBy: (table, { desc }) => [desc(table.createdAt)], with: { - project: true, + environment: { columns: { slug: true } }, + project: { columns: { id: true, name: true, slug: true } }, }, }); @@ -49,9 +50,7 @@ export const listByProject = t.procedure status: deployment.status, gitCommitSha: deployment.gitCommitSha, gitBranch: deployment.gitBranch, - environment: deployment.environment, - rootfsImageId: deployment.rootfsImageId, - buildId: deployment.buildId, + environment: deployment.environment.slug, createdAt: deployment.createdAt, updatedAt: deployment.updatedAt, project: deployment.project diff --git a/deployment/docker-compose.yaml b/deployment/docker-compose.yaml index 301b9bd5b5..e8f40d5b8f 100644 --- a/deployment/docker-compose.yaml +++ b/deployment/docker-compose.yaml @@ -227,6 +227,7 @@ services: - mysql - metald-aio - otel + - s3 environment: # Database configuration - use existing mysql service UNKEY_DATABASE_PRIMARY: "unkey:password@tcp(mysql:3306)/unkey?parseTime=true" @@ -236,6 +237,11 @@ services: # Control plane configuration UNKEY_HTTP_PORT: "7091" UNKEY_METALD_ADDRESS: "http://metald-aio:8080" + UNKEY_VAULT_S3_URL: "http://s3:3902" + UNKEY_VAULT_S3_BUCKET: "vault" + UNKEY_VAULT_S3_ACCESS_KEY_ID: "minio_root_user" + UNKEY_VAULT_S3_ACCESS_KEY_SECRET: "minio_root_password" + UNKEY_VAULT_MASTER_KEYS: "Ch9rZWtfMmdqMFBJdVhac1NSa0ZhNE5mOWlLSnBHenFPENTt7an5MRogENt9Si6wms4pQ2XIvqNSIgNpaBenJmXgcInhu6Nfv2U=" otel: image: grafana/otel-lgtm:0.11.7 container_name: otel diff --git a/go/apps/ctrl/config.go b/go/apps/ctrl/config.go index a5232f562e..7feeb45494 100644 --- a/go/apps/ctrl/config.go +++ b/go/apps/ctrl/config.go @@ -1,12 +1,17 @@ package ctrl import ( - "github.com/unkeyed/unkey/go/pkg/assert" "github.com/unkeyed/unkey/go/pkg/clock" "github.com/unkeyed/unkey/go/pkg/tls" - "github.com/unkeyed/unkey/go/pkg/vault/storage" ) +type S3Config struct { + URL string + Bucket string + AccessKeyID string + AccessKeySecret string +} + type Config struct { // InstanceID is the unique identifier for this instance of the control plane server InstanceID string @@ -52,21 +57,12 @@ type Config struct { // --- Vault Configuration --- VaultMasterKeys []string - VaultS3 *storage.S3Config + VaultS3 S3Config + + AcmeEnabled bool } func (c Config) Validate() error { - if c.VaultS3 != nil { - err := assert.All( - assert.NotEmpty(c.VaultS3.S3URL, "vault s3 url is empty"), - assert.NotEmpty(c.VaultS3.S3Bucket, "vault s3 bucket is empty"), - assert.NotEmpty(c.VaultS3.S3AccessKeyID, "vault s3 access key id is empty"), - assert.NotEmpty(c.VaultS3.S3AccessKeySecret, "vault s3 secret access key is empty"), - ) - if err != nil { - return err - } - } return nil } diff --git a/go/apps/ctrl/run.go b/go/apps/ctrl/run.go index 0166ce622a..9dc9a7a738 100644 --- a/go/apps/ctrl/run.go +++ b/go/apps/ctrl/run.go @@ -70,13 +70,13 @@ func Run(ctx context.Context, cfg Config) error { } var vaultSvc *vault.Service - if len(cfg.VaultMasterKeys) > 0 && cfg.VaultS3 != nil { + if len(cfg.VaultMasterKeys) > 0 { vaultStorage, err := storage.NewS3(storage.S3Config{ Logger: logger, - S3URL: cfg.VaultS3.S3URL, - S3Bucket: cfg.VaultS3.S3Bucket, - S3AccessKeyID: cfg.VaultS3.S3AccessKeyID, - S3AccessKeySecret: cfg.VaultS3.S3AccessKeySecret, + S3URL: cfg.VaultS3.URL, + S3Bucket: cfg.VaultS3.Bucket, + S3AccessKeyID: cfg.VaultS3.AccessKeyID, + S3AccessKeySecret: cfg.VaultS3.AccessKeySecret, }) if err != nil { return fmt.Errorf("unable to create vault storage: %w", err) @@ -197,7 +197,7 @@ func Run(ctx context.Context, cfg Config) error { // Create the service handlers with interceptors mux.Handle(ctrlv1connect.NewCtrlServiceHandler(ctrl.New(cfg.InstanceID, database))) - mux.Handle(ctrlv1connect.NewVersionServiceHandler(deployment.New(database, partitionDB, hydraEngine, logger))) + mux.Handle(ctrlv1connect.NewDeploymentServiceHandler(deployment.New(database, partitionDB, hydraEngine, logger))) mux.Handle(ctrlv1connect.NewOpenApiServiceHandler(openapi.New(database, logger))) mux.Handle(ctrlv1connect.NewAcmeServiceHandler(acme.New(acme.Config{ PartitionDB: partitionDB, @@ -257,82 +257,82 @@ func Run(ctx context.Context, cfg Config) error { } }() - acmeClient, err := acme.GetOrCreateUser(ctx, acme.UserConfig{ - DB: database, - Logger: logger, - Vault: vaultSvc, - WorkspaceID: "unkey", - }) - if err != nil { - logger.Error("Failed to create ACME user", "error", err) - return fmt.Errorf("failed to create ACME user: %w", err) - } - - // Set up our custom HTTP-01 challenge provider on the ACME client - httpProvider := providers.NewHTTPProvider(providers.HTTPProviderConfig{ - DB: database, - Logger: logger, - }) - err = acmeClient.Challenge.SetHTTP01Provider(httpProvider) - if err != nil { - logger.Error("failed to set HTTP-01 provider", "error", err) - return fmt.Errorf("failed to set HTTP-01 provider: %w", err) - } + if cfg.AcmeEnabled { + acmeClient, err := acme.GetOrCreateUser(ctx, acme.UserConfig{ + DB: database, + Logger: logger, + Vault: vaultSvc, + WorkspaceID: "unkey", + }) + if err != nil { + return fmt.Errorf("failed to create ACME user: %w", err) + } - // Register deployment workflow with Hydra worker - acmeWorkflows := acme.NewCertificateChallenge(acme.CertificateChallengeConfig{ - DB: database, - PartitionDB: partitionDB, - Logger: logger, - AcmeClient: acmeClient, - Vault: vaultSvc, - }) - err = hydra.RegisterWorkflow(hydraWorker, acmeWorkflows) - if err != nil { - logger.Error("unable to register deployment workflow: %w", err) - return fmt.Errorf("unable to register deployment workflow: %w", err) - } + // Set up our custom HTTP-01 challenge provider on the ACME client + httpProvider := providers.NewHTTPProvider(providers.HTTPProviderConfig{ + DB: database, + Logger: logger, + }) + err = acmeClient.Challenge.SetHTTP01Provider(httpProvider) + if err != nil { + logger.Error("failed to set HTTP-01 provider", "error", err) + return fmt.Errorf("failed to set HTTP-01 provider: %w", err) + } - go func() { - logger.Info("Starting cert worker") + // Register deployment workflow with Hydra worker + acmeWorkflows := acme.NewCertificateChallenge(acme.CertificateChallengeConfig{ + DB: database, + PartitionDB: partitionDB, + Logger: logger, + AcmeClient: acmeClient, + Vault: vaultSvc, + }) + err = hydra.RegisterWorkflow(hydraWorker, acmeWorkflows) + if err != nil { + logger.Error("unable to register ACME certificate workflow", "error", err) + return fmt.Errorf("unable to register deployment workflow: %w", err) + } - err = hydraEngine.RegisterCron("*/5 * * * *", "start-certificate-challenges", func(ctx context.Context, payload hydra.CronPayload) error { - challenges, err := db.Query.ListExecutableChallenges(ctx, database.RO()) - if err != nil { - logger.Error("Failed to start workflow", "error", err) - return err - } + go func() { + logger.Info("Starting cert worker") - logger.Info("Starting certificate challenges", "count", len(challenges)) - - for _, challenge := range challenges { - executionID, err := hydraEngine.StartWorkflow(ctx, "certificate_challenge", - acme.CertificateChallengeRequest{ - ID: challenge.ID, - WorkspaceID: challenge.WorkspaceID, - Domain: challenge.Domain, - }, - hydra.WithMaxAttempts(24), - hydra.WithTimeout(25*time.Hour), - hydra.WithRetryBackoff(1*time.Hour), - ) + registerErr := hydraEngine.RegisterCron("*/5 * * * *", "start-certificate-challenges", func(ctx context.Context, payload hydra.CronPayload) error { + challenges, err := db.Query.ListExecutableChallenges(ctx, database.RO()) if err != nil { logger.Error("Failed to start workflow", "error", err) - continue + return err } - logger.Info("Workflow started", "executionID", executionID) - } + logger.Info("Starting certificate challenges", "count", len(challenges)) + + for _, challenge := range challenges { + executionID, err := hydraEngine.StartWorkflow(ctx, "certificate_challenge", + acme.CertificateChallengeRequest{ + ID: challenge.ID, + WorkspaceID: challenge.WorkspaceID, + Domain: challenge.Domain, + }, + hydra.WithMaxAttempts(24), + hydra.WithTimeout(25*time.Hour), + hydra.WithRetryBackoff(1*time.Hour), + ) + if err != nil { + logger.Error("Failed to start workflow", "error", err) + continue + } + + logger.Info("Workflow started", "executionID", executionID) + } - return nil - }) - - if err != nil { - logger.Error("Failed to register daily report cron job", "error", err) - return - } - }() + return nil + }) + if registerErr != nil { + logger.Error("Failed to register daily report cron job", "error", err) + return + } + }() + } // Start Hydra worker go func() { logger.Info("Starting Hydra workflow worker") diff --git a/go/apps/ctrl/services/acme/certificate_verification.go b/go/apps/ctrl/services/acme/certificate_verification.go index c0830a4ba2..91dc478559 100644 --- a/go/apps/ctrl/services/acme/certificate_verification.go +++ b/go/apps/ctrl/services/acme/certificate_verification.go @@ -2,7 +2,6 @@ package acme import ( "context" - "database/sql" "errors" "connectrpc.com/connect" @@ -25,10 +24,10 @@ func (s *Service) HandleCertificateVerification( return nil, connect.NewError(connect.CodeInternal, err) } - challenge, err := db.Query.FindDomainChallengeByToken(ctx, s.db.RO(), db.FindDomainChallengeByTokenParams{ + challenge, err := db.Query.FindAcmeChallengeByToken(ctx, s.db.RO(), db.FindAcmeChallengeByTokenParams{ WorkspaceID: domain.WorkspaceID, DomainID: domain.ID, - Token: sql.NullString{Valid: true, String: req.Msg.GetToken()}, + Token: req.Msg.GetToken(), }) if err != nil { if db.IsNotFound(err) { @@ -38,10 +37,10 @@ func (s *Service) HandleCertificateVerification( return nil, connect.NewError(connect.CodeInternal, err) } - if !challenge.Authorization.Valid { + if challenge.Authorization == "" { return nil, connect.NewError(connect.CodeNotFound, errors.New("challenge hasn't been issued yet")) } - res.Msg.Token = challenge.Authorization.String + res.Msg.Token = challenge.Authorization return res, nil } diff --git a/go/apps/ctrl/services/acme/certificate_workflow.go b/go/apps/ctrl/services/acme/certificate_workflow.go index e05516f66b..e19d8ad8cd 100644 --- a/go/apps/ctrl/services/acme/certificate_workflow.go +++ b/go/apps/ctrl/services/acme/certificate_workflow.go @@ -75,9 +75,9 @@ func (w *CertificateChallenge) Run(ctx hydra.WorkflowContext, req *CertificateCh } err = hydra.StepVoid(ctx, "claim-challenge", func(stepCtx context.Context) error { - return db.Query.UpdateDomainChallengeTryClaiming(stepCtx, w.db.RW(), db.UpdateDomainChallengeTryClaimingParams{ + return db.Query.UpdateAcmeChallengeTryClaiming(stepCtx, w.db.RW(), db.UpdateAcmeChallengeTryClaimingParams{ DomainID: dom.ID, - Status: db.DomainChallengesStatusPending, + Status: db.AcmeChallengesStatusPending, UpdatedAt: sql.NullInt64{Int64: time.Now().UnixMilli(), Valid: true}, }) }) @@ -92,9 +92,9 @@ func (w *CertificateChallenge) Run(ctx hydra.WorkflowContext, req *CertificateCh // B: We have to renew a existing certificate // Regardless we first claim the challenge so that no-other job tries to do the same, this will just annoy acme ratelimits if err != nil { - db.Query.UpdateDomainChallengeStatus(ctx.Context(), w.db.RW(), db.UpdateDomainChallengeStatusParams{ + db.Query.UpdateAcmeChallengeStatus(ctx.Context(), w.db.RW(), db.UpdateAcmeChallengeStatusParams{ DomainID: dom.ID, - Status: db.DomainChallengesStatusFailed, + Status: db.AcmeChallengesStatusFailed, UpdatedAt: sql.NullInt64{Valid: true, Int64: time.Now().UnixMilli()}, }) w.logger.Error("failed to obtain certificate", "error", err) @@ -174,9 +174,10 @@ func (w *CertificateChallenge) Run(ctx hydra.WorkflowContext, req *CertificateCh } err = hydra.StepVoid(ctx, "set-expires-at", func(stepCtx context.Context) error { - return db.Query.UpdateDomainChallengeExpiresAt(stepCtx, w.db.RW(), db.UpdateDomainChallengeExpiresAtParams{ - ExpiresAt: sql.NullInt64{Valid: true, Int64: cert.ExpiresAt}, - DomainID: dom.ID, + return db.Query.UpdateAcmeChallengeExpiresAt(stepCtx, w.db.RW(), db.UpdateAcmeChallengeExpiresAtParams{ + ExpiresAt: cert.ExpiresAt, + ID: 0, // "TODO: I need the challenge id" + }) }) if err != nil { diff --git a/go/apps/ctrl/services/acme/providers/http_provider.go b/go/apps/ctrl/services/acme/providers/http_provider.go index 50e8471e02..c501df9fb7 100644 --- a/go/apps/ctrl/services/acme/providers/http_provider.go +++ b/go/apps/ctrl/services/acme/providers/http_provider.go @@ -45,11 +45,11 @@ func (p *HTTPProvider) Present(domain, token, keyAuth string) error { } // Update the existing challenge record with the token and authorization - err = db.Query.UpdateDomainChallengePending(ctx, p.db.RW(), db.UpdateDomainChallengePendingParams{ + err = db.Query.UpdateAcmeChallengePending(ctx, p.db.RW(), db.UpdateAcmeChallengePendingParams{ DomainID: dom.ID, - Status: db.DomainChallengesStatusPending, - Token: sql.NullString{String: token, Valid: true}, - Authorization: sql.NullString{String: keyAuth, Valid: true}, + Status: db.AcmeChallengesStatusPending, + Token: token, + Authorization: keyAuth, UpdatedAt: sql.NullInt64{Int64: time.Now().UnixMilli(), Valid: true}, }) @@ -75,9 +75,9 @@ func (p *HTTPProvider) CleanUp(domain, token, keyAuth string) error { } // Update the challenge status to mark it as verified - err = db.Query.UpdateDomainChallengeStatus(ctx, p.db.RW(), db.UpdateDomainChallengeStatusParams{ + err = db.Query.UpdateAcmeChallengeStatus(ctx, p.db.RW(), db.UpdateAcmeChallengeStatusParams{ DomainID: dom.ID, - Status: db.DomainChallengesStatusVerified, + Status: db.AcmeChallengesStatusVerified, UpdatedAt: sql.NullInt64{Valid: true, Int64: time.Now().UnixMilli()}, }) diff --git a/go/apps/ctrl/services/deployment/create_version.go b/go/apps/ctrl/services/deployment/create_deployment.go similarity index 71% rename from go/apps/ctrl/services/deployment/create_version.go rename to go/apps/ctrl/services/deployment/create_deployment.go index 1647495f1d..a5fc129482 100644 --- a/go/apps/ctrl/services/deployment/create_version.go +++ b/go/apps/ctrl/services/deployment/create_deployment.go @@ -3,6 +3,7 @@ package deployment import ( "context" "database/sql" + "encoding/json" "fmt" "strings" "time" @@ -14,24 +15,18 @@ import ( "github.com/unkeyed/unkey/go/pkg/uid" ) -// limitString truncates a string to the specified maximum number of runes -func limitString(s string, maxRunes int) string { - runes := []rune(s) - if len(runes) > maxRunes { - return string(runes[:maxRunes]) +func trimLength(s string, characters int) string { + if len(s) > characters { + return s[:characters] } return s } -// CreateVersion creates a new deployment version record and kicks off the deployment workflow. -// It validates workspace/project, normalizes git metadata (branch fallback, commit fields), -// and persists the deployment in "pending" state. Workflow failures are logged but do not -// fail creation to allow retries. - -func (s *Service) CreateVersion( +func (s *Service) CreateDeployment( ctx context.Context, - req *connect.Request[ctrlv1.CreateVersionRequest], -) (*connect.Response[ctrlv1.CreateVersionResponse], error) { + req *connect.Request[ctrlv1.CreateDeploymentRequest], +) (*connect.Response[ctrlv1.CreateDeploymentResponse], error) { + // Validate workspace exists _, err := db.Query.FindWorkspaceByID(ctx, s.db.RO(), req.Msg.GetWorkspaceId()) if err != nil { @@ -85,29 +80,28 @@ func (s *Service) CreateVersion( } } - // Determine environment (default to preview) - // TODO: Add environment field to CreateVersionRequest proto - environment := db.DeploymentsEnvironmentPreview - // Generate deployment ID deploymentID := uid.New("deployment") now := time.Now().UnixMilli() // Sanitize input values before persisting gitCommitSha := req.Msg.GetGitCommitSha() - gitCommitMessage := limitString(req.Msg.GetGitCommitMessage(), 10240) - gitCommitAuthorName := limitString(strings.TrimSpace(req.Msg.GetGitCommitAuthorName()), 256) - gitCommitAuthorUsername := limitString(strings.TrimSpace(req.Msg.GetGitCommitAuthorUsername()), 256) - gitCommitAuthorAvatarUrl := limitString(strings.TrimSpace(req.Msg.GetGitCommitAuthorAvatarUrl()), 512) + gitCommitMessage := trimLength(req.Msg.GetGitCommitMessage(), 10240) + gitCommitAuthorName := trimLength(strings.TrimSpace(req.Msg.GetGitCommitAuthorName()), 256) + gitCommitAuthorUsername := trimLength(strings.TrimSpace(req.Msg.GetGitCommitAuthorUsername()), 256) + gitCommitAuthorAvatarUrl := trimLength(strings.TrimSpace(req.Msg.GetGitCommitAuthorAvatarUrl()), 512) // Insert deployment into database err = db.Query.InsertDeployment(ctx, s.db.RW(), db.InsertDeploymentParams{ ID: deploymentID, WorkspaceID: req.Msg.GetWorkspaceId(), ProjectID: req.Msg.GetProjectId(), - Environment: environment, - BuildID: sql.NullString{String: "", Valid: false}, // Build creation handled separately - RootfsImageID: "", // Image handling not implemented yet + EnvironmentID: req.Msg.GetEnvironmentId(), + RuntimeConfig: json.RawMessage("{}"), + OpenapiSpec: sql.NullString{String: "", Valid: false}, + Status: db.DeploymentsStatusPending, + CreatedAt: now, + UpdatedAt: sql.NullInt64{Int64: now, Valid: true}, GitCommitSha: sql.NullString{String: gitCommitSha, Valid: gitCommitSha != ""}, GitBranch: sql.NullString{String: gitBranch, Valid: true}, GitCommitMessage: sql.NullString{String: gitCommitMessage, Valid: req.Msg.GetGitCommitMessage() != ""}, @@ -116,13 +110,9 @@ func (s *Service) CreateVersion( GitCommitAuthorUsername: sql.NullString{String: gitCommitAuthorUsername, Valid: req.Msg.GetGitCommitAuthorUsername() != ""}, GitCommitAuthorAvatarUrl: sql.NullString{String: gitCommitAuthorAvatarUrl, Valid: req.Msg.GetGitCommitAuthorAvatarUrl() != ""}, GitCommitTimestamp: sql.NullInt64{Int64: req.Msg.GetGitCommitTimestamp(), Valid: req.Msg.GetGitCommitTimestamp() != 0}, - ConfigSnapshot: []byte("{}"), // Configuration snapshot placeholder - OpenapiSpec: sql.NullString{String: "", Valid: false}, - Status: db.DeploymentsStatusPending, - CreatedAt: now, - UpdatedAt: sql.NullInt64{Int64: now, Valid: true}, }) if err != nil { + s.logger.Error("failed to insert deployment", "error", err.Error()) return nil, connect.NewError(connect.CodeInternal, err) } @@ -130,7 +120,7 @@ func (s *Service) CreateVersion( "deployment_id", deploymentID, "workspace_id", req.Msg.GetWorkspaceId(), "project_id", req.Msg.GetProjectId(), - "environment", environment, + "environment", req.Msg.GetEnvironmentId(), "docker_image", req.Msg.GetDockerImageTag()) // Start the deployment workflow directly @@ -159,9 +149,9 @@ func (s *Service) CreateVersion( "execution_id", executionID) } - res := connect.NewResponse(&ctrlv1.CreateVersionResponse{ - VersionId: deploymentID, - Status: ctrlv1.VersionStatus_VERSION_STATUS_PENDING, + res := connect.NewResponse(&ctrlv1.CreateDeploymentResponse{ + DeploymentId: deploymentID, + Status: ctrlv1.DeploymentStatus_DEPLOYMENT_STATUS_PENDING, }) return res, nil diff --git a/go/apps/ctrl/services/deployment/create_version_simple_test.go b/go/apps/ctrl/services/deployment/create_deployment_simple_test.go similarity index 96% rename from go/apps/ctrl/services/deployment/create_version_simple_test.go rename to go/apps/ctrl/services/deployment/create_deployment_simple_test.go index 132d35e2d6..0619420862 100644 --- a/go/apps/ctrl/services/deployment/create_version_simple_test.go +++ b/go/apps/ctrl/services/deployment/create_deployment_simple_test.go @@ -68,7 +68,7 @@ func TestGitFieldValidation_SpecialCharacters(t *testing.T) { t.Parallel() // Test that special characters are preserved in protobuf - req := &ctrlv1.CreateVersionRequest{ + req := &ctrlv1.CreateDeploymentRequest{ GitCommitMessage: tt.input, GitCommitAuthorName: tt.input, GitCommitAuthorUsername: tt.input, @@ -101,7 +101,7 @@ func TestGitFieldValidation_NullHandling(t *testing.T) { t.Parallel() // Test empty protobuf fields - req := &ctrlv1.CreateVersionRequest{ + req := &ctrlv1.CreateDeploymentRequest{ WorkspaceId: "ws_test", ProjectId: "proj_test", GitCommitMessage: "", @@ -144,7 +144,7 @@ func TestTimestampConversion(t *testing.T) { nowMillis := now.UnixMilli() // Test protobuf timestamp - req := &ctrlv1.CreateVersionRequest{ + req := &ctrlv1.CreateDeploymentRequest{ GitCommitTimestamp: nowMillis, } require.Equal(t, nowMillis, req.GetGitCommitTimestamp()) @@ -166,7 +166,7 @@ func TestCreateVersionTimestampValidation_InvalidSecondsFormat(t *testing.T) { t.Parallel() // Create proto request directly with seconds timestamp (should be rejected) - req := &ctrlv1.CreateVersionRequest{ + req := &ctrlv1.CreateDeploymentRequest{ WorkspaceId: "ws_test123", ProjectId: "proj_test456", Branch: "main", @@ -185,7 +185,7 @@ func TestCreateVersionTimestampValidation_ValidMillisecondsFormat(t *testing.T) t.Parallel() // Create proto request directly with milliseconds timestamp - req := &ctrlv1.CreateVersionRequest{ + req := &ctrlv1.CreateDeploymentRequest{ WorkspaceId: "ws_test123", ProjectId: "proj_test456", Branch: "main", @@ -263,7 +263,7 @@ func TestCreateVersionFieldMapping(t *testing.T) { tests := []struct { name string - request *ctrlv1.CreateVersionRequest + request *ctrlv1.CreateDeploymentRequest expected struct { gitCommitSha string gitCommitShaValid bool @@ -283,7 +283,7 @@ func TestCreateVersionFieldMapping(t *testing.T) { }{ { name: "all_git_fields_populated", - request: &ctrlv1.CreateVersionRequest{ + request: &ctrlv1.CreateDeploymentRequest{ WorkspaceId: "ws_test123", ProjectId: "proj_test456", Branch: "feature/test-branch", @@ -329,7 +329,7 @@ func TestCreateVersionFieldMapping(t *testing.T) { }, { name: "empty_git_fields", - request: &ctrlv1.CreateVersionRequest{ + request: &ctrlv1.CreateDeploymentRequest{ WorkspaceId: "ws_test123", ProjectId: "proj_test456", Branch: "main", @@ -375,7 +375,7 @@ func TestCreateVersionFieldMapping(t *testing.T) { }, { name: "mixed_populated_and_empty_fields", - request: &ctrlv1.CreateVersionRequest{ + request: &ctrlv1.CreateDeploymentRequest{ WorkspaceId: "ws_test123", ProjectId: "proj_test456", Branch: "hotfix/urgent-fix", @@ -431,9 +431,7 @@ func TestCreateVersionFieldMapping(t *testing.T) { ID: "test_deployment_id", WorkspaceID: tt.request.GetWorkspaceId(), ProjectID: tt.request.GetProjectId(), - Environment: db.DeploymentsEnvironmentPreview, - BuildID: sql.NullString{String: "", Valid: false}, - RootfsImageID: "", + EnvironmentID: "todo", // Git field mappings - this is what we're testing GitCommitSha: sql.NullString{String: tt.request.GetGitCommitSha(), Valid: tt.request.GetGitCommitSha() != ""}, GitBranch: sql.NullString{String: tt.request.GetBranch(), Valid: true}, @@ -442,9 +440,9 @@ func TestCreateVersionFieldMapping(t *testing.T) { GitCommitAuthorUsername: sql.NullString{String: tt.request.GetGitCommitAuthorUsername(), Valid: tt.request.GetGitCommitAuthorUsername() != ""}, GitCommitAuthorAvatarUrl: sql.NullString{String: tt.request.GetGitCommitAuthorAvatarUrl(), Valid: tt.request.GetGitCommitAuthorAvatarUrl() != ""}, GitCommitTimestamp: sql.NullInt64{Int64: tt.request.GetGitCommitTimestamp(), Valid: tt.request.GetGitCommitTimestamp() != 0}, - ConfigSnapshot: []byte("{}"), + RuntimeConfig: []byte("{}"), OpenapiSpec: sql.NullString{String: "", Valid: false}, - Status: "pending", + Status: db.DeploymentsStatusPending, CreatedAt: 1724251845000, UpdatedAt: sql.NullInt64{Int64: 1724251845000, Valid: true}, } diff --git a/go/apps/ctrl/services/deployment/deploy_workflow.go b/go/apps/ctrl/services/deployment/deploy_workflow.go index ddc4ec4fa3..99fbf77353 100644 --- a/go/apps/ctrl/services/deployment/deploy_workflow.go +++ b/go/apps/ctrl/services/deployment/deploy_workflow.go @@ -57,28 +57,6 @@ type DeployRequest struct { Hostname string `json:"hostname"` } -// BuildInfo holds build metadata from initialization step -type BuildInfo struct { - BuildID string `json:"build_id"` - WorkspaceID string `json:"workspace_id"` - ProjectID string `json:"project_id"` - VersionID string `json:"version_id"` - DockerImage string `json:"docker_image"` -} - -// SubmissionResult holds the result of build submission -type SubmissionResult struct { - BuildID string `json:"build_id"` - Submitted bool `json:"submitted"` -} - -// BuildResult holds the final build outcome -type BuildResult struct { - BuildID string `json:"build_id"` - Status string `json:"status"` - ErrorMsg string `json:"error_message,omitempty"` -} - // DeploymentResult holds the deployment outcome type DeploymentResult struct { DeploymentID string `json:"deployment_id"` @@ -111,36 +89,16 @@ func (w *DeployWorkflow) Run(ctx hydra.WorkflowContext, req *DeployRequest) erro // Step 2: Log deployment pending err = hydra.StepVoid(ctx, "log-deployment-pending", func(stepCtx context.Context) error { return db.Query.InsertDeploymentStep(stepCtx, w.db.RW(), db.InsertDeploymentStepParams{ - DeploymentID: req.DeploymentID, - Status: "pending", - Message: sql.NullString{String: "Deployment queued and ready to start", Valid: true}, - ErrorMessage: sql.NullString{String: "", Valid: false}, - CreatedAt: time.Now().UnixMilli(), - }) - }) - if err != nil { - w.logger.Error("failed to log deployment pending", "error", err, "deployment_id", req.DeploymentID) - return err - } - - // Step 3: Insert build into database - err = hydra.StepVoid(ctx, "insert-build", func(stepCtx context.Context) error { - w.logger.Info("inserting build into database", "build_id", buildID) - insertErr := db.Query.InsertBuild(stepCtx, w.db.RW(), db.InsertBuildParams{ - ID: buildID, WorkspaceID: req.WorkspaceID, ProjectID: req.ProjectID, DeploymentID: req.DeploymentID, + Status: "pending", + Message: "Deployment queued and ready to start", CreatedAt: time.Now().UnixMilli(), }) - if insertErr != nil { - return fmt.Errorf("failed to create build record: %w", insertErr) - } - w.logger.Info("build record created successfully", "build_id", buildID) - return nil }) if err != nil { - w.logger.Error("failed to insert build", "error", err, "build_id", buildID) + w.logger.Error("failed to log deployment pending", "error", err, "deployment_id", req.DeploymentID) return err } @@ -163,32 +121,12 @@ func (w *DeployWorkflow) Run(ctx hydra.WorkflowContext, req *DeployRequest) erro return err } - // Step 5: Update build status to running - _, err = hydra.Step(ctx, "update-build-running", func(stepCtx context.Context) (*struct{}, error) { - w.logger.Info("updating build status to running", "build_id", buildID) - now := time.Now().UnixMilli() - runningErr := db.Query.UpdateBuildStatus(stepCtx, w.db.RW(), db.UpdateBuildStatusParams{ - ID: buildID, - Status: db.BuildsStatusRunning, - Now: sql.NullInt64{Valid: true, Int64: now}, - }) - if runningErr != nil { - return nil, fmt.Errorf("failed to update build status to running: %w", runningErr) - } - return &struct{}{}, nil - }) - if err != nil { - w.logger.Error("failed to update build status to running", "error", err, "build_id", buildID) - return err - } - // Step 6: Log downloading Docker image err = hydra.StepVoid(ctx, "log-downloading-docker-image", func(stepCtx context.Context) error { return db.Query.InsertDeploymentStep(stepCtx, w.db.RW(), db.InsertDeploymentStepParams{ DeploymentID: req.DeploymentID, Status: "downloading_docker_image", - Message: sql.NullString{String: fmt.Sprintf("Downloading Docker image: %s", req.DockerImage), Valid: true}, - ErrorMessage: sql.NullString{String: "", Valid: false}, + Message: fmt.Sprintf("Downloading Docker image: %s", req.DockerImage), CreatedAt: time.Now().UnixMilli(), }) }) @@ -222,7 +160,7 @@ func (w *DeployWorkflow) Run(ctx hydra.WorkflowContext, req *DeployRequest) erro "docker_image": req.DockerImage, "exposed_ports": "8080/tcp", "env_vars": "PORT=8080", - "version_id": req.DeploymentID, + "deployment_id": req.DeploymentID, "workspace_id": req.WorkspaceID, "project_id": req.ProjectID, "created_by": "deploy-workflow", @@ -254,8 +192,7 @@ func (w *DeployWorkflow) Run(ctx hydra.WorkflowContext, req *DeployRequest) erro return db.Query.InsertDeploymentStep(stepCtx, w.db.RW(), db.InsertDeploymentStepParams{ DeploymentID: req.DeploymentID, Status: "building_rootfs", - Message: sql.NullString{String: fmt.Sprintf("Building rootfs from Docker image: %s", req.DockerImage), Valid: true}, - ErrorMessage: sql.NullString{String: "", Valid: false}, + Message: fmt.Sprintf("Building rootfs from Docker image: %s", req.DockerImage), CreatedAt: time.Now().UnixMilli(), }) }) @@ -269,8 +206,7 @@ func (w *DeployWorkflow) Run(ctx hydra.WorkflowContext, req *DeployRequest) erro return db.Query.InsertDeploymentStep(stepCtx, w.db.RW(), db.InsertDeploymentStepParams{ DeploymentID: req.DeploymentID, Status: "uploading_rootfs", - Message: sql.NullString{String: "Uploading rootfs image to storage", Valid: true}, - ErrorMessage: sql.NullString{String: "", Valid: false}, + Message: "Uploading rootfs image to storage", CreatedAt: time.Now().UnixMilli(), }) }) @@ -279,31 +215,12 @@ func (w *DeployWorkflow) Run(ctx hydra.WorkflowContext, req *DeployRequest) erro return err } - // Step 10: Update build status to succeeded - _, err = hydra.Step(ctx, "update-build-succeeded", func(stepCtx context.Context) (*struct{}, error) { - w.logger.Info("updating build status to succeeded", "build_id", buildID) - successErr := db.Query.UpdateBuildSucceeded(stepCtx, w.db.RW(), db.UpdateBuildSucceededParams{ - ID: buildID, - Now: sql.NullInt64{Valid: true, Int64: time.Now().UnixMilli()}, - }) - if successErr != nil { - return nil, fmt.Errorf("failed to update build status to succeeded: %w", successErr) - } - w.logger.Info("build status updated to succeeded", "build_id", buildID) - return &struct{}{}, nil - }) - if err != nil { - w.logger.Error("failed to update build status to succeeded", "error", err, "build_id", buildID) - return err - } - // Step 11: Log creating VM err = hydra.StepVoid(ctx, "log-creating-vm", func(stepCtx context.Context) error { return db.Query.InsertDeploymentStep(stepCtx, w.db.RW(), db.InsertDeploymentStepParams{ DeploymentID: req.DeploymentID, Status: "creating_vm", - Message: sql.NullString{String: fmt.Sprintf("Creating VM for version: %s", req.DeploymentID), Valid: true}, - ErrorMessage: sql.NullString{String: "", Valid: false}, + Message: fmt.Sprintf("Creating VM for version: %s", req.DeploymentID), CreatedAt: time.Now().UnixMilli(), }) }) @@ -412,19 +329,14 @@ func (w *DeployWorkflow) Run(ctx hydra.WorkflowContext, req *DeployRequest) erro vmParams := partitiondb.UpsertVMParams{ ID: createResult.VmId, DeploymentID: req.DeploymentID, - Region: "us-east-1", - PrivateIp: sql.NullString{ - String: "127.0.0.1", - Valid: true, - }, - Port: sql.NullInt32{ - Int32: hostPort, - Valid: true, + Address: sql.NullString{ + Valid: false, + String: "", }, + CpuMillicores: 1000, MemoryMb: 512, Status: partitiondb.VmsStatusRunning, - HealthStatus: partitiondb.VmsHealthStatusHealthy, } if err := partitiondb.Query.UpsertVM(stepCtx, w.partitionDB.RW(), vmParams); err != nil { @@ -459,24 +371,23 @@ func (w *DeployWorkflow) Run(ctx hydra.WorkflowContext, req *DeployRequest) erro // Create VM protobuf objects for gateway config vms := []*partitionv1.VM{ { - Id: createResult.VmId, - Region: "us-east-1", // TODO: make this configurable + Id: createResult.VmId, }, } gatewayConfig := &partitionv1.GatewayConfig{ - DeploymentId: req.DeploymentID, - IsEnabled: true, - Vms: vms, + Deployment: &partitionv1.Deployment{ + Id: req.DeploymentID, + IsEnabled: true, + }, + Vms: vms, } // Only add AuthConfig if we have a KeyspaceID if req.KeyspaceID != "" { gatewayConfig.AuthConfig = &partitionv1.AuthConfig{ - RequireApiKey: true, - KeyspaceId: req.KeyspaceID, - AllowAnonymous: false, - Enabled: true, + + KeyAuthId: req.KeyspaceID, } } @@ -510,8 +421,7 @@ func (w *DeployWorkflow) Run(ctx hydra.WorkflowContext, req *DeployRequest) erro return db.Query.InsertDeploymentStep(stepCtx, w.db.RW(), db.InsertDeploymentStepParams{ DeploymentID: req.DeploymentID, Status: "booting_vm", - Message: sql.NullString{String: fmt.Sprintf("VM booted successfully: %s", createResult.VmId), Valid: true}, - ErrorMessage: sql.NullString{String: "", Valid: false}, + Message: fmt.Sprintf("VM booted successfully: %s", createResult.VmId), CreatedAt: time.Now().UnixMilli(), }) }) @@ -546,25 +456,25 @@ func (w *DeployWorkflow) Run(ctx hydra.WorkflowContext, req *DeployRequest) erro cleanIdentifier := strings.ReplaceAll(identifier, "_", "-") primaryHostname := fmt.Sprintf("%s-%s-%s.unkey.app", branch, cleanIdentifier, req.WorkspaceID) - // Create route entry for primary hostname - routeID := uid.New("route") - insertErr := db.Query.InsertHostnameRoute(stepCtx, w.db.RW(), db.InsertHostnameRouteParams{ - ID: routeID, + // Create domain entry for primary hostname + domainID := uid.New("domain") + insertErr := db.Query.InsertDomain(stepCtx, w.db.RW(), db.InsertDomainParams{ + ID: domainID, WorkspaceID: req.WorkspaceID, - ProjectID: req.ProjectID, - Hostname: primaryHostname, - DeploymentID: req.DeploymentID, - IsEnabled: true, + ProjectID: sql.NullString{Valid: true, String: req.ProjectID}, + Domain: primaryHostname, + DeploymentID: sql.NullString{Valid: true, String: req.DeploymentID}, CreatedAt: time.Now().UnixMilli(), UpdatedAt: sql.NullInt64{Valid: true, Int64: time.Now().UnixMilli()}, + Type: db.DomainsTypeCustom, }) if insertErr != nil { - w.logger.Error("failed to create route", "error", insertErr, "hostname", primaryHostname, "deployment_id", req.DeploymentID) + w.logger.Error("failed to create domain", "error", insertErr, "domain", primaryHostname, "deployment_id", req.DeploymentID) return nil, fmt.Errorf("failed to create route for hostname %s: %w", primaryHostname, insertErr) } hostnames = append(hostnames, primaryHostname) - w.logger.Info("primary domain assigned successfully", "hostname", primaryHostname, "deployment_id", req.DeploymentID, "route_id", routeID) + w.logger.Info("primary domain assigned successfully", "hostname", primaryHostname, "deployment_id", req.DeploymentID, "domain_id", domainID) // Add localhost:port hostname for development w.logger.Info("checking for port mappings", "has_network_info", vmInfo.NetworkInfo != nil, "port_mappings_count", func() int { @@ -580,15 +490,15 @@ func (w *DeployWorkflow) Run(ctx hydra.WorkflowContext, req *DeployRequest) erro // Create route entry for localhost:port localhostRouteID := uid.New("route") - insertErr := db.Query.InsertHostnameRoute(stepCtx, w.db.RW(), db.InsertHostnameRouteParams{ + insertErr := db.Query.InsertDomain(stepCtx, w.db.RW(), db.InsertDomainParams{ ID: localhostRouteID, WorkspaceID: req.WorkspaceID, - ProjectID: req.ProjectID, - Hostname: localhostHostname, - DeploymentID: req.DeploymentID, - IsEnabled: true, + ProjectID: sql.NullString{Valid: true, String: req.ProjectID}, + Domain: localhostHostname, + DeploymentID: sql.NullString{Valid: true, String: req.DeploymentID}, CreatedAt: time.Now().UnixMilli(), UpdatedAt: sql.NullInt64{Valid: true, Int64: time.Now().UnixMilli()}, + Type: db.DomainsTypeCustom, }) if insertErr != nil { w.logger.Error("failed to create localhost route", "error", insertErr, "hostname", localhostHostname, "deployment_id", req.DeploymentID) @@ -607,66 +517,6 @@ func (w *DeployWorkflow) Run(ctx hydra.WorkflowContext, req *DeployRequest) erro return err } - err = hydra.StepVoid(ctx, "generate-certificates", func(stepCtx context.Context) error { - domains := []db.InsertDomainParams{} - now := time.Now().UnixMilli() - for _, domain := range assignedHostnames { - domains = append(domains, db.InsertDomainParams{ - ID: uid.New(uid.DomainPrefix), - WorkspaceID: req.WorkspaceID, - ProjectID: req.ProjectID, - Domain: domain, - Type: db.DomainsTypeGenerated, - SubdomainConfig: []byte("{}"), - CreatedAt: now, - UpdatedAt: sql.NullInt64{Valid: true, Int64: now}, - }) - } - - if req.Hostname != "" { - domainId := uid.New(uid.DomainPrefix) - domains = append(domains, db.InsertDomainParams{ - ID: domainId, - WorkspaceID: req.WorkspaceID, - ProjectID: req.ProjectID, - Domain: req.Hostname, - Type: db.DomainsTypeCustom, - SubdomainConfig: []byte("{}"), - CreatedAt: now, - UpdatedAt: sql.NullInt64{Valid: true, Int64: now}, - }) - - err = db.Query.InsertDomainChallenge(ctx.Context(), w.db.RW(), db.InsertDomainChallengeParams{ - WorkspaceID: req.WorkspaceID, - DomainID: domainId, - Token: sql.NullString{Valid: false, String: ""}, - Authorization: sql.NullString{Valid: false, String: ""}, - Status: db.DomainChallengesStatusWaiting, - CreatedAt: now, - UpdatedAt: sql.NullInt64{Valid: false, Int64: 0}, - ExpiresAt: sql.NullInt64{Valid: false, Int64: 0}, - }) - if err != nil { - w.logger.Error("failed to insert domain challenge", "error", err, "deployment_id", req.DeploymentID) - return err - } - } - - if len(domains) > 0 { - err = db.BulkQuery.InsertDomains(ctx.Context(), w.db.RW(), domains) - if err != nil { - w.logger.Error("failed to insert domains", "error", err, "deployment_id", req.DeploymentID) - return err - } - } - - return nil - }) - if err != nil { - w.logger.Error("failed to insert domains", "error", err, "deployment_id", req.DeploymentID) - return err - } - // Step 20: Log assigning domains err = hydra.StepVoid(ctx, "log-assigning-domains", func(stepCtx context.Context) error { var message string @@ -677,9 +527,8 @@ func (w *DeployWorkflow) Run(ctx hydra.WorkflowContext, req *DeployRequest) erro } return db.Query.InsertDeploymentStep(stepCtx, w.db.RW(), db.InsertDeploymentStepParams{ DeploymentID: req.DeploymentID, - Status: "assigning_domains", - Message: sql.NullString{String: message, Valid: true}, - ErrorMessage: sql.NullString{String: "", Valid: false}, + Status: db.DeploymentStepsStatusAssigningDomains, + Message: message, CreatedAt: time.Now().UnixMilli(), }) }) @@ -688,18 +537,18 @@ func (w *DeployWorkflow) Run(ctx hydra.WorkflowContext, req *DeployRequest) erro return err } - // Step 21: Update version status to active - _, err = hydra.Step(ctx, "update-version-active", func(stepCtx context.Context) (*DeploymentResult, error) { + // Step 21: Update deployment status to active + _, err = hydra.Step(ctx, "update-deployment-active", func(stepCtx context.Context) (*DeploymentResult, error) { completionTime := time.Now().UnixMilli() w.logger.Info("updating deployment status to active", "deployment_id", req.DeploymentID, "completion_time", completionTime) activeErr := db.Query.UpdateDeploymentStatus(stepCtx, w.db.RW(), db.UpdateDeploymentStatusParams{ ID: req.DeploymentID, - Status: db.DeploymentsStatusActive, + Status: db.DeploymentsStatusReady, UpdatedAt: sql.NullInt64{Valid: true, Int64: completionTime}, }) if activeErr != nil { - w.logger.Error("failed to update version status to active", "error", activeErr, "deployment_id", req.DeploymentID) - return nil, fmt.Errorf("failed to update version status to active: %w", activeErr) + w.logger.Error("failed to update deployment status to active", "error", activeErr, "deployment_id", req.DeploymentID) + return nil, fmt.Errorf("failed to update deployment status to active: %w", activeErr) } w.logger.Info("deployment complete", "deployment_id", req.DeploymentID, "status", "active") @@ -867,7 +716,6 @@ func (w *DeployWorkflow) Run(ctx hydra.WorkflowContext, req *DeployRequest) erro gatewayConfig.ValidationConfig = &partitionv1.ValidationConfig{} } gatewayConfig.ValidationConfig.OpenapiSpec = openapiSpec - gatewayConfig.ValidationConfig.Enabled = true // Marshal updated config configBytes, err := proto.Marshal(&gatewayConfig) @@ -926,8 +774,7 @@ func (w *DeployWorkflow) Run(ctx hydra.WorkflowContext, req *DeployRequest) erro return db.Query.InsertDeploymentStep(stepCtx, w.db.RW(), db.InsertDeploymentStepParams{ DeploymentID: req.DeploymentID, Status: "completed", - Message: sql.NullString{String: "Version deployment completed successfully", Valid: true}, - ErrorMessage: sql.NullString{String: "", Valid: false}, + Message: "Deployment completed successfully", CreatedAt: time.Now().UnixMilli(), }) }) diff --git a/go/apps/ctrl/services/deployment/get_deployment.go b/go/apps/ctrl/services/deployment/get_deployment.go new file mode 100644 index 0000000000..d34e0ffb29 --- /dev/null +++ b/go/apps/ctrl/services/deployment/get_deployment.go @@ -0,0 +1,127 @@ +package deployment + +import ( + "context" + "database/sql" + "fmt" + + "connectrpc.com/connect" + ctrlv1 "github.com/unkeyed/unkey/go/gen/proto/ctrl/v1" + "github.com/unkeyed/unkey/go/pkg/db" +) + +func (s *Service) GetDeployment( + ctx context.Context, + req *connect.Request[ctrlv1.GetDeploymentRequest], +) (*connect.Response[ctrlv1.GetDeploymentResponse], error) { + // Query deployment from database + deployment, err := db.Query.FindDeploymentById(ctx, s.db.RO(), req.Msg.GetDeploymentId()) + if err != nil { + if db.IsNotFound(err) { + return nil, connect.NewError(connect.CodeNotFound, err) + } + s.logger.Error("failed to load deployment", "error", err, "deployment_id", req.Msg.GetDeploymentId()) + return nil, connect.NewError(connect.CodeInternal, fmt.Errorf("failed to load deployment")) + } + + // Convert database model to proto + protoDeployment := &ctrlv1.Deployment{ + Id: deployment.ID, + WorkspaceId: deployment.WorkspaceID, + ProjectId: deployment.ProjectID, + EnvironmentId: deployment.EnvironmentID, + Status: convertDbStatusToProto(deployment.Status), + CreatedAt: deployment.CreatedAt, + GitCommitSha: "", + GitBranch: "", + ErrorMessage: "", + EnvironmentVariables: nil, + Topology: nil, + UpdatedAt: 0, + Hostnames: nil, + RootfsImageId: "", + BuildId: "", + Steps: nil, + } + + if deployment.GitCommitSha.Valid { + protoDeployment.GitCommitSha = deployment.GitCommitSha.String + } + if deployment.GitBranch.Valid { + protoDeployment.GitBranch = deployment.GitBranch.String + } + if deployment.GitCommitMessage.Valid { + protoDeployment.GitCommitMessage = deployment.GitCommitMessage.String + } + if deployment.GitCommitAuthorName.Valid { + protoDeployment.GitCommitAuthorName = deployment.GitCommitAuthorName.String + } + // Email removed to avoid storing PII - TODO: implement GitHub API lookup + if deployment.GitCommitAuthorUsername.Valid { + protoDeployment.GitCommitAuthorUsername = deployment.GitCommitAuthorUsername.String + } + if deployment.GitCommitAuthorAvatarUrl.Valid { + protoDeployment.GitCommitAuthorAvatarUrl = deployment.GitCommitAuthorAvatarUrl.String + } + if deployment.GitCommitTimestamp.Valid { + protoDeployment.GitCommitTimestamp = deployment.GitCommitTimestamp.Int64 + } + if deployment.UpdatedAt.Valid { + protoDeployment.UpdatedAt = deployment.UpdatedAt.Int64 + } + + // Fetch deployment steps + deploymentSteps, err := db.Query.FindDeploymentStepsByDeploymentId(ctx, s.db.RO(), deployment.ID) + if err != nil { + s.logger.Warn("failed to fetch deployment steps", "error", err, "deployment_id", deployment.ID) + // Continue without steps rather than failing the entire request + } else { + protoSteps := make([]*ctrlv1.DeploymentStep, len(deploymentSteps)) + for i, step := range deploymentSteps { + protoSteps[i] = &ctrlv1.DeploymentStep{ + Status: string(step.Status), + CreatedAt: step.CreatedAt, + Message: step.Message, + } + } + protoDeployment.Steps = protoSteps + } + + // Fetch routes (hostnames) for this deployment + routes, err := db.Query.FindDomainsByDeploymentId(ctx, s.db.RO(), sql.NullString{Valid: true, String: req.Msg.GetDeploymentId()}) + if err != nil { + s.logger.Warn("failed to fetch domains for deployment", "error", err, "deployment_id", deployment.ID) + // Continue without hostnames rather than failing the entire request + } else { + hostnames := make([]string, len(routes)) + for i, route := range routes { + hostnames[i] = route.Domain + } + protoDeployment.Hostnames = hostnames + } + + res := connect.NewResponse(&ctrlv1.GetDeploymentResponse{ + Deployment: protoDeployment, + }) + + return res, nil +} + +func convertDbStatusToProto(status db.DeploymentsStatus) ctrlv1.DeploymentStatus { + switch status { + case db.DeploymentsStatusPending: + return ctrlv1.DeploymentStatus_DEPLOYMENT_STATUS_PENDING + case db.DeploymentsStatusBuilding: + return ctrlv1.DeploymentStatus_DEPLOYMENT_STATUS_BUILDING + case db.DeploymentsStatusDeploying: + return ctrlv1.DeploymentStatus_DEPLOYMENT_STATUS_DEPLOYING + case db.DeploymentsStatusNetwork: + return ctrlv1.DeploymentStatus_DEPLOYMENT_STATUS_NETWORK + case db.DeploymentsStatusReady: + return ctrlv1.DeploymentStatus_DEPLOYMENT_STATUS_READY + case db.DeploymentsStatusFailed: + return ctrlv1.DeploymentStatus_DEPLOYMENT_STATUS_FAILED + default: + return ctrlv1.DeploymentStatus_DEPLOYMENT_STATUS_UNSPECIFIED + } +} diff --git a/go/apps/ctrl/services/deployment/get_version.go b/go/apps/ctrl/services/deployment/get_version.go deleted file mode 100644 index 1c815f8ffe..0000000000 --- a/go/apps/ctrl/services/deployment/get_version.go +++ /dev/null @@ -1,144 +0,0 @@ -package deployment - -import ( - "context" - - "connectrpc.com/connect" - ctrlv1 "github.com/unkeyed/unkey/go/gen/proto/ctrl/v1" - "github.com/unkeyed/unkey/go/pkg/db" -) - -// GetVersion loads a deployment by ID and projects it into the ctrlv1.Version proto, including git metadata, build -// linkage, steps, and hostnames. Non-critical lookup failures (steps/hostnames/build) are logged and ignored to keep the endpoint resilient. -func (s *Service) GetVersion( - ctx context.Context, - req *connect.Request[ctrlv1.GetVersionRequest], -) (*connect.Response[ctrlv1.GetVersionResponse], error) { - // Query deployment from database - deployment, err := db.Query.FindDeploymentById(ctx, s.db.RO(), req.Msg.GetVersionId()) - if err != nil { - return nil, connect.NewError(connect.CodeNotFound, err) - } - - // Convert database model to proto - protoVersion := &ctrlv1.Version{ - Id: deployment.ID, - WorkspaceId: deployment.WorkspaceID, - ProjectId: deployment.ProjectID, - EnvironmentId: string(deployment.Environment), - Status: convertDbStatusToProto(string(deployment.Status)), - CreatedAt: deployment.CreatedAt, - GitCommitSha: "", - GitBranch: "", - GitCommitMessage: "", - GitCommitAuthorName: "", - GitCommitAuthorUsername: "", - GitCommitAuthorAvatarUrl: "", - GitCommitTimestamp: 0, - ErrorMessage: "", - EnvironmentVariables: nil, - Topology: nil, - UpdatedAt: 0, - Hostnames: nil, - RootfsImageId: "", - BuildId: "", - Steps: nil, - } - - if deployment.GitCommitSha.Valid { - protoVersion.GitCommitSha = deployment.GitCommitSha.String - } - if deployment.GitBranch.Valid { - protoVersion.GitBranch = deployment.GitBranch.String - } - if deployment.GitCommitMessage.Valid { - protoVersion.GitCommitMessage = deployment.GitCommitMessage.String - } - if deployment.GitCommitAuthorName.Valid { - protoVersion.GitCommitAuthorName = deployment.GitCommitAuthorName.String - } - // Email removed to avoid storing PII - TODO: implement GitHub API lookup - if deployment.GitCommitAuthorUsername.Valid { - protoVersion.GitCommitAuthorUsername = deployment.GitCommitAuthorUsername.String - } - if deployment.GitCommitAuthorAvatarUrl.Valid { - protoVersion.GitCommitAuthorAvatarUrl = deployment.GitCommitAuthorAvatarUrl.String - } - if deployment.GitCommitTimestamp.Valid { - protoVersion.GitCommitTimestamp = deployment.GitCommitTimestamp.Int64 - } - if deployment.UpdatedAt.Valid { - protoVersion.UpdatedAt = deployment.UpdatedAt.Int64 - } - if deployment.RootfsImageID != "" { - protoVersion.RootfsImageId = deployment.RootfsImageID - } - - // Find the latest build for this deployment - build, err := db.Query.FindLatestBuildByDeploymentId(ctx, s.db.RO(), deployment.ID) - if err == nil { - protoVersion.BuildId = build.ID - } - - // Fetch deployment steps - deploymentSteps, err := db.Query.FindDeploymentStepsByDeploymentId(ctx, s.db.RO(), deployment.ID) - if err != nil { - s.logger.Warn("failed to fetch deployment steps", "error", err, "deployment_id", deployment.ID) - // Continue without steps rather than failing the entire request - } else { - protoSteps := make([]*ctrlv1.VersionStep, len(deploymentSteps)) - for i, step := range deploymentSteps { - protoSteps[i] = &ctrlv1.VersionStep{ - Status: string(step.Status), - CreatedAt: step.CreatedAt, - Message: "", - ErrorMessage: "", - } - if step.Message.Valid { - protoSteps[i].Message = step.Message.String - } - if step.ErrorMessage.Valid { - protoSteps[i].ErrorMessage = step.ErrorMessage.String - } - } - protoVersion.Steps = protoSteps - } - - // Fetch routes (hostnames) for this deployment - routes, err := db.Query.FindHostnameRoutesByDeploymentId(ctx, s.db.RO(), deployment.ID) - if err != nil { - s.logger.Warn("failed to fetch routes for deployment", "error", err, "deployment_id", deployment.ID) - // Continue without hostnames rather than failing the entire request - } else { - hostnames := make([]string, len(routes)) - for i, route := range routes { - hostnames[i] = route.Hostname - } - protoVersion.Hostnames = hostnames - } - - res := connect.NewResponse(&ctrlv1.GetVersionResponse{ - Version: protoVersion, - }) - - return res, nil -} - -func convertDbStatusToProto(status string) ctrlv1.VersionStatus { - switch status { - case "pending": - return ctrlv1.VersionStatus_VERSION_STATUS_PENDING - case "building": - return ctrlv1.VersionStatus_VERSION_STATUS_BUILDING - case "deploying": - return ctrlv1.VersionStatus_VERSION_STATUS_DEPLOYING - case "active": - return ctrlv1.VersionStatus_VERSION_STATUS_ACTIVE - case "failed": - return ctrlv1.VersionStatus_VERSION_STATUS_FAILED - case "archived": - return ctrlv1.VersionStatus_VERSION_STATUS_ARCHIVED - default: - return ctrlv1.VersionStatus_VERSION_STATUS_UNSPECIFIED - } -} diff --git a/go/apps/ctrl/services/deployment/service.go b/go/apps/ctrl/services/deployment/service.go index 27eeab1209..f85ce853a1 100644 --- a/go/apps/ctrl/services/deployment/service.go +++ b/go/apps/ctrl/services/deployment/service.go @@ -8,7 +8,7 @@ import ( ) type Service struct { - ctrlv1connect.UnimplementedVersionServiceHandler + ctrlv1connect.UnimplementedDeploymentServiceHandler db db.Database partitionDB db.Database hydraEngine *hydra.Engine @@ -17,10 +17,10 @@ type Service struct { func New(database db.Database, partitionDB db.Database, hydraEngine *hydra.Engine, logger logging.Logger) *Service { return &Service{ - UnimplementedVersionServiceHandler: ctrlv1connect.UnimplementedVersionServiceHandler{}, - db: database, - partitionDB: partitionDB, - hydraEngine: hydraEngine, - logger: logger, + UnimplementedDeploymentServiceHandler: ctrlv1connect.UnimplementedDeploymentServiceHandler{}, + db: database, + partitionDB: partitionDB, + hydraEngine: hydraEngine, + logger: logger, } } diff --git a/go/apps/gw/services/auth/auth.go b/go/apps/gw/services/auth/auth.go index bfab5d00c8..af94a96103 100644 --- a/go/apps/gw/services/auth/auth.go +++ b/go/apps/gw/services/auth/auth.go @@ -39,7 +39,7 @@ func New(config Config) (Authenticator, error) { // Authenticate processes API key authentication for the request. func (a *authenticator) Authenticate(ctx context.Context, sess *server.Session, config *partitionv1.GatewayConfig) error { // Skip authentication if not configured or not enabled - if config.AuthConfig == nil || !config.AuthConfig.Enabled || !config.AuthConfig.RequireApiKey { + if config.AuthConfig == nil { return nil } @@ -103,11 +103,11 @@ func (a *authenticator) verifyAPIKey(ctx context.Context, sess *server.Session, } // Validate keyspace - ensure key belongs to the correct keyspace - if key.Key.KeyAuthID != config.AuthConfig.KeyspaceId { + if key.Key.KeyAuthID != config.AuthConfig.KeyAuthId { a.logger.Warn("key belongs to different keyspace", "requestId", sess.RequestID(), "key_id", key.Key.ID, - "expected_keyspace", config.AuthConfig.KeyspaceId, + "expected_keyspace", config.AuthConfig.KeyAuthId, "actual_keyspace", key.Key.KeyAuthID, ) diff --git a/go/apps/gw/services/routing/service.go b/go/apps/gw/services/routing/service.go index 361e326228..d2c894c95f 100644 --- a/go/apps/gw/services/routing/service.go +++ b/go/apps/gw/services/routing/service.go @@ -90,14 +90,14 @@ func (s *service) GetConfig(ctx context.Context, host string) (*partitionv1.Gate return config, nil } -// SelectVM picks an available VM from the gateway's VM list using simple round-robin. +// SelectVM picks an available VM from the gateway's VM list using random selection. func (s *service) SelectVM(ctx context.Context, config *partitionv1.GatewayConfig) (*url.URL, error) { - if !config.IsEnabled { - return nil, fmt.Errorf("gateway %s is disabled", config.DeploymentId) + if !config.Deployment.IsEnabled { + return nil, fmt.Errorf("gateway %s is disabled", config.Deployment.Id) } if len(config.Vms) == 0 { - return nil, fmt.Errorf("no VMs available for gateway %s", config.DeploymentId) + return nil, fmt.Errorf("no VMs available for gateway %s", config.Deployment.Id) } availableVms := make([]db.Vm, 0) @@ -127,13 +127,13 @@ func (s *service) SelectVM(ctx context.Context, config *partitionv1.GatewayConfi } if len(availableVms) == 0 { - return nil, fmt.Errorf("no available VMs for gateway %s", config.DeploymentId) + return nil, fmt.Errorf("no available VMs for gateway %s", config.Deployment.Id) } // select random VM selectedVM := availableVms[rand.Intn(len(availableVms))] - fullUrl := fmt.Sprintf("http://%s:%d", selectedVM.PrivateIp.String, selectedVM.Port.Int32) + fullUrl := fmt.Sprintf("http://%s", selectedVM.Address.String) targetURL, err := url.Parse(fullUrl) if err != nil { diff --git a/go/apps/gw/services/validation/validator.go b/go/apps/gw/services/validation/validator.go index 01832b9fc7..2d21fca70f 100644 --- a/go/apps/gw/services/validation/validator.go +++ b/go/apps/gw/services/validation/validator.go @@ -42,7 +42,7 @@ func New(config Config) (*Service, error) { // Validate implements the Validator interface. func (s *Service) Validate(ctx context.Context, sess *server.Session, config *partitionv1.GatewayConfig) error { // Skip validation if not enabled - if config.ValidationConfig == nil || !config.ValidationConfig.Enabled { + if config.ValidationConfig == nil { return nil } @@ -50,7 +50,7 @@ func (s *Service) Validate(ctx context.Context, sess *server.Session, config *pa if config.ValidationConfig.OpenapiSpec == "" { s.logger.Warn("validation enabled but no OpenAPI spec configured", "requestId", sess.RequestID(), - "deploymentId", config.DeploymentId, + "deploymentId", config.Deployment.Id, ) return nil } @@ -60,11 +60,11 @@ func (s *Service) Validate(ctx context.Context, sess *server.Session, config *pa defer span.End() // Get or create validator for this spec - v, err := s.getOrCreateValidator(ctx, config.DeploymentId, config.ValidationConfig.OpenapiSpec) + v, err := s.getOrCreateValidator(ctx, config.Deployment.Id, config.ValidationConfig.OpenapiSpec) if err != nil { s.logger.Error("failed to get validator", "requestId", sess.RequestID(), - "deploymentId", config.DeploymentId, + "deploymentId", config.Deployment.Id, "error", err.Error(), ) // Don't fail the request if we can't create a validator @@ -79,7 +79,7 @@ func (s *Service) Validate(ctx context.Context, sess *server.Session, config *pa if valid { s.logger.Debug("request validation passed", "requestId", sess.RequestID(), - "deploymentId", config.DeploymentId, + "deploymentId", config.Deployment.Id, "method", req.Method, "path", req.URL.Path, ) @@ -91,7 +91,7 @@ func (s *Service) Validate(ctx context.Context, sess *server.Session, config *pa s.logger.Warn("request validation failed", "requestId", sess.RequestID(), - "deploymentId", config.DeploymentId, + "deploymentId", config.Deployment.Id, "method", req.Method, "path", req.URL.Path, "errors", len(validationErr.Errors), diff --git a/go/cmd/ctrl/main.go b/go/cmd/ctrl/main.go index 9cfcdd71eb..1298e48cea 100644 --- a/go/cmd/ctrl/main.go +++ b/go/cmd/ctrl/main.go @@ -8,7 +8,6 @@ import ( "github.com/unkeyed/unkey/go/pkg/clock" "github.com/unkeyed/unkey/go/pkg/tls" "github.com/unkeyed/unkey/go/pkg/uid" - "github.com/unkeyed/unkey/go/pkg/vault/storage" ) var Cmd = &cli.Command{ @@ -62,15 +61,17 @@ var Cmd = &cli.Command{ // Vault Configuration cli.StringSlice("vault-master-keys", "Vault master keys for encryption", - cli.EnvVar("UNKEY_VAULT_MASTER_KEYS")), + cli.Required(), cli.EnvVar("UNKEY_VAULT_MASTER_KEYS")), cli.String("vault-s3-url", "S3 Compatible Endpoint URL", - cli.EnvVar("UNKEY_VAULT_S3_URL")), + cli.Required(), cli.EnvVar("UNKEY_VAULT_S3_URL")), cli.String("vault-s3-bucket", "S3 bucket name", - cli.EnvVar("UNKEY_VAULT_S3_BUCKET")), + cli.Required(), cli.EnvVar("UNKEY_VAULT_S3_BUCKET")), cli.String("vault-s3-access-key-id", "S3 access key ID", - cli.EnvVar("UNKEY_VAULT_S3_ACCESS_KEY_ID")), + cli.Required(), cli.EnvVar("UNKEY_VAULT_S3_ACCESS_KEY_ID")), cli.String("vault-s3-access-key-secret", "S3 secret access key", - cli.EnvVar("UNKEY_VAULT_S3_ACCESS_KEY_SECRET")), + cli.Required(), cli.EnvVar("UNKEY_VAULT_S3_ACCESS_KEY_SECRET")), + + cli.Bool("acme-enabled", "Enable Let's Encrypt for acme challenges", cli.EnvVar("UNKEY_ACME_ENABLED")), }, Action: action, } @@ -93,16 +94,6 @@ func action(ctx context.Context, cmd *cli.Command) error { } } - var vaultS3Config *storage.S3Config - if cmd.String("vault-s3-url") != "" { - vaultS3Config = &storage.S3Config{ - S3URL: cmd.String("vault-s3-url"), - S3Bucket: cmd.String("vault-s3-bucket"), - S3AccessKeySecret: cmd.String("vault-s3-access-key-secret"), - S3AccessKeyID: cmd.String("vault-s3-access-key-id"), - } - } - config := ctrl.Config{ // Basic configuration Platform: cmd.String("platform"), @@ -130,7 +121,14 @@ func action(ctx context.Context, cmd *cli.Command) error { // Vault configuration VaultMasterKeys: cmd.StringSlice("vault-master-keys"), - VaultS3: vaultS3Config, + VaultS3: ctrl.S3Config{ + URL: cmd.String("vault-s3-url"), + Bucket: cmd.String("vault-s3-bucket"), + AccessKeySecret: cmd.String("vault-s3-access-key-secret"), + AccessKeyID: cmd.String("vault-s3-access-key-id"), + }, + + AcmeEnabled: cmd.Bool("acme-enabled"), // Common Clock: clock.New(), diff --git a/go/cmd/deploy/control_plane.go b/go/cmd/deploy/control_plane.go index 553b058819..5d88eec7c0 100644 --- a/go/cmd/deploy/control_plane.go +++ b/go/cmd/deploy/control_plane.go @@ -19,28 +19,28 @@ import ( // DeploymentStatusEvent represents a status change event type DeploymentStatusEvent struct { DeploymentID string - PreviousStatus ctrlv1.VersionStatus - CurrentStatus ctrlv1.VersionStatus - Version *ctrlv1.Version + PreviousStatus ctrlv1.DeploymentStatus + CurrentStatus ctrlv1.DeploymentStatus + Deployment *ctrlv1.Deployment } // DeploymentStepEvent represents a step update event type DeploymentStepEvent struct { DeploymentID string - Step *ctrlv1.VersionStep - Status ctrlv1.VersionStatus + Step *ctrlv1.DeploymentStep + Status ctrlv1.DeploymentStatus } // ControlPlaneClient handles API operations with the control plane type ControlPlaneClient struct { - client ctrlv1connect.VersionServiceClient + client ctrlv1connect.DeploymentServiceClient opts DeployOptions } // NewControlPlaneClient creates a new control plane client func NewControlPlaneClient(opts DeployOptions) *ControlPlaneClient { httpClient := &http.Client{} - client := ctrlv1connect.NewVersionServiceClient(httpClient, opts.ControlPlaneURL) + client := ctrlv1connect.NewDeploymentServiceClient(httpClient, opts.ControlPlaneURL) return &ControlPlaneClient{ client: client, @@ -50,7 +50,7 @@ func NewControlPlaneClient(opts DeployOptions) *ControlPlaneClient { // CreateDeployment creates a new deployment in the control plane func (c *ControlPlaneClient) CreateDeployment(ctx context.Context, dockerImage string) (string, error) { - createReq := connect.NewRequest(&ctrlv1.CreateVersionRequest{ + createReq := connect.NewRequest(&ctrlv1.CreateDeploymentRequest{ WorkspaceId: c.opts.WorkspaceID, ProjectId: c.opts.ProjectID, KeyspaceId: c.opts.KeyspaceID, @@ -64,12 +64,12 @@ func (c *ControlPlaneClient) CreateDeployment(ctx context.Context, dockerImage s createReq.Header().Set("Authorization", "Bearer "+c.opts.AuthToken) - createResp, err := c.client.CreateVersion(ctx, createReq) + createResp, err := c.client.CreateDeployment(ctx, createReq) if err != nil { return "", c.handleCreateDeploymentError(err) } - deploymentID := createResp.Msg.GetVersionId() + deploymentID := createResp.Msg.GetDeploymentId() if deploymentID == "" { return "", fmt.Errorf("empty deployment ID returned from control plane") } @@ -78,18 +78,18 @@ func (c *ControlPlaneClient) CreateDeployment(ctx context.Context, dockerImage s } // GetDeployment retrieves deployment information from the control plane -func (c *ControlPlaneClient) GetDeployment(ctx context.Context, deploymentId string) (*ctrlv1.Version, error) { - getReq := connect.NewRequest(&ctrlv1.GetVersionRequest{ - VersionId: deploymentId, +func (c *ControlPlaneClient) GetDeployment(ctx context.Context, deploymentId string) (*ctrlv1.Deployment, error) { + getReq := connect.NewRequest(&ctrlv1.GetDeploymentRequest{ + DeploymentId: deploymentId, }) getReq.Header().Set("Authorization", "Bearer "+c.opts.AuthToken) - getResp, err := c.client.GetVersion(ctx, getReq) + getResp, err := c.client.GetDeployment(ctx, getReq) if err != nil { return nil, err } - return getResp.Msg.GetVersion(), nil + return getResp.Msg.GetDeployment(), nil } // PollDeploymentStatus polls for deployment changes and calls event handlers @@ -107,7 +107,7 @@ func (c *ControlPlaneClient) PollDeploymentStatus( // Track processed steps by creation time to avoid duplicates processedSteps := make(map[int64]bool) - lastStatus := ctrlv1.VersionStatus_VERSION_STATUS_UNSPECIFIED + lastStatus := ctrlv1.DeploymentStatus_DEPLOYMENT_STATUS_UNSPECIFIED for { select { @@ -116,13 +116,13 @@ func (c *ControlPlaneClient) PollDeploymentStatus( case <-timeout.C: return fmt.Errorf("deployment timeout after 5 minutes") case <-ticker.C: - version, err := c.GetDeployment(ctx, deploymentID) + deployment, err := c.GetDeployment(ctx, deploymentID) if err != nil { logger.Debug("Failed to get deployment status", "error", err, "deployment_id", deploymentID) continue } - currentStatus := version.GetStatus() + currentStatus := deployment.GetStatus() // Handle deployment status changes if currentStatus != lastStatus { @@ -130,7 +130,7 @@ func (c *ControlPlaneClient) PollDeploymentStatus( DeploymentID: deploymentID, PreviousStatus: lastStatus, CurrentStatus: currentStatus, - Version: version, + Deployment: deployment, } if err := onStatusChange(event); err != nil { @@ -140,12 +140,12 @@ func (c *ControlPlaneClient) PollDeploymentStatus( } // Process new step updates - if err := c.processNewSteps(deploymentID, version.GetSteps(), processedSteps, currentStatus, onStepUpdate); err != nil { + if err := c.processNewSteps(deploymentID, deployment.GetSteps(), processedSteps, currentStatus, onStepUpdate); err != nil { return err } // Check for completion - if currentStatus == ctrlv1.VersionStatus_VERSION_STATUS_ACTIVE { + if currentStatus == ctrlv1.DeploymentStatus_DEPLOYMENT_STATUS_READY { return nil } } @@ -155,9 +155,9 @@ func (c *ControlPlaneClient) PollDeploymentStatus( // processNewSteps processes new deployment steps and calls the event handler func (c *ControlPlaneClient) processNewSteps( deploymentID string, - steps []*ctrlv1.VersionStep, + steps []*ctrlv1.DeploymentStep, processedSteps map[int64]bool, - currentStatus ctrlv1.VersionStatus, + currentStatus ctrlv1.DeploymentStatus, onStepUpdate func(DeploymentStepEvent) error, ) error { for _, step := range steps { @@ -198,13 +198,13 @@ func (c *ControlPlaneClient) processNewSteps( } // getFailureMessage extracts failure message from version -func (c *ControlPlaneClient) getFailureMessage(version *ctrlv1.Version) string { - if version.GetErrorMessage() != "" { - return version.GetErrorMessage() +func (c *ControlPlaneClient) getFailureMessage(deployment *ctrlv1.Deployment) string { + if deployment.GetErrorMessage() != "" { + return deployment.GetErrorMessage() } // Check for error in steps - for _, step := range version.GetSteps() { + for _, step := range deployment.GetSteps() { if step.GetErrorMessage() != "" { return step.GetErrorMessage() } diff --git a/go/cmd/deploy/main.go b/go/cmd/deploy/main.go index 9dd2256d33..5ec27defe3 100644 --- a/go/cmd/deploy/main.go +++ b/go/cmd/deploy/main.go @@ -282,17 +282,17 @@ func executeDeploy(ctx context.Context, opts DeployOptions) error { } ui.PrintSuccess(fmt.Sprintf("Deployment created: %s", deploymentId)) - // Track final version for completion info - var finalVersion *ctrlv1.Version + // Track final deployment for completion info + var finalDeployment *ctrlv1.Deployment // Handle deployment status changes onStatusChange := func(event DeploymentStatusEvent) error { switch event.CurrentStatus { - case ctrlv1.VersionStatus_VERSION_STATUS_FAILED: - return handleVersionFailure(controlPlane, event.Version, ui) - case ctrlv1.VersionStatus_VERSION_STATUS_ACTIVE: - // Store version but don't print success, wait for polling to complete - finalVersion = event.Version + case ctrlv1.DeploymentStatus_DEPLOYMENT_STATUS_FAILED: + return handleDeploymentFailure(controlPlane, event.Deployment, ui) + case ctrlv1.DeploymentStatus_DEPLOYMENT_STATUS_READY: + // Store deployment but don't print success, wait for polling to complete + finalDeployment = event.Deployment } return nil } @@ -310,11 +310,11 @@ func executeDeploy(ctx context.Context, opts DeployOptions) error { } // Print final success message only after all polling is complete - if finalVersion != nil { + if finalDeployment != nil { ui.CompleteCurrentStep(MsgDeploymentStepCompleted, true) ui.PrintSuccess(MsgDeploymentCompleted) fmt.Printf("\n") - printCompletionInfo(finalVersion) + printCompletionInfo(finalDeployment) fmt.Printf("\n") } @@ -357,8 +357,8 @@ func handleStepUpdate(event DeploymentStepEvent, ui *UI) error { return nil } -func handleVersionFailure(controlPlane *ControlPlaneClient, version *ctrlv1.Version, ui *UI) error { - errorMsg := controlPlane.getFailureMessage(version) +func handleDeploymentFailure(controlPlane *ControlPlaneClient, deployment *ctrlv1.Deployment, ui *UI) error { + errorMsg := controlPlane.getFailureMessage(deployment) ui.CompleteCurrentStep(MsgDeploymentFailed, false) ui.PrintError(MsgDeploymentFailed) ui.PrintErrorDetails(errorMsg) @@ -386,22 +386,22 @@ func printSourceInfo(opts DeployOptions, gitInfo git.Info) { fmt.Printf("\n") } -func printCompletionInfo(version *ctrlv1.Version) { - if version == nil || version.GetId() == "" { +func printCompletionInfo(deployment *ctrlv1.Deployment) { + if deployment == nil || deployment.GetId() == "" { fmt.Printf("✓ Deployment completed\n") return } fmt.Println() fmt.Println(CompletionTitle) - fmt.Printf(" %s: %s\n", CompletionDeploymentID, version.GetId()) + fmt.Printf(" %s: %s\n", CompletionDeploymentID, deployment.GetId()) fmt.Printf(" %s: %s\n", CompletionStatus, CompletionReady) fmt.Printf(" %s: %s\n", CompletionEnvironment, DefaultEnvironment) fmt.Println() fmt.Println(CompletionDomains) - hostnames := version.GetHostnames() + hostnames := deployment.GetHostnames() if len(hostnames) > 0 { for _, hostname := range hostnames { if strings.HasPrefix(hostname, LocalhostPrefix) { diff --git a/go/gen/proto/ctrl/v1/ctrlv1connect/deployment.connect.go b/go/gen/proto/ctrl/v1/ctrlv1connect/deployment.connect.go new file mode 100644 index 0000000000..bc1fa94dfd --- /dev/null +++ b/go/gen/proto/ctrl/v1/ctrlv1connect/deployment.connect.go @@ -0,0 +1,147 @@ +// Code generated by protoc-gen-connect-go. DO NOT EDIT. +// +// Source: proto/ctrl/v1/deployment.proto + +package ctrlv1connect + +import ( + connect "connectrpc.com/connect" + context "context" + errors "errors" + v1 "github.com/unkeyed/unkey/go/gen/proto/ctrl/v1" + http "net/http" + strings "strings" +) + +// This is a compile-time assertion to ensure that this generated file and the connect package are +// compatible. If you get a compiler error that this constant is not defined, this code was +// generated with a version of connect newer than the one compiled into your binary. You can fix the +// problem by either regenerating this code with an older version of connect or updating the connect +// version compiled into your binary. +const _ = connect.IsAtLeastVersion1_13_0 + +const ( + // DeploymentServiceName is the fully-qualified name of the DeploymentService service. + DeploymentServiceName = "ctrl.v1.DeploymentService" +) + +// These constants are the fully-qualified names of the RPCs defined in this package. They're +// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route. +// +// Note that these are different from the fully-qualified method names used by +// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to +// reflection-formatted method names, remove the leading slash and convert the remaining slash to a +// period. +const ( + // DeploymentServiceCreateDeploymentProcedure is the fully-qualified name of the DeploymentService's + // CreateDeployment RPC. + DeploymentServiceCreateDeploymentProcedure = "/ctrl.v1.DeploymentService/CreateDeployment" + // DeploymentServiceGetDeploymentProcedure is the fully-qualified name of the DeploymentService's + // GetDeployment RPC. + DeploymentServiceGetDeploymentProcedure = "/ctrl.v1.DeploymentService/GetDeployment" +) + +// These variables are the protoreflect.Descriptor objects for the RPCs defined in this package. +var ( + deploymentServiceServiceDescriptor = v1.File_proto_ctrl_v1_deployment_proto.Services().ByName("DeploymentService") + deploymentServiceCreateDeploymentMethodDescriptor = deploymentServiceServiceDescriptor.Methods().ByName("CreateDeployment") + deploymentServiceGetDeploymentMethodDescriptor = deploymentServiceServiceDescriptor.Methods().ByName("GetDeployment") +) + +// DeploymentServiceClient is a client for the ctrl.v1.DeploymentService service. +type DeploymentServiceClient interface { + // Create a new deployment + CreateDeployment(context.Context, *connect.Request[v1.CreateDeploymentRequest]) (*connect.Response[v1.CreateDeploymentResponse], error) + // Get deployment details + GetDeployment(context.Context, *connect.Request[v1.GetDeploymentRequest]) (*connect.Response[v1.GetDeploymentResponse], error) +} + +// NewDeploymentServiceClient constructs a client for the ctrl.v1.DeploymentService service. By +// default, it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, +// and sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the +// connect.WithGRPC() or connect.WithGRPCWeb() options. +// +// The URL supplied here should be the base URL for the Connect or gRPC server (for example, +// http://api.acme.com or https://acme.com/grpc). +func NewDeploymentServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) DeploymentServiceClient { + baseURL = strings.TrimRight(baseURL, "/") + return &deploymentServiceClient{ + createDeployment: connect.NewClient[v1.CreateDeploymentRequest, v1.CreateDeploymentResponse]( + httpClient, + baseURL+DeploymentServiceCreateDeploymentProcedure, + connect.WithSchema(deploymentServiceCreateDeploymentMethodDescriptor), + connect.WithClientOptions(opts...), + ), + getDeployment: connect.NewClient[v1.GetDeploymentRequest, v1.GetDeploymentResponse]( + httpClient, + baseURL+DeploymentServiceGetDeploymentProcedure, + connect.WithSchema(deploymentServiceGetDeploymentMethodDescriptor), + connect.WithClientOptions(opts...), + ), + } +} + +// deploymentServiceClient implements DeploymentServiceClient. +type deploymentServiceClient struct { + createDeployment *connect.Client[v1.CreateDeploymentRequest, v1.CreateDeploymentResponse] + getDeployment *connect.Client[v1.GetDeploymentRequest, v1.GetDeploymentResponse] +} + +// CreateDeployment calls ctrl.v1.DeploymentService.CreateDeployment. +func (c *deploymentServiceClient) CreateDeployment(ctx context.Context, req *connect.Request[v1.CreateDeploymentRequest]) (*connect.Response[v1.CreateDeploymentResponse], error) { + return c.createDeployment.CallUnary(ctx, req) +} + +// GetDeployment calls ctrl.v1.DeploymentService.GetDeployment. +func (c *deploymentServiceClient) GetDeployment(ctx context.Context, req *connect.Request[v1.GetDeploymentRequest]) (*connect.Response[v1.GetDeploymentResponse], error) { + return c.getDeployment.CallUnary(ctx, req) +} + +// DeploymentServiceHandler is an implementation of the ctrl.v1.DeploymentService service. +type DeploymentServiceHandler interface { + // Create a new deployment + CreateDeployment(context.Context, *connect.Request[v1.CreateDeploymentRequest]) (*connect.Response[v1.CreateDeploymentResponse], error) + // Get deployment details + GetDeployment(context.Context, *connect.Request[v1.GetDeploymentRequest]) (*connect.Response[v1.GetDeploymentResponse], error) +} + +// NewDeploymentServiceHandler builds an HTTP handler from the service implementation. It returns +// the path on which to mount the handler and the handler itself. +// +// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf +// and JSON codecs. They also support gzip compression. +func NewDeploymentServiceHandler(svc DeploymentServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { + deploymentServiceCreateDeploymentHandler := connect.NewUnaryHandler( + DeploymentServiceCreateDeploymentProcedure, + svc.CreateDeployment, + connect.WithSchema(deploymentServiceCreateDeploymentMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + deploymentServiceGetDeploymentHandler := connect.NewUnaryHandler( + DeploymentServiceGetDeploymentProcedure, + svc.GetDeployment, + connect.WithSchema(deploymentServiceGetDeploymentMethodDescriptor), + connect.WithHandlerOptions(opts...), + ) + return "/ctrl.v1.DeploymentService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + switch r.URL.Path { + case DeploymentServiceCreateDeploymentProcedure: + deploymentServiceCreateDeploymentHandler.ServeHTTP(w, r) + case DeploymentServiceGetDeploymentProcedure: + deploymentServiceGetDeploymentHandler.ServeHTTP(w, r) + default: + http.NotFound(w, r) + } + }) +} + +// UnimplementedDeploymentServiceHandler returns CodeUnimplemented from all methods. +type UnimplementedDeploymentServiceHandler struct{} + +func (UnimplementedDeploymentServiceHandler) CreateDeployment(context.Context, *connect.Request[v1.CreateDeploymentRequest]) (*connect.Response[v1.CreateDeploymentResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("ctrl.v1.DeploymentService.CreateDeployment is not implemented")) +} + +func (UnimplementedDeploymentServiceHandler) GetDeployment(context.Context, *connect.Request[v1.GetDeploymentRequest]) (*connect.Response[v1.GetDeploymentResponse], error) { + return nil, connect.NewError(connect.CodeUnimplemented, errors.New("ctrl.v1.DeploymentService.GetDeployment is not implemented")) +} diff --git a/go/gen/proto/ctrl/v1/ctrlv1connect/version.connect.go b/go/gen/proto/ctrl/v1/ctrlv1connect/version.connect.go deleted file mode 100644 index 168737ab0b..0000000000 --- a/go/gen/proto/ctrl/v1/ctrlv1connect/version.connect.go +++ /dev/null @@ -1,147 +0,0 @@ -// Code generated by protoc-gen-connect-go. DO NOT EDIT. -// -// Source: proto/ctrl/v1/version.proto - -package ctrlv1connect - -import ( - connect "connectrpc.com/connect" - context "context" - errors "errors" - v1 "github.com/unkeyed/unkey/go/gen/proto/ctrl/v1" - http "net/http" - strings "strings" -) - -// This is a compile-time assertion to ensure that this generated file and the connect package are -// compatible. If you get a compiler error that this constant is not defined, this code was -// generated with a version of connect newer than the one compiled into your binary. You can fix the -// problem by either regenerating this code with an older version of connect or updating the connect -// version compiled into your binary. -const _ = connect.IsAtLeastVersion1_13_0 - -const ( - // VersionServiceName is the fully-qualified name of the VersionService service. - VersionServiceName = "ctrl.v1.VersionService" -) - -// These constants are the fully-qualified names of the RPCs defined in this package. They're -// exposed at runtime as Spec.Procedure and as the final two segments of the HTTP route. -// -// Note that these are different from the fully-qualified method names used by -// google.golang.org/protobuf/reflect/protoreflect. To convert from these constants to -// reflection-formatted method names, remove the leading slash and convert the remaining slash to a -// period. -const ( - // VersionServiceCreateVersionProcedure is the fully-qualified name of the VersionService's - // CreateVersion RPC. - VersionServiceCreateVersionProcedure = "/ctrl.v1.VersionService/CreateVersion" - // VersionServiceGetVersionProcedure is the fully-qualified name of the VersionService's GetVersion - // RPC. - VersionServiceGetVersionProcedure = "/ctrl.v1.VersionService/GetVersion" -) - -// These variables are the protoreflect.Descriptor objects for the RPCs defined in this package. -var ( - versionServiceServiceDescriptor = v1.File_proto_ctrl_v1_version_proto.Services().ByName("VersionService") - versionServiceCreateVersionMethodDescriptor = versionServiceServiceDescriptor.Methods().ByName("CreateVersion") - versionServiceGetVersionMethodDescriptor = versionServiceServiceDescriptor.Methods().ByName("GetVersion") -) - -// VersionServiceClient is a client for the ctrl.v1.VersionService service. -type VersionServiceClient interface { - // Create a new version - CreateVersion(context.Context, *connect.Request[v1.CreateVersionRequest]) (*connect.Response[v1.CreateVersionResponse], error) - // Get version details - GetVersion(context.Context, *connect.Request[v1.GetVersionRequest]) (*connect.Response[v1.GetVersionResponse], error) -} - -// NewVersionServiceClient constructs a client for the ctrl.v1.VersionService service. By default, -// it uses the Connect protocol with the binary Protobuf Codec, asks for gzipped responses, and -// sends uncompressed requests. To use the gRPC or gRPC-Web protocols, supply the connect.WithGRPC() -// or connect.WithGRPCWeb() options. -// -// The URL supplied here should be the base URL for the Connect or gRPC server (for example, -// http://api.acme.com or https://acme.com/grpc). -func NewVersionServiceClient(httpClient connect.HTTPClient, baseURL string, opts ...connect.ClientOption) VersionServiceClient { - baseURL = strings.TrimRight(baseURL, "/") - return &versionServiceClient{ - createVersion: connect.NewClient[v1.CreateVersionRequest, v1.CreateVersionResponse]( - httpClient, - baseURL+VersionServiceCreateVersionProcedure, - connect.WithSchema(versionServiceCreateVersionMethodDescriptor), - connect.WithClientOptions(opts...), - ), - getVersion: connect.NewClient[v1.GetVersionRequest, v1.GetVersionResponse]( - httpClient, - baseURL+VersionServiceGetVersionProcedure, - connect.WithSchema(versionServiceGetVersionMethodDescriptor), - connect.WithClientOptions(opts...), - ), - } -} - -// versionServiceClient implements VersionServiceClient. -type versionServiceClient struct { - createVersion *connect.Client[v1.CreateVersionRequest, v1.CreateVersionResponse] - getVersion *connect.Client[v1.GetVersionRequest, v1.GetVersionResponse] -} - -// CreateVersion calls ctrl.v1.VersionService.CreateVersion. -func (c *versionServiceClient) CreateVersion(ctx context.Context, req *connect.Request[v1.CreateVersionRequest]) (*connect.Response[v1.CreateVersionResponse], error) { - return c.createVersion.CallUnary(ctx, req) -} - -// GetVersion calls ctrl.v1.VersionService.GetVersion. -func (c *versionServiceClient) GetVersion(ctx context.Context, req *connect.Request[v1.GetVersionRequest]) (*connect.Response[v1.GetVersionResponse], error) { - return c.getVersion.CallUnary(ctx, req) -} - -// VersionServiceHandler is an implementation of the ctrl.v1.VersionService service. -type VersionServiceHandler interface { - // Create a new version - CreateVersion(context.Context, *connect.Request[v1.CreateVersionRequest]) (*connect.Response[v1.CreateVersionResponse], error) - // Get version details - GetVersion(context.Context, *connect.Request[v1.GetVersionRequest]) (*connect.Response[v1.GetVersionResponse], error) -} - -// NewVersionServiceHandler builds an HTTP handler from the service implementation. It returns the -// path on which to mount the handler and the handler itself. -// -// By default, handlers support the Connect, gRPC, and gRPC-Web protocols with the binary Protobuf -// and JSON codecs. They also support gzip compression. -func NewVersionServiceHandler(svc VersionServiceHandler, opts ...connect.HandlerOption) (string, http.Handler) { - versionServiceCreateVersionHandler := connect.NewUnaryHandler( - VersionServiceCreateVersionProcedure, - svc.CreateVersion, - connect.WithSchema(versionServiceCreateVersionMethodDescriptor), - connect.WithHandlerOptions(opts...), - ) - versionServiceGetVersionHandler := connect.NewUnaryHandler( - VersionServiceGetVersionProcedure, - svc.GetVersion, - connect.WithSchema(versionServiceGetVersionMethodDescriptor), - connect.WithHandlerOptions(opts...), - ) - return "/ctrl.v1.VersionService/", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - switch r.URL.Path { - case VersionServiceCreateVersionProcedure: - versionServiceCreateVersionHandler.ServeHTTP(w, r) - case VersionServiceGetVersionProcedure: - versionServiceGetVersionHandler.ServeHTTP(w, r) - default: - http.NotFound(w, r) - } - }) -} - -// UnimplementedVersionServiceHandler returns CodeUnimplemented from all methods. -type UnimplementedVersionServiceHandler struct{} - -func (UnimplementedVersionServiceHandler) CreateVersion(context.Context, *connect.Request[v1.CreateVersionRequest]) (*connect.Response[v1.CreateVersionResponse], error) { - return nil, connect.NewError(connect.CodeUnimplemented, errors.New("ctrl.v1.VersionService.CreateVersion is not implemented")) -} - -func (UnimplementedVersionServiceHandler) GetVersion(context.Context, *connect.Request[v1.GetVersionRequest]) (*connect.Response[v1.GetVersionResponse], error) { - return nil, connect.NewError(connect.CodeUnimplemented, errors.New("ctrl.v1.VersionService.GetVersion is not implemented")) -} diff --git a/go/gen/proto/ctrl/v1/version.pb.go b/go/gen/proto/ctrl/v1/deployment.pb.go similarity index 57% rename from go/gen/proto/ctrl/v1/version.pb.go rename to go/gen/proto/ctrl/v1/deployment.pb.go index d6ad6d0560..0411544d3d 100644 --- a/go/gen/proto/ctrl/v1/version.pb.go +++ b/go/gen/proto/ctrl/v1/deployment.pb.go @@ -2,7 +2,7 @@ // versions: // protoc-gen-go v1.36.8 // protoc (unknown) -// source: proto/ctrl/v1/version.proto +// source: proto/ctrl/v1/deployment.proto package ctrlv1 @@ -21,69 +21,69 @@ const ( _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) ) -// Version status enum -type VersionStatus int32 +// Deployment status enum +type DeploymentStatus int32 const ( - VersionStatus_VERSION_STATUS_UNSPECIFIED VersionStatus = 0 - VersionStatus_VERSION_STATUS_PENDING VersionStatus = 1 - VersionStatus_VERSION_STATUS_BUILDING VersionStatus = 2 - VersionStatus_VERSION_STATUS_DEPLOYING VersionStatus = 3 - VersionStatus_VERSION_STATUS_ACTIVE VersionStatus = 4 - VersionStatus_VERSION_STATUS_FAILED VersionStatus = 5 - VersionStatus_VERSION_STATUS_ARCHIVED VersionStatus = 6 + DeploymentStatus_DEPLOYMENT_STATUS_UNSPECIFIED DeploymentStatus = 0 + DeploymentStatus_DEPLOYMENT_STATUS_PENDING DeploymentStatus = 1 + DeploymentStatus_DEPLOYMENT_STATUS_BUILDING DeploymentStatus = 2 + DeploymentStatus_DEPLOYMENT_STATUS_DEPLOYING DeploymentStatus = 3 + DeploymentStatus_DEPLOYMENT_STATUS_NETWORK DeploymentStatus = 4 + DeploymentStatus_DEPLOYMENT_STATUS_READY DeploymentStatus = 5 + DeploymentStatus_DEPLOYMENT_STATUS_FAILED DeploymentStatus = 6 ) -// Enum value maps for VersionStatus. +// Enum value maps for DeploymentStatus. var ( - VersionStatus_name = map[int32]string{ - 0: "VERSION_STATUS_UNSPECIFIED", - 1: "VERSION_STATUS_PENDING", - 2: "VERSION_STATUS_BUILDING", - 3: "VERSION_STATUS_DEPLOYING", - 4: "VERSION_STATUS_ACTIVE", - 5: "VERSION_STATUS_FAILED", - 6: "VERSION_STATUS_ARCHIVED", - } - VersionStatus_value = map[string]int32{ - "VERSION_STATUS_UNSPECIFIED": 0, - "VERSION_STATUS_PENDING": 1, - "VERSION_STATUS_BUILDING": 2, - "VERSION_STATUS_DEPLOYING": 3, - "VERSION_STATUS_ACTIVE": 4, - "VERSION_STATUS_FAILED": 5, - "VERSION_STATUS_ARCHIVED": 6, + DeploymentStatus_name = map[int32]string{ + 0: "DEPLOYMENT_STATUS_UNSPECIFIED", + 1: "DEPLOYMENT_STATUS_PENDING", + 2: "DEPLOYMENT_STATUS_BUILDING", + 3: "DEPLOYMENT_STATUS_DEPLOYING", + 4: "DEPLOYMENT_STATUS_NETWORK", + 5: "DEPLOYMENT_STATUS_READY", + 6: "DEPLOYMENT_STATUS_FAILED", + } + DeploymentStatus_value = map[string]int32{ + "DEPLOYMENT_STATUS_UNSPECIFIED": 0, + "DEPLOYMENT_STATUS_PENDING": 1, + "DEPLOYMENT_STATUS_BUILDING": 2, + "DEPLOYMENT_STATUS_DEPLOYING": 3, + "DEPLOYMENT_STATUS_NETWORK": 4, + "DEPLOYMENT_STATUS_READY": 5, + "DEPLOYMENT_STATUS_FAILED": 6, } ) -func (x VersionStatus) Enum() *VersionStatus { - p := new(VersionStatus) +func (x DeploymentStatus) Enum() *DeploymentStatus { + p := new(DeploymentStatus) *p = x return p } -func (x VersionStatus) String() string { +func (x DeploymentStatus) String() string { return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) } -func (VersionStatus) Descriptor() protoreflect.EnumDescriptor { - return file_proto_ctrl_v1_version_proto_enumTypes[0].Descriptor() +func (DeploymentStatus) Descriptor() protoreflect.EnumDescriptor { + return file_proto_ctrl_v1_deployment_proto_enumTypes[0].Descriptor() } -func (VersionStatus) Type() protoreflect.EnumType { - return &file_proto_ctrl_v1_version_proto_enumTypes[0] +func (DeploymentStatus) Type() protoreflect.EnumType { + return &file_proto_ctrl_v1_deployment_proto_enumTypes[0] } -func (x VersionStatus) Number() protoreflect.EnumNumber { +func (x DeploymentStatus) Number() protoreflect.EnumNumber { return protoreflect.EnumNumber(x) } -// Deprecated: Use VersionStatus.Descriptor instead. -func (VersionStatus) EnumDescriptor() ([]byte, []int) { - return file_proto_ctrl_v1_version_proto_rawDescGZIP(), []int{0} +// Deprecated: Use DeploymentStatus.Descriptor instead. +func (DeploymentStatus) EnumDescriptor() ([]byte, []int) { + return file_proto_ctrl_v1_deployment_proto_rawDescGZIP(), []int{0} } -// Source type for version creation +// Source type for deployment creation type SourceType int32 const ( @@ -117,11 +117,11 @@ func (x SourceType) String() string { } func (SourceType) Descriptor() protoreflect.EnumDescriptor { - return file_proto_ctrl_v1_version_proto_enumTypes[1].Descriptor() + return file_proto_ctrl_v1_deployment_proto_enumTypes[1].Descriptor() } func (SourceType) Type() protoreflect.EnumType { - return &file_proto_ctrl_v1_version_proto_enumTypes[1] + return &file_proto_ctrl_v1_deployment_proto_enumTypes[1] } func (x SourceType) Number() protoreflect.EnumNumber { @@ -130,10 +130,10 @@ func (x SourceType) Number() protoreflect.EnumNumber { // Deprecated: Use SourceType.Descriptor instead. func (SourceType) EnumDescriptor() ([]byte, []int) { - return file_proto_ctrl_v1_version_proto_rawDescGZIP(), []int{1} + return file_proto_ctrl_v1_deployment_proto_rawDescGZIP(), []int{1} } -type CreateVersionRequest struct { +type CreateDeploymentRequest struct { state protoimpl.MessageState `protogen:"open.v1"` WorkspaceId string `protobuf:"bytes,1,opt,name=workspace_id,json=workspaceId,proto3" json:"workspace_id,omitempty"` ProjectId string `protobuf:"bytes,2,opt,name=project_id,json=projectId,proto3" json:"project_id,omitempty"` @@ -160,21 +160,21 @@ type CreateVersionRequest struct { sizeCache protoimpl.SizeCache } -func (x *CreateVersionRequest) Reset() { - *x = CreateVersionRequest{} - mi := &file_proto_ctrl_v1_version_proto_msgTypes[0] +func (x *CreateDeploymentRequest) Reset() { + *x = CreateDeploymentRequest{} + mi := &file_proto_ctrl_v1_deployment_proto_msgTypes[0] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *CreateVersionRequest) String() string { +func (x *CreateDeploymentRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*CreateVersionRequest) ProtoMessage() {} +func (*CreateDeploymentRequest) ProtoMessage() {} -func (x *CreateVersionRequest) ProtoReflect() protoreflect.Message { - mi := &file_proto_ctrl_v1_version_proto_msgTypes[0] +func (x *CreateDeploymentRequest) ProtoReflect() protoreflect.Message { + mi := &file_proto_ctrl_v1_deployment_proto_msgTypes[0] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -185,132 +185,132 @@ func (x *CreateVersionRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use CreateVersionRequest.ProtoReflect.Descriptor instead. -func (*CreateVersionRequest) Descriptor() ([]byte, []int) { - return file_proto_ctrl_v1_version_proto_rawDescGZIP(), []int{0} +// Deprecated: Use CreateDeploymentRequest.ProtoReflect.Descriptor instead. +func (*CreateDeploymentRequest) Descriptor() ([]byte, []int) { + return file_proto_ctrl_v1_deployment_proto_rawDescGZIP(), []int{0} } -func (x *CreateVersionRequest) GetWorkspaceId() string { +func (x *CreateDeploymentRequest) GetWorkspaceId() string { if x != nil { return x.WorkspaceId } return "" } -func (x *CreateVersionRequest) GetProjectId() string { +func (x *CreateDeploymentRequest) GetProjectId() string { if x != nil { return x.ProjectId } return "" } -func (x *CreateVersionRequest) GetBranch() string { +func (x *CreateDeploymentRequest) GetBranch() string { if x != nil { return x.Branch } return "" } -func (x *CreateVersionRequest) GetSourceType() SourceType { +func (x *CreateDeploymentRequest) GetSourceType() SourceType { if x != nil { return x.SourceType } return SourceType_SOURCE_TYPE_UNSPECIFIED } -func (x *CreateVersionRequest) GetGitCommitSha() string { +func (x *CreateDeploymentRequest) GetGitCommitSha() string { if x != nil { return x.GitCommitSha } return "" } -func (x *CreateVersionRequest) GetEnvironmentId() string { +func (x *CreateDeploymentRequest) GetEnvironmentId() string { if x != nil { return x.EnvironmentId } return "" } -func (x *CreateVersionRequest) GetDockerImageTag() string { +func (x *CreateDeploymentRequest) GetDockerImageTag() string { if x != nil { return x.DockerImageTag } return "" } -func (x *CreateVersionRequest) GetHostname() string { +func (x *CreateDeploymentRequest) GetHostname() string { if x != nil { return x.Hostname } return "" } -func (x *CreateVersionRequest) GetKeyspaceId() string { +func (x *CreateDeploymentRequest) GetKeyspaceId() string { if x != nil { return x.KeyspaceId } return "" } -func (x *CreateVersionRequest) GetGitCommitMessage() string { +func (x *CreateDeploymentRequest) GetGitCommitMessage() string { if x != nil { return x.GitCommitMessage } return "" } -func (x *CreateVersionRequest) GetGitCommitAuthorName() string { +func (x *CreateDeploymentRequest) GetGitCommitAuthorName() string { if x != nil { return x.GitCommitAuthorName } return "" } -func (x *CreateVersionRequest) GetGitCommitAuthorUsername() string { +func (x *CreateDeploymentRequest) GetGitCommitAuthorUsername() string { if x != nil { return x.GitCommitAuthorUsername } return "" } -func (x *CreateVersionRequest) GetGitCommitAuthorAvatarUrl() string { +func (x *CreateDeploymentRequest) GetGitCommitAuthorAvatarUrl() string { if x != nil { return x.GitCommitAuthorAvatarUrl } return "" } -func (x *CreateVersionRequest) GetGitCommitTimestamp() int64 { +func (x *CreateDeploymentRequest) GetGitCommitTimestamp() int64 { if x != nil { return x.GitCommitTimestamp } return 0 } -type CreateVersionResponse struct { +type CreateDeploymentResponse struct { state protoimpl.MessageState `protogen:"open.v1"` - VersionId string `protobuf:"bytes,1,opt,name=version_id,json=versionId,proto3" json:"version_id,omitempty"` - Status VersionStatus `protobuf:"varint,2,opt,name=status,proto3,enum=ctrl.v1.VersionStatus" json:"status,omitempty"` // Will be PENDING or BUILDING + DeploymentId string `protobuf:"bytes,1,opt,name=deployment_id,json=deploymentId,proto3" json:"deployment_id,omitempty"` + Status DeploymentStatus `protobuf:"varint,2,opt,name=status,proto3,enum=ctrl.v1.DeploymentStatus" json:"status,omitempty"` // Will be PENDING or BUILDING unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *CreateVersionResponse) Reset() { - *x = CreateVersionResponse{} - mi := &file_proto_ctrl_v1_version_proto_msgTypes[1] +func (x *CreateDeploymentResponse) Reset() { + *x = CreateDeploymentResponse{} + mi := &file_proto_ctrl_v1_deployment_proto_msgTypes[1] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *CreateVersionResponse) String() string { +func (x *CreateDeploymentResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*CreateVersionResponse) ProtoMessage() {} +func (*CreateDeploymentResponse) ProtoMessage() {} -func (x *CreateVersionResponse) ProtoReflect() protoreflect.Message { - mi := &file_proto_ctrl_v1_version_proto_msgTypes[1] +func (x *CreateDeploymentResponse) ProtoReflect() protoreflect.Message { + mi := &file_proto_ctrl_v1_deployment_proto_msgTypes[1] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -321,47 +321,47 @@ func (x *CreateVersionResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use CreateVersionResponse.ProtoReflect.Descriptor instead. -func (*CreateVersionResponse) Descriptor() ([]byte, []int) { - return file_proto_ctrl_v1_version_proto_rawDescGZIP(), []int{1} +// Deprecated: Use CreateDeploymentResponse.ProtoReflect.Descriptor instead. +func (*CreateDeploymentResponse) Descriptor() ([]byte, []int) { + return file_proto_ctrl_v1_deployment_proto_rawDescGZIP(), []int{1} } -func (x *CreateVersionResponse) GetVersionId() string { +func (x *CreateDeploymentResponse) GetDeploymentId() string { if x != nil { - return x.VersionId + return x.DeploymentId } return "" } -func (x *CreateVersionResponse) GetStatus() VersionStatus { +func (x *CreateDeploymentResponse) GetStatus() DeploymentStatus { if x != nil { return x.Status } - return VersionStatus_VERSION_STATUS_UNSPECIFIED + return DeploymentStatus_DEPLOYMENT_STATUS_UNSPECIFIED } -type GetVersionRequest struct { +type GetDeploymentRequest struct { state protoimpl.MessageState `protogen:"open.v1"` - VersionId string `protobuf:"bytes,1,opt,name=version_id,json=versionId,proto3" json:"version_id,omitempty"` + DeploymentId string `protobuf:"bytes,1,opt,name=deployment_id,json=deploymentId,proto3" json:"deployment_id,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *GetVersionRequest) Reset() { - *x = GetVersionRequest{} - mi := &file_proto_ctrl_v1_version_proto_msgTypes[2] +func (x *GetDeploymentRequest) Reset() { + *x = GetDeploymentRequest{} + mi := &file_proto_ctrl_v1_deployment_proto_msgTypes[2] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *GetVersionRequest) String() string { +func (x *GetDeploymentRequest) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GetVersionRequest) ProtoMessage() {} +func (*GetDeploymentRequest) ProtoMessage() {} -func (x *GetVersionRequest) ProtoReflect() protoreflect.Message { - mi := &file_proto_ctrl_v1_version_proto_msgTypes[2] +func (x *GetDeploymentRequest) ProtoReflect() protoreflect.Message { + mi := &file_proto_ctrl_v1_deployment_proto_msgTypes[2] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -372,40 +372,40 @@ func (x *GetVersionRequest) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use GetVersionRequest.ProtoReflect.Descriptor instead. -func (*GetVersionRequest) Descriptor() ([]byte, []int) { - return file_proto_ctrl_v1_version_proto_rawDescGZIP(), []int{2} +// Deprecated: Use GetDeploymentRequest.ProtoReflect.Descriptor instead. +func (*GetDeploymentRequest) Descriptor() ([]byte, []int) { + return file_proto_ctrl_v1_deployment_proto_rawDescGZIP(), []int{2} } -func (x *GetVersionRequest) GetVersionId() string { +func (x *GetDeploymentRequest) GetDeploymentId() string { if x != nil { - return x.VersionId + return x.DeploymentId } return "" } -type GetVersionResponse struct { +type GetDeploymentResponse struct { state protoimpl.MessageState `protogen:"open.v1"` - Version *Version `protobuf:"bytes,1,opt,name=version,proto3" json:"version,omitempty"` + Deployment *Deployment `protobuf:"bytes,1,opt,name=deployment,proto3" json:"deployment,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } -func (x *GetVersionResponse) Reset() { - *x = GetVersionResponse{} - mi := &file_proto_ctrl_v1_version_proto_msgTypes[3] +func (x *GetDeploymentResponse) Reset() { + *x = GetDeploymentResponse{} + mi := &file_proto_ctrl_v1_deployment_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *GetVersionResponse) String() string { +func (x *GetDeploymentResponse) String() string { return protoimpl.X.MessageStringOf(x) } -func (*GetVersionResponse) ProtoMessage() {} +func (*GetDeploymentResponse) ProtoMessage() {} -func (x *GetVersionResponse) ProtoReflect() protoreflect.Message { - mi := &file_proto_ctrl_v1_version_proto_msgTypes[3] +func (x *GetDeploymentResponse) ProtoReflect() protoreflect.Message { + mi := &file_proto_ctrl_v1_deployment_proto_msgTypes[3] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -416,19 +416,19 @@ func (x *GetVersionResponse) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use GetVersionResponse.ProtoReflect.Descriptor instead. -func (*GetVersionResponse) Descriptor() ([]byte, []int) { - return file_proto_ctrl_v1_version_proto_rawDescGZIP(), []int{3} +// Deprecated: Use GetDeploymentResponse.ProtoReflect.Descriptor instead. +func (*GetDeploymentResponse) Descriptor() ([]byte, []int) { + return file_proto_ctrl_v1_deployment_proto_rawDescGZIP(), []int{3} } -func (x *GetVersionResponse) GetVersion() *Version { +func (x *GetDeploymentResponse) GetDeployment() *Deployment { if x != nil { - return x.Version + return x.Deployment } return nil } -type Version struct { +type Deployment struct { state protoimpl.MessageState `protogen:"open.v1"` Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` WorkspaceId string `protobuf:"bytes,2,opt,name=workspace_id,json=workspaceId,proto3" json:"workspace_id,omitempty"` @@ -438,8 +438,8 @@ type Version struct { GitCommitSha string `protobuf:"bytes,5,opt,name=git_commit_sha,json=gitCommitSha,proto3" json:"git_commit_sha,omitempty"` GitBranch string `protobuf:"bytes,6,opt,name=git_branch,json=gitBranch,proto3" json:"git_branch,omitempty"` // Status and lifecycle - Status VersionStatus `protobuf:"varint,7,opt,name=status,proto3,enum=ctrl.v1.VersionStatus" json:"status,omitempty"` - ErrorMessage string `protobuf:"bytes,8,opt,name=error_message,json=errorMessage,proto3" json:"error_message,omitempty"` // For failed versions + Status DeploymentStatus `protobuf:"varint,7,opt,name=status,proto3,enum=ctrl.v1.DeploymentStatus" json:"status,omitempty"` + ErrorMessage string `protobuf:"bytes,8,opt,name=error_message,json=errorMessage,proto3" json:"error_message,omitempty"` // For failed deployments // Configuration snapshot (resolved at creation time) EnvironmentVariables map[string]string `protobuf:"bytes,9,rep,name=environment_variables,json=environmentVariables,proto3" json:"environment_variables,omitempty" protobuf_key:"bytes,1,opt,name=key" protobuf_val:"bytes,2,opt,name=value"` // Topology configuration @@ -447,13 +447,13 @@ type Version struct { // Timestamps CreatedAt int64 `protobuf:"varint,11,opt,name=created_at,json=createdAt,proto3" json:"created_at,omitempty"` UpdatedAt int64 `protobuf:"varint,12,opt,name=updated_at,json=updatedAt,proto3" json:"updated_at,omitempty"` - // Associated hostnames for this version + // Associated hostnames for this deployment Hostnames []string `protobuf:"bytes,13,rep,name=hostnames,proto3" json:"hostnames,omitempty"` // Build information RootfsImageId string `protobuf:"bytes,14,opt,name=rootfs_image_id,json=rootfsImageId,proto3" json:"rootfs_image_id,omitempty"` BuildId string `protobuf:"bytes,15,opt,name=build_id,json=buildId,proto3" json:"build_id,omitempty"` // Deployment steps - Steps []*VersionStep `protobuf:"bytes,16,rep,name=steps,proto3" json:"steps,omitempty"` + Steps []*DeploymentStep `protobuf:"bytes,16,rep,name=steps,proto3" json:"steps,omitempty"` // Extended git information GitCommitMessage string `protobuf:"bytes,17,opt,name=git_commit_message,json=gitCommitMessage,proto3" json:"git_commit_message,omitempty"` GitCommitAuthorName string `protobuf:"bytes,18,opt,name=git_commit_author_name,json=gitCommitAuthorName,proto3" json:"git_commit_author_name,omitempty"` @@ -465,21 +465,21 @@ type Version struct { sizeCache protoimpl.SizeCache } -func (x *Version) Reset() { - *x = Version{} - mi := &file_proto_ctrl_v1_version_proto_msgTypes[4] +func (x *Deployment) Reset() { + *x = Deployment{} + mi := &file_proto_ctrl_v1_deployment_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *Version) String() string { +func (x *Deployment) String() string { return protoimpl.X.MessageStringOf(x) } -func (*Version) ProtoMessage() {} +func (*Deployment) ProtoMessage() {} -func (x *Version) ProtoReflect() protoreflect.Message { - mi := &file_proto_ctrl_v1_version_proto_msgTypes[4] +func (x *Deployment) ProtoReflect() protoreflect.Message { + mi := &file_proto_ctrl_v1_deployment_proto_msgTypes[4] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -490,159 +490,159 @@ func (x *Version) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use Version.ProtoReflect.Descriptor instead. -func (*Version) Descriptor() ([]byte, []int) { - return file_proto_ctrl_v1_version_proto_rawDescGZIP(), []int{4} +// Deprecated: Use Deployment.ProtoReflect.Descriptor instead. +func (*Deployment) Descriptor() ([]byte, []int) { + return file_proto_ctrl_v1_deployment_proto_rawDescGZIP(), []int{4} } -func (x *Version) GetId() string { +func (x *Deployment) GetId() string { if x != nil { return x.Id } return "" } -func (x *Version) GetWorkspaceId() string { +func (x *Deployment) GetWorkspaceId() string { if x != nil { return x.WorkspaceId } return "" } -func (x *Version) GetProjectId() string { +func (x *Deployment) GetProjectId() string { if x != nil { return x.ProjectId } return "" } -func (x *Version) GetEnvironmentId() string { +func (x *Deployment) GetEnvironmentId() string { if x != nil { return x.EnvironmentId } return "" } -func (x *Version) GetGitCommitSha() string { +func (x *Deployment) GetGitCommitSha() string { if x != nil { return x.GitCommitSha } return "" } -func (x *Version) GetGitBranch() string { +func (x *Deployment) GetGitBranch() string { if x != nil { return x.GitBranch } return "" } -func (x *Version) GetStatus() VersionStatus { +func (x *Deployment) GetStatus() DeploymentStatus { if x != nil { return x.Status } - return VersionStatus_VERSION_STATUS_UNSPECIFIED + return DeploymentStatus_DEPLOYMENT_STATUS_UNSPECIFIED } -func (x *Version) GetErrorMessage() string { +func (x *Deployment) GetErrorMessage() string { if x != nil { return x.ErrorMessage } return "" } -func (x *Version) GetEnvironmentVariables() map[string]string { +func (x *Deployment) GetEnvironmentVariables() map[string]string { if x != nil { return x.EnvironmentVariables } return nil } -func (x *Version) GetTopology() *Topology { +func (x *Deployment) GetTopology() *Topology { if x != nil { return x.Topology } return nil } -func (x *Version) GetCreatedAt() int64 { +func (x *Deployment) GetCreatedAt() int64 { if x != nil { return x.CreatedAt } return 0 } -func (x *Version) GetUpdatedAt() int64 { +func (x *Deployment) GetUpdatedAt() int64 { if x != nil { return x.UpdatedAt } return 0 } -func (x *Version) GetHostnames() []string { +func (x *Deployment) GetHostnames() []string { if x != nil { return x.Hostnames } return nil } -func (x *Version) GetRootfsImageId() string { +func (x *Deployment) GetRootfsImageId() string { if x != nil { return x.RootfsImageId } return "" } -func (x *Version) GetBuildId() string { +func (x *Deployment) GetBuildId() string { if x != nil { return x.BuildId } return "" } -func (x *Version) GetSteps() []*VersionStep { +func (x *Deployment) GetSteps() []*DeploymentStep { if x != nil { return x.Steps } return nil } -func (x *Version) GetGitCommitMessage() string { +func (x *Deployment) GetGitCommitMessage() string { if x != nil { return x.GitCommitMessage } return "" } -func (x *Version) GetGitCommitAuthorName() string { +func (x *Deployment) GetGitCommitAuthorName() string { if x != nil { return x.GitCommitAuthorName } return "" } -func (x *Version) GetGitCommitAuthorUsername() string { +func (x *Deployment) GetGitCommitAuthorUsername() string { if x != nil { return x.GitCommitAuthorUsername } return "" } -func (x *Version) GetGitCommitAuthorAvatarUrl() string { +func (x *Deployment) GetGitCommitAuthorAvatarUrl() string { if x != nil { return x.GitCommitAuthorAvatarUrl } return "" } -func (x *Version) GetGitCommitTimestamp() int64 { +func (x *Deployment) GetGitCommitTimestamp() int64 { if x != nil { return x.GitCommitTimestamp } return 0 } -type VersionStep struct { +type DeploymentStep struct { state protoimpl.MessageState `protogen:"open.v1"` Status string `protobuf:"bytes,1,opt,name=status,proto3" json:"status,omitempty"` Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` @@ -652,21 +652,21 @@ type VersionStep struct { sizeCache protoimpl.SizeCache } -func (x *VersionStep) Reset() { - *x = VersionStep{} - mi := &file_proto_ctrl_v1_version_proto_msgTypes[5] +func (x *DeploymentStep) Reset() { + *x = DeploymentStep{} + mi := &file_proto_ctrl_v1_deployment_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } -func (x *VersionStep) String() string { +func (x *DeploymentStep) String() string { return protoimpl.X.MessageStringOf(x) } -func (*VersionStep) ProtoMessage() {} +func (*DeploymentStep) ProtoMessage() {} -func (x *VersionStep) ProtoReflect() protoreflect.Message { - mi := &file_proto_ctrl_v1_version_proto_msgTypes[5] +func (x *DeploymentStep) ProtoReflect() protoreflect.Message { + mi := &file_proto_ctrl_v1_deployment_proto_msgTypes[5] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -677,33 +677,33 @@ func (x *VersionStep) ProtoReflect() protoreflect.Message { return mi.MessageOf(x) } -// Deprecated: Use VersionStep.ProtoReflect.Descriptor instead. -func (*VersionStep) Descriptor() ([]byte, []int) { - return file_proto_ctrl_v1_version_proto_rawDescGZIP(), []int{5} +// Deprecated: Use DeploymentStep.ProtoReflect.Descriptor instead. +func (*DeploymentStep) Descriptor() ([]byte, []int) { + return file_proto_ctrl_v1_deployment_proto_rawDescGZIP(), []int{5} } -func (x *VersionStep) GetStatus() string { +func (x *DeploymentStep) GetStatus() string { if x != nil { return x.Status } return "" } -func (x *VersionStep) GetMessage() string { +func (x *DeploymentStep) GetMessage() string { if x != nil { return x.Message } return "" } -func (x *VersionStep) GetErrorMessage() string { +func (x *DeploymentStep) GetErrorMessage() string { if x != nil { return x.ErrorMessage } return "" } -func (x *VersionStep) GetCreatedAt() int64 { +func (x *DeploymentStep) GetCreatedAt() int64 { if x != nil { return x.CreatedAt } @@ -726,7 +726,7 @@ type Topology struct { func (x *Topology) Reset() { *x = Topology{} - mi := &file_proto_ctrl_v1_version_proto_msgTypes[6] + mi := &file_proto_ctrl_v1_deployment_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -738,7 +738,7 @@ func (x *Topology) String() string { func (*Topology) ProtoMessage() {} func (x *Topology) ProtoReflect() protoreflect.Message { - mi := &file_proto_ctrl_v1_version_proto_msgTypes[6] + mi := &file_proto_ctrl_v1_deployment_proto_msgTypes[6] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -751,7 +751,7 @@ func (x *Topology) ProtoReflect() protoreflect.Message { // Deprecated: Use Topology.ProtoReflect.Descriptor instead. func (*Topology) Descriptor() ([]byte, []int) { - return file_proto_ctrl_v1_version_proto_rawDescGZIP(), []int{6} + return file_proto_ctrl_v1_deployment_proto_rawDescGZIP(), []int{6} } func (x *Topology) GetCpuMillicores() int32 { @@ -807,7 +807,7 @@ type RegionalConfig struct { func (x *RegionalConfig) Reset() { *x = RegionalConfig{} - mi := &file_proto_ctrl_v1_version_proto_msgTypes[7] + mi := &file_proto_ctrl_v1_deployment_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -819,7 +819,7 @@ func (x *RegionalConfig) String() string { func (*RegionalConfig) ProtoMessage() {} func (x *RegionalConfig) ProtoReflect() protoreflect.Message { - mi := &file_proto_ctrl_v1_version_proto_msgTypes[7] + mi := &file_proto_ctrl_v1_deployment_proto_msgTypes[7] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -832,7 +832,7 @@ func (x *RegionalConfig) ProtoReflect() protoreflect.Message { // Deprecated: Use RegionalConfig.ProtoReflect.Descriptor instead. func (*RegionalConfig) Descriptor() ([]byte, []int) { - return file_proto_ctrl_v1_version_proto_rawDescGZIP(), []int{7} + return file_proto_ctrl_v1_deployment_proto_rawDescGZIP(), []int{7} } func (x *RegionalConfig) GetRegion() string { @@ -856,12 +856,12 @@ func (x *RegionalConfig) GetMaxInstances() int32 { return 0 } -var File_proto_ctrl_v1_version_proto protoreflect.FileDescriptor +var File_proto_ctrl_v1_deployment_proto protoreflect.FileDescriptor -const file_proto_ctrl_v1_version_proto_rawDesc = "" + +const file_proto_ctrl_v1_deployment_proto_rawDesc = "" + "\n" + - "\x1bproto/ctrl/v1/version.proto\x12\actrl.v1\"\xec\x04\n" + - "\x14CreateVersionRequest\x12!\n" + + "\x1eproto/ctrl/v1/deployment.proto\x12\actrl.v1\"\xef\x04\n" + + "\x17CreateDeploymentRequest\x12!\n" + "\fworkspace_id\x18\x01 \x01(\tR\vworkspaceId\x12\x1d\n" + "\n" + "project_id\x18\x02 \x01(\tR\tprojectId\x12\x16\n" + @@ -879,17 +879,18 @@ const file_proto_ctrl_v1_version_proto_rawDesc = "" + "\x16git_commit_author_name\x18\v \x01(\tR\x13gitCommitAuthorName\x12;\n" + "\x1agit_commit_author_username\x18\f \x01(\tR\x17gitCommitAuthorUsername\x12>\n" + "\x1cgit_commit_author_avatar_url\x18\r \x01(\tR\x18gitCommitAuthorAvatarUrl\x120\n" + - "\x14git_commit_timestamp\x18\x0e \x01(\x03R\x12gitCommitTimestamp\"f\n" + - "\x15CreateVersionResponse\x12\x1d\n" + + "\x14git_commit_timestamp\x18\x0e \x01(\x03R\x12gitCommitTimestamp\"r\n" + + "\x18CreateDeploymentResponse\x12#\n" + + "\rdeployment_id\x18\x01 \x01(\tR\fdeploymentId\x121\n" + + "\x06status\x18\x02 \x01(\x0e2\x19.ctrl.v1.DeploymentStatusR\x06status\";\n" + + "\x14GetDeploymentRequest\x12#\n" + + "\rdeployment_id\x18\x01 \x01(\tR\fdeploymentId\"L\n" + + "\x15GetDeploymentResponse\x123\n" + "\n" + - "version_id\x18\x01 \x01(\tR\tversionId\x12.\n" + - "\x06status\x18\x02 \x01(\x0e2\x16.ctrl.v1.VersionStatusR\x06status\"2\n" + - "\x11GetVersionRequest\x12\x1d\n" + + "deployment\x18\x01 \x01(\v2\x13.ctrl.v1.DeploymentR\n" + + "deployment\"\xde\a\n" + "\n" + - "version_id\x18\x01 \x01(\tR\tversionId\"@\n" + - "\x12GetVersionResponse\x12*\n" + - "\aversion\x18\x01 \x01(\v2\x10.ctrl.v1.VersionR\aversion\"\xd2\a\n" + - "\aVersion\x12\x0e\n" + + "Deployment\x12\x0e\n" + "\x02id\x18\x01 \x01(\tR\x02id\x12!\n" + "\fworkspace_id\x18\x02 \x01(\tR\vworkspaceId\x12\x1d\n" + "\n" + @@ -897,10 +898,10 @@ const file_proto_ctrl_v1_version_proto_rawDesc = "" + "\x0eenvironment_id\x18\x04 \x01(\tR\renvironmentId\x12$\n" + "\x0egit_commit_sha\x18\x05 \x01(\tR\fgitCommitSha\x12\x1d\n" + "\n" + - "git_branch\x18\x06 \x01(\tR\tgitBranch\x12.\n" + - "\x06status\x18\a \x01(\x0e2\x16.ctrl.v1.VersionStatusR\x06status\x12#\n" + - "\rerror_message\x18\b \x01(\tR\ferrorMessage\x12_\n" + - "\x15environment_variables\x18\t \x03(\v2*.ctrl.v1.Version.EnvironmentVariablesEntryR\x14environmentVariables\x12-\n" + + "git_branch\x18\x06 \x01(\tR\tgitBranch\x121\n" + + "\x06status\x18\a \x01(\x0e2\x19.ctrl.v1.DeploymentStatusR\x06status\x12#\n" + + "\rerror_message\x18\b \x01(\tR\ferrorMessage\x12b\n" + + "\x15environment_variables\x18\t \x03(\v2-.ctrl.v1.Deployment.EnvironmentVariablesEntryR\x14environmentVariables\x12-\n" + "\btopology\x18\n" + " \x01(\v2\x11.ctrl.v1.TopologyR\btopology\x12\x1d\n" + "\n" + @@ -909,8 +910,8 @@ const file_proto_ctrl_v1_version_proto_rawDesc = "" + "updated_at\x18\f \x01(\x03R\tupdatedAt\x12\x1c\n" + "\thostnames\x18\r \x03(\tR\thostnames\x12&\n" + "\x0frootfs_image_id\x18\x0e \x01(\tR\rrootfsImageId\x12\x19\n" + - "\bbuild_id\x18\x0f \x01(\tR\abuildId\x12*\n" + - "\x05steps\x18\x10 \x03(\v2\x14.ctrl.v1.VersionStepR\x05steps\x12,\n" + + "\bbuild_id\x18\x0f \x01(\tR\abuildId\x12-\n" + + "\x05steps\x18\x10 \x03(\v2\x17.ctrl.v1.DeploymentStepR\x05steps\x12,\n" + "\x12git_commit_message\x18\x11 \x01(\tR\x10gitCommitMessage\x123\n" + "\x16git_commit_author_name\x18\x12 \x01(\tR\x13gitCommitAuthorName\x12;\n" + "\x1agit_commit_author_username\x18\x14 \x01(\tR\x17gitCommitAuthorUsername\x12>\n" + @@ -918,8 +919,8 @@ const file_proto_ctrl_v1_version_proto_rawDesc = "" + "\x14git_commit_timestamp\x18\x16 \x01(\x03R\x12gitCommitTimestamp\x1aG\n" + "\x19EnvironmentVariablesEntry\x12\x10\n" + "\x03key\x18\x01 \x01(\tR\x03key\x12\x14\n" + - "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\x83\x01\n" + - "\vVersionStep\x12\x16\n" + + "\x05value\x18\x02 \x01(\tR\x05value:\x028\x01\"\x86\x01\n" + + "\x0eDeploymentStep\x12\x16\n" + "\x06status\x18\x01 \x01(\tR\x06status\x12\x18\n" + "\amessage\x18\x02 \x01(\tR\amessage\x12#\n" + "\rerror_message\x18\x03 \x01(\tR\ferrorMessage\x12\x1d\n" + @@ -935,65 +936,64 @@ const file_proto_ctrl_v1_version_proto_rawDesc = "" + "\x0eRegionalConfig\x12\x16\n" + "\x06region\x18\x01 \x01(\tR\x06region\x12#\n" + "\rmin_instances\x18\x02 \x01(\x05R\fminInstances\x12#\n" + - "\rmax_instances\x18\x03 \x01(\x05R\fmaxInstances*\xd9\x01\n" + - "\rVersionStatus\x12\x1e\n" + - "\x1aVERSION_STATUS_UNSPECIFIED\x10\x00\x12\x1a\n" + - "\x16VERSION_STATUS_PENDING\x10\x01\x12\x1b\n" + - "\x17VERSION_STATUS_BUILDING\x10\x02\x12\x1c\n" + - "\x18VERSION_STATUS_DEPLOYING\x10\x03\x12\x19\n" + - "\x15VERSION_STATUS_ACTIVE\x10\x04\x12\x19\n" + - "\x15VERSION_STATUS_FAILED\x10\x05\x12\x1b\n" + - "\x17VERSION_STATUS_ARCHIVED\x10\x06*Z\n" + + "\rmax_instances\x18\x03 \x01(\x05R\fmaxInstances*\xef\x01\n" + + "\x10DeploymentStatus\x12!\n" + + "\x1dDEPLOYMENT_STATUS_UNSPECIFIED\x10\x00\x12\x1d\n" + + "\x19DEPLOYMENT_STATUS_PENDING\x10\x01\x12\x1e\n" + + "\x1aDEPLOYMENT_STATUS_BUILDING\x10\x02\x12\x1f\n" + + "\x1bDEPLOYMENT_STATUS_DEPLOYING\x10\x03\x12\x1d\n" + + "\x19DEPLOYMENT_STATUS_NETWORK\x10\x04\x12\x1b\n" + + "\x17DEPLOYMENT_STATUS_READY\x10\x05\x12\x1c\n" + + "\x18DEPLOYMENT_STATUS_FAILED\x10\x06*Z\n" + "\n" + "SourceType\x12\x1b\n" + "\x17SOURCE_TYPE_UNSPECIFIED\x10\x00\x12\x13\n" + "\x0fSOURCE_TYPE_GIT\x10\x01\x12\x1a\n" + - "\x16SOURCE_TYPE_CLI_UPLOAD\x10\x022\xab\x01\n" + - "\x0eVersionService\x12P\n" + - "\rCreateVersion\x12\x1d.ctrl.v1.CreateVersionRequest\x1a\x1e.ctrl.v1.CreateVersionResponse\"\x00\x12G\n" + - "\n" + - "GetVersion\x12\x1a.ctrl.v1.GetVersionRequest\x1a\x1b.ctrl.v1.GetVersionResponse\"\x00B6Z4github.com/unkeyed/unkey/go/gen/proto/ctrl/v1;ctrlv1b\x06proto3" + "\x16SOURCE_TYPE_CLI_UPLOAD\x10\x022\xc0\x01\n" + + "\x11DeploymentService\x12Y\n" + + "\x10CreateDeployment\x12 .ctrl.v1.CreateDeploymentRequest\x1a!.ctrl.v1.CreateDeploymentResponse\"\x00\x12P\n" + + "\rGetDeployment\x12\x1d.ctrl.v1.GetDeploymentRequest\x1a\x1e.ctrl.v1.GetDeploymentResponse\"\x00B6Z4github.com/unkeyed/unkey/go/gen/proto/ctrl/v1;ctrlv1b\x06proto3" var ( - file_proto_ctrl_v1_version_proto_rawDescOnce sync.Once - file_proto_ctrl_v1_version_proto_rawDescData []byte + file_proto_ctrl_v1_deployment_proto_rawDescOnce sync.Once + file_proto_ctrl_v1_deployment_proto_rawDescData []byte ) -func file_proto_ctrl_v1_version_proto_rawDescGZIP() []byte { - file_proto_ctrl_v1_version_proto_rawDescOnce.Do(func() { - file_proto_ctrl_v1_version_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_proto_ctrl_v1_version_proto_rawDesc), len(file_proto_ctrl_v1_version_proto_rawDesc))) +func file_proto_ctrl_v1_deployment_proto_rawDescGZIP() []byte { + file_proto_ctrl_v1_deployment_proto_rawDescOnce.Do(func() { + file_proto_ctrl_v1_deployment_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_proto_ctrl_v1_deployment_proto_rawDesc), len(file_proto_ctrl_v1_deployment_proto_rawDesc))) }) - return file_proto_ctrl_v1_version_proto_rawDescData -} - -var file_proto_ctrl_v1_version_proto_enumTypes = make([]protoimpl.EnumInfo, 2) -var file_proto_ctrl_v1_version_proto_msgTypes = make([]protoimpl.MessageInfo, 9) -var file_proto_ctrl_v1_version_proto_goTypes = []any{ - (VersionStatus)(0), // 0: ctrl.v1.VersionStatus - (SourceType)(0), // 1: ctrl.v1.SourceType - (*CreateVersionRequest)(nil), // 2: ctrl.v1.CreateVersionRequest - (*CreateVersionResponse)(nil), // 3: ctrl.v1.CreateVersionResponse - (*GetVersionRequest)(nil), // 4: ctrl.v1.GetVersionRequest - (*GetVersionResponse)(nil), // 5: ctrl.v1.GetVersionResponse - (*Version)(nil), // 6: ctrl.v1.Version - (*VersionStep)(nil), // 7: ctrl.v1.VersionStep - (*Topology)(nil), // 8: ctrl.v1.Topology - (*RegionalConfig)(nil), // 9: ctrl.v1.RegionalConfig - nil, // 10: ctrl.v1.Version.EnvironmentVariablesEntry -} -var file_proto_ctrl_v1_version_proto_depIdxs = []int32{ - 1, // 0: ctrl.v1.CreateVersionRequest.source_type:type_name -> ctrl.v1.SourceType - 0, // 1: ctrl.v1.CreateVersionResponse.status:type_name -> ctrl.v1.VersionStatus - 6, // 2: ctrl.v1.GetVersionResponse.version:type_name -> ctrl.v1.Version - 0, // 3: ctrl.v1.Version.status:type_name -> ctrl.v1.VersionStatus - 10, // 4: ctrl.v1.Version.environment_variables:type_name -> ctrl.v1.Version.EnvironmentVariablesEntry - 8, // 5: ctrl.v1.Version.topology:type_name -> ctrl.v1.Topology - 7, // 6: ctrl.v1.Version.steps:type_name -> ctrl.v1.VersionStep + return file_proto_ctrl_v1_deployment_proto_rawDescData +} + +var file_proto_ctrl_v1_deployment_proto_enumTypes = make([]protoimpl.EnumInfo, 2) +var file_proto_ctrl_v1_deployment_proto_msgTypes = make([]protoimpl.MessageInfo, 9) +var file_proto_ctrl_v1_deployment_proto_goTypes = []any{ + (DeploymentStatus)(0), // 0: ctrl.v1.DeploymentStatus + (SourceType)(0), // 1: ctrl.v1.SourceType + (*CreateDeploymentRequest)(nil), // 2: ctrl.v1.CreateDeploymentRequest + (*CreateDeploymentResponse)(nil), // 3: ctrl.v1.CreateDeploymentResponse + (*GetDeploymentRequest)(nil), // 4: ctrl.v1.GetDeploymentRequest + (*GetDeploymentResponse)(nil), // 5: ctrl.v1.GetDeploymentResponse + (*Deployment)(nil), // 6: ctrl.v1.Deployment + (*DeploymentStep)(nil), // 7: ctrl.v1.DeploymentStep + (*Topology)(nil), // 8: ctrl.v1.Topology + (*RegionalConfig)(nil), // 9: ctrl.v1.RegionalConfig + nil, // 10: ctrl.v1.Deployment.EnvironmentVariablesEntry +} +var file_proto_ctrl_v1_deployment_proto_depIdxs = []int32{ + 1, // 0: ctrl.v1.CreateDeploymentRequest.source_type:type_name -> ctrl.v1.SourceType + 0, // 1: ctrl.v1.CreateDeploymentResponse.status:type_name -> ctrl.v1.DeploymentStatus + 6, // 2: ctrl.v1.GetDeploymentResponse.deployment:type_name -> ctrl.v1.Deployment + 0, // 3: ctrl.v1.Deployment.status:type_name -> ctrl.v1.DeploymentStatus + 10, // 4: ctrl.v1.Deployment.environment_variables:type_name -> ctrl.v1.Deployment.EnvironmentVariablesEntry + 8, // 5: ctrl.v1.Deployment.topology:type_name -> ctrl.v1.Topology + 7, // 6: ctrl.v1.Deployment.steps:type_name -> ctrl.v1.DeploymentStep 9, // 7: ctrl.v1.Topology.regions:type_name -> ctrl.v1.RegionalConfig - 2, // 8: ctrl.v1.VersionService.CreateVersion:input_type -> ctrl.v1.CreateVersionRequest - 4, // 9: ctrl.v1.VersionService.GetVersion:input_type -> ctrl.v1.GetVersionRequest - 3, // 10: ctrl.v1.VersionService.CreateVersion:output_type -> ctrl.v1.CreateVersionResponse - 5, // 11: ctrl.v1.VersionService.GetVersion:output_type -> ctrl.v1.GetVersionResponse + 2, // 8: ctrl.v1.DeploymentService.CreateDeployment:input_type -> ctrl.v1.CreateDeploymentRequest + 4, // 9: ctrl.v1.DeploymentService.GetDeployment:input_type -> ctrl.v1.GetDeploymentRequest + 3, // 10: ctrl.v1.DeploymentService.CreateDeployment:output_type -> ctrl.v1.CreateDeploymentResponse + 5, // 11: ctrl.v1.DeploymentService.GetDeployment:output_type -> ctrl.v1.GetDeploymentResponse 10, // [10:12] is the sub-list for method output_type 8, // [8:10] is the sub-list for method input_type 8, // [8:8] is the sub-list for extension type_name @@ -1001,27 +1001,27 @@ var file_proto_ctrl_v1_version_proto_depIdxs = []int32{ 0, // [0:8] is the sub-list for field type_name } -func init() { file_proto_ctrl_v1_version_proto_init() } -func file_proto_ctrl_v1_version_proto_init() { - if File_proto_ctrl_v1_version_proto != nil { +func init() { file_proto_ctrl_v1_deployment_proto_init() } +func file_proto_ctrl_v1_deployment_proto_init() { + if File_proto_ctrl_v1_deployment_proto != nil { return } type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: unsafe.Slice(unsafe.StringData(file_proto_ctrl_v1_version_proto_rawDesc), len(file_proto_ctrl_v1_version_proto_rawDesc)), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_proto_ctrl_v1_deployment_proto_rawDesc), len(file_proto_ctrl_v1_deployment_proto_rawDesc)), NumEnums: 2, NumMessages: 9, NumExtensions: 0, NumServices: 1, }, - GoTypes: file_proto_ctrl_v1_version_proto_goTypes, - DependencyIndexes: file_proto_ctrl_v1_version_proto_depIdxs, - EnumInfos: file_proto_ctrl_v1_version_proto_enumTypes, - MessageInfos: file_proto_ctrl_v1_version_proto_msgTypes, + GoTypes: file_proto_ctrl_v1_deployment_proto_goTypes, + DependencyIndexes: file_proto_ctrl_v1_deployment_proto_depIdxs, + EnumInfos: file_proto_ctrl_v1_deployment_proto_enumTypes, + MessageInfos: file_proto_ctrl_v1_deployment_proto_msgTypes, }.Build() - File_proto_ctrl_v1_version_proto = out.File - file_proto_ctrl_v1_version_proto_goTypes = nil - file_proto_ctrl_v1_version_proto_depIdxs = nil + File_proto_ctrl_v1_deployment_proto = out.File + file_proto_ctrl_v1_deployment_proto_goTypes = nil + file_proto_ctrl_v1_deployment_proto_depIdxs = nil } diff --git a/go/gen/proto/metal/vmprovisioner/v1/wip.pb.go b/go/gen/proto/metal/vmprovisioner/v1/wip.pb.go new file mode 100644 index 0000000000..486bb3992a --- /dev/null +++ b/go/gen/proto/metal/vmprovisioner/v1/wip.pb.go @@ -0,0 +1,279 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.36.8 +// protoc (unknown) +// source: proto/metal/vmprovisioner/v1/wip.proto + +package vmprovisionerv1 + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" + unsafe "unsafe" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type NetworkSize int32 + +const ( + // These are made up + NetworkSize_NETWORK_SIZE_SMALL NetworkSize = 0 + NetworkSize_NETWORK_SIZE_MEDIUM NetworkSize = 1 + NetworkSize_NETWORK_SIZE_LARGE NetworkSize = 2 +) + +// Enum value maps for NetworkSize. +var ( + NetworkSize_name = map[int32]string{ + 0: "NETWORK_SIZE_SMALL", + 1: "NETWORK_SIZE_MEDIUM", + 2: "NETWORK_SIZE_LARGE", + } + NetworkSize_value = map[string]int32{ + "NETWORK_SIZE_SMALL": 0, + "NETWORK_SIZE_MEDIUM": 1, + "NETWORK_SIZE_LARGE": 2, + } +) + +func (x NetworkSize) Enum() *NetworkSize { + p := new(NetworkSize) + *p = x + return p +} + +func (x NetworkSize) String() string { + return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x)) +} + +func (NetworkSize) Descriptor() protoreflect.EnumDescriptor { + return file_proto_metal_vmprovisioner_v1_wip_proto_enumTypes[0].Descriptor() +} + +func (NetworkSize) Type() protoreflect.EnumType { + return &file_proto_metal_vmprovisioner_v1_wip_proto_enumTypes[0] +} + +func (x NetworkSize) Number() protoreflect.EnumNumber { + return protoreflect.EnumNumber(x) +} + +// Deprecated: Use NetworkSize.Descriptor instead. +func (NetworkSize) EnumDescriptor() ([]byte, []int) { + return file_proto_metal_vmprovisioner_v1_wip_proto_rawDescGZIP(), []int{0} +} + +// from our call, ian +// lmk what you think, it's not hooked up yet and we can change it as you wish. +type CreateVmRequestV2 struct { + state protoimpl.MessageState `protogen:"open.v1"` + VmId string `protobuf:"bytes,1,opt,name=vm_id,json=vmId,proto3" json:"vm_id,omitempty"` + // I know you want this elsewhere but I really don't understand what you want me to do. + // cause just defining it as `message DeploymentId string` doesn't make anything better. + // please send help + DeploymentId string `protobuf:"bytes,2,opt,name=deployment_id,json=deploymentId,proto3" json:"deployment_id,omitempty"` + // 1024 = 1 vcpu + CpuMillicores uint32 `protobuf:"varint,3,opt,name=cpu_millicores,json=cpuMillicores,proto3" json:"cpu_millicores,omitempty"` // millicores, e.g., 1024 = 1 vCPU + MemoryBytes uint64 `protobuf:"varint,4,opt,name=memory_bytes,json=memoryBytes,proto3" json:"memory_bytes,omitempty"` // bytes + DockerImage string `protobuf:"bytes,5,opt,name=docker_image,json=dockerImage,proto3" json:"docker_image,omitempty"` // full image ref: registry/repo:tag or digest + NetworkSize NetworkSize `protobuf:"varint,6,opt,name=network_size,json=networkSize,proto3,enum=metal.vmprovisioner.v1.NetworkSize" json:"network_size,omitempty"` // default: NETWORK_SIZE_UNSPECIFIED + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateVmRequestV2) Reset() { + *x = CreateVmRequestV2{} + mi := &file_proto_metal_vmprovisioner_v1_wip_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateVmRequestV2) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateVmRequestV2) ProtoMessage() {} + +func (x *CreateVmRequestV2) ProtoReflect() protoreflect.Message { + mi := &file_proto_metal_vmprovisioner_v1_wip_proto_msgTypes[0] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreateVmRequestV2.ProtoReflect.Descriptor instead. +func (*CreateVmRequestV2) Descriptor() ([]byte, []int) { + return file_proto_metal_vmprovisioner_v1_wip_proto_rawDescGZIP(), []int{0} +} + +func (x *CreateVmRequestV2) GetVmId() string { + if x != nil { + return x.VmId + } + return "" +} + +func (x *CreateVmRequestV2) GetDeploymentId() string { + if x != nil { + return x.DeploymentId + } + return "" +} + +func (x *CreateVmRequestV2) GetCpuMillicores() uint32 { + if x != nil { + return x.CpuMillicores + } + return 0 +} + +func (x *CreateVmRequestV2) GetMemoryBytes() uint64 { + if x != nil { + return x.MemoryBytes + } + return 0 +} + +func (x *CreateVmRequestV2) GetDockerImage() string { + if x != nil { + return x.DockerImage + } + return "" +} + +func (x *CreateVmRequestV2) GetNetworkSize() NetworkSize { + if x != nil { + return x.NetworkSize + } + return NetworkSize_NETWORK_SIZE_SMALL +} + +type CreateVmRespomseV2 struct { + state protoimpl.MessageState `protogen:"open.v1"` + // metalhost_ip:port + Address string `protobuf:"bytes,1,opt,name=address,proto3" json:"address,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateVmRespomseV2) Reset() { + *x = CreateVmRespomseV2{} + mi := &file_proto_metal_vmprovisioner_v1_wip_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateVmRespomseV2) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateVmRespomseV2) ProtoMessage() {} + +func (x *CreateVmRespomseV2) ProtoReflect() protoreflect.Message { + mi := &file_proto_metal_vmprovisioner_v1_wip_proto_msgTypes[1] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use CreateVmRespomseV2.ProtoReflect.Descriptor instead. +func (*CreateVmRespomseV2) Descriptor() ([]byte, []int) { + return file_proto_metal_vmprovisioner_v1_wip_proto_rawDescGZIP(), []int{1} +} + +func (x *CreateVmRespomseV2) GetAddress() string { + if x != nil { + return x.Address + } + return "" +} + +var File_proto_metal_vmprovisioner_v1_wip_proto protoreflect.FileDescriptor + +const file_proto_metal_vmprovisioner_v1_wip_proto_rawDesc = "" + + "\n" + + "&proto/metal/vmprovisioner/v1/wip.proto\x12\x16metal.vmprovisioner.v1\"\x82\x02\n" + + "\x11CreateVmRequestV2\x12\x13\n" + + "\x05vm_id\x18\x01 \x01(\tR\x04vmId\x12#\n" + + "\rdeployment_id\x18\x02 \x01(\tR\fdeploymentId\x12%\n" + + "\x0ecpu_millicores\x18\x03 \x01(\rR\rcpuMillicores\x12!\n" + + "\fmemory_bytes\x18\x04 \x01(\x04R\vmemoryBytes\x12!\n" + + "\fdocker_image\x18\x05 \x01(\tR\vdockerImage\x12F\n" + + "\fnetwork_size\x18\x06 \x01(\x0e2#.metal.vmprovisioner.v1.NetworkSizeR\vnetworkSize\".\n" + + "\x12CreateVmRespomseV2\x12\x18\n" + + "\aaddress\x18\x01 \x01(\tR\aaddress*V\n" + + "\vNetworkSize\x12\x16\n" + + "\x12NETWORK_SIZE_SMALL\x10\x00\x12\x17\n" + + "\x13NETWORK_SIZE_MEDIUM\x10\x01\x12\x16\n" + + "\x12NETWORK_SIZE_LARGE\x10\x02BNZLgithub.com/unkeyed/unkey/go/gen/proto/metal/vmprovisioner/v1;vmprovisionerv1b\x06proto3" + +var ( + file_proto_metal_vmprovisioner_v1_wip_proto_rawDescOnce sync.Once + file_proto_metal_vmprovisioner_v1_wip_proto_rawDescData []byte +) + +func file_proto_metal_vmprovisioner_v1_wip_proto_rawDescGZIP() []byte { + file_proto_metal_vmprovisioner_v1_wip_proto_rawDescOnce.Do(func() { + file_proto_metal_vmprovisioner_v1_wip_proto_rawDescData = protoimpl.X.CompressGZIP(unsafe.Slice(unsafe.StringData(file_proto_metal_vmprovisioner_v1_wip_proto_rawDesc), len(file_proto_metal_vmprovisioner_v1_wip_proto_rawDesc))) + }) + return file_proto_metal_vmprovisioner_v1_wip_proto_rawDescData +} + +var file_proto_metal_vmprovisioner_v1_wip_proto_enumTypes = make([]protoimpl.EnumInfo, 1) +var file_proto_metal_vmprovisioner_v1_wip_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_proto_metal_vmprovisioner_v1_wip_proto_goTypes = []any{ + (NetworkSize)(0), // 0: metal.vmprovisioner.v1.NetworkSize + (*CreateVmRequestV2)(nil), // 1: metal.vmprovisioner.v1.CreateVmRequestV2 + (*CreateVmRespomseV2)(nil), // 2: metal.vmprovisioner.v1.CreateVmRespomseV2 +} +var file_proto_metal_vmprovisioner_v1_wip_proto_depIdxs = []int32{ + 0, // 0: metal.vmprovisioner.v1.CreateVmRequestV2.network_size:type_name -> metal.vmprovisioner.v1.NetworkSize + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_proto_metal_vmprovisioner_v1_wip_proto_init() } +func file_proto_metal_vmprovisioner_v1_wip_proto_init() { + if File_proto_metal_vmprovisioner_v1_wip_proto != nil { + return + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: unsafe.Slice(unsafe.StringData(file_proto_metal_vmprovisioner_v1_wip_proto_rawDesc), len(file_proto_metal_vmprovisioner_v1_wip_proto_rawDesc)), + NumEnums: 1, + NumMessages: 2, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_proto_metal_vmprovisioner_v1_wip_proto_goTypes, + DependencyIndexes: file_proto_metal_vmprovisioner_v1_wip_proto_depIdxs, + EnumInfos: file_proto_metal_vmprovisioner_v1_wip_proto_enumTypes, + MessageInfos: file_proto_metal_vmprovisioner_v1_wip_proto_msgTypes, + }.Build() + File_proto_metal_vmprovisioner_v1_wip_proto = out.File + file_proto_metal_vmprovisioner_v1_wip_proto_goTypes = nil + file_proto_metal_vmprovisioner_v1_wip_proto_depIdxs = nil +} diff --git a/go/gen/proto/partition/v1/gateway.pb.go b/go/gen/proto/partition/v1/gateway.pb.go index 7dc955dd97..60cc3c5043 100644 --- a/go/gen/proto/partition/v1/gateway.pb.go +++ b/go/gen/proto/partition/v1/gateway.pb.go @@ -24,23 +24,16 @@ const ( // GatewayConfig contains all configuration needed for a hostname // including deployment metadata and middleware configurations type GatewayConfig struct { - state protoimpl.MessageState `protogen:"open.v1"` - // Routing configuration - IsEnabled bool `protobuf:"varint,1,opt,name=is_enabled,json=isEnabled,proto3" json:"is_enabled,omitempty"` + state protoimpl.MessageState `protogen:"open.v1"` + Project *Project `protobuf:"bytes,1,opt,name=project,proto3" json:"project,omitempty"` // Deployment information - DeploymentId string `protobuf:"bytes,2,opt,name=deployment_id,json=deploymentId,proto3" json:"deployment_id,omitempty"` - WorkspaceId string `protobuf:"bytes,3,opt,name=workspace_id,json=workspaceId,proto3" json:"workspace_id,omitempty"` - ProjectId string `protobuf:"bytes,4,opt,name=project_id,json=projectId,proto3" json:"project_id,omitempty"` - Environment string `protobuf:"bytes,5,opt,name=environment,proto3" json:"environment,omitempty"` - Vms []*VM `protobuf:"bytes,6,rep,name=vms,proto3" json:"vms,omitempty"` + Deployment *Deployment `protobuf:"bytes,2,opt,name=deployment,proto3" json:"deployment,omitempty"` + Vms []*VM `protobuf:"bytes,3,rep,name=vms,proto3" json:"vms,omitempty"` // Middleware configurations - AuthConfig *AuthConfig `protobuf:"bytes,10,opt,name=auth_config,json=authConfig,proto3" json:"auth_config,omitempty"` - ValidationConfig *ValidationConfig `protobuf:"bytes,11,opt,name=validation_config,json=validationConfig,proto3" json:"validation_config,omitempty"` - // Deployment metadata - GitCommitSha string `protobuf:"bytes,20,opt,name=git_commit_sha,json=gitCommitSha,proto3" json:"git_commit_sha,omitempty"` - GitBranch string `protobuf:"bytes,21,opt,name=git_branch,json=gitBranch,proto3" json:"git_branch,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + AuthConfig *AuthConfig `protobuf:"bytes,4,opt,name=auth_config,json=authConfig,proto3,oneof" json:"auth_config,omitempty"` + ValidationConfig *ValidationConfig `protobuf:"bytes,5,opt,name=validation_config,json=validationConfig,proto3,oneof" json:"validation_config,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *GatewayConfig) Reset() { @@ -73,87 +66,155 @@ func (*GatewayConfig) Descriptor() ([]byte, []int) { return file_proto_partition_v1_gateway_proto_rawDescGZIP(), []int{0} } -func (x *GatewayConfig) GetIsEnabled() bool { +func (x *GatewayConfig) GetProject() *Project { if x != nil { - return x.IsEnabled + return x.Project } - return false + return nil } -func (x *GatewayConfig) GetDeploymentId() string { +func (x *GatewayConfig) GetDeployment() *Deployment { if x != nil { - return x.DeploymentId + return x.Deployment } - return "" + return nil } -func (x *GatewayConfig) GetWorkspaceId() string { +func (x *GatewayConfig) GetVms() []*VM { if x != nil { - return x.WorkspaceId + return x.Vms } - return "" + return nil } -func (x *GatewayConfig) GetProjectId() string { +func (x *GatewayConfig) GetAuthConfig() *AuthConfig { if x != nil { - return x.ProjectId + return x.AuthConfig } - return "" + return nil } -func (x *GatewayConfig) GetEnvironment() string { +func (x *GatewayConfig) GetValidationConfig() *ValidationConfig { if x != nil { - return x.Environment + return x.ValidationConfig } - return "" + return nil } -func (x *GatewayConfig) GetVms() []*VM { +type Deployment struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + IsEnabled bool `protobuf:"varint,2,opt,name=is_enabled,json=isEnabled,proto3" json:"is_enabled,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Deployment) Reset() { + *x = Deployment{} + mi := &file_proto_partition_v1_gateway_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Deployment) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Deployment) ProtoMessage() {} + +func (x *Deployment) ProtoReflect() protoreflect.Message { + mi := &file_proto_partition_v1_gateway_proto_msgTypes[1] if x != nil { - return x.Vms + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms } - return nil + return mi.MessageOf(x) } -func (x *GatewayConfig) GetAuthConfig() *AuthConfig { +// Deprecated: Use Deployment.ProtoReflect.Descriptor instead. +func (*Deployment) Descriptor() ([]byte, []int) { + return file_proto_partition_v1_gateway_proto_rawDescGZIP(), []int{1} +} + +func (x *Deployment) GetId() string { if x != nil { - return x.AuthConfig + return x.Id } - return nil + return "" } -func (x *GatewayConfig) GetValidationConfig() *ValidationConfig { +func (x *Deployment) GetIsEnabled() bool { if x != nil { - return x.ValidationConfig + return x.IsEnabled } - return nil + return false +} + +type Project struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` + IsEnabled bool `protobuf:"varint,2,opt,name=is_enabled,json=isEnabled,proto3" json:"is_enabled,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } -func (x *GatewayConfig) GetGitCommitSha() string { +func (x *Project) Reset() { + *x = Project{} + mi := &file_proto_partition_v1_gateway_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Project) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Project) ProtoMessage() {} + +func (x *Project) ProtoReflect() protoreflect.Message { + mi := &file_proto_partition_v1_gateway_proto_msgTypes[2] if x != nil { - return x.GitCommitSha + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms } - return "" + return mi.MessageOf(x) +} + +// Deprecated: Use Project.ProtoReflect.Descriptor instead. +func (*Project) Descriptor() ([]byte, []int) { + return file_proto_partition_v1_gateway_proto_rawDescGZIP(), []int{2} } -func (x *GatewayConfig) GetGitBranch() string { +func (x *Project) GetId() string { if x != nil { - return x.GitBranch + return x.Id } return "" } +func (x *Project) GetIsEnabled() bool { + if x != nil { + return x.IsEnabled + } + return false +} + type VM struct { state protoimpl.MessageState `protogen:"open.v1"` Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` - Region string `protobuf:"bytes,2,opt,name=region,proto3" json:"region,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *VM) Reset() { *x = VM{} - mi := &file_proto_partition_v1_gateway_proto_msgTypes[1] + mi := &file_proto_partition_v1_gateway_proto_msgTypes[3] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -165,7 +226,7 @@ func (x *VM) String() string { func (*VM) ProtoMessage() {} func (x *VM) ProtoReflect() protoreflect.Message { - mi := &file_proto_partition_v1_gateway_proto_msgTypes[1] + mi := &file_proto_partition_v1_gateway_proto_msgTypes[3] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -178,7 +239,7 @@ func (x *VM) ProtoReflect() protoreflect.Message { // Deprecated: Use VM.ProtoReflect.Descriptor instead. func (*VM) Descriptor() ([]byte, []int) { - return file_proto_partition_v1_gateway_proto_rawDescGZIP(), []int{1} + return file_proto_partition_v1_gateway_proto_rawDescGZIP(), []int{3} } func (x *VM) GetId() string { @@ -188,27 +249,17 @@ func (x *VM) GetId() string { return "" } -func (x *VM) GetRegion() string { - if x != nil { - return x.Region - } - return "" -} - // Authentication middleware configuration type AuthConfig struct { - state protoimpl.MessageState `protogen:"open.v1"` - RequireApiKey bool `protobuf:"varint,1,opt,name=require_api_key,json=requireApiKey,proto3" json:"require_api_key,omitempty"` - KeyspaceId string `protobuf:"bytes,2,opt,name=keyspace_id,json=keyspaceId,proto3" json:"keyspace_id,omitempty"` - AllowAnonymous bool `protobuf:"varint,3,opt,name=allow_anonymous,json=allowAnonymous,proto3" json:"allow_anonymous,omitempty"` - Enabled bool `protobuf:"varint,4,opt,name=enabled,proto3" json:"enabled,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + KeyAuthId string `protobuf:"bytes,1,opt,name=key_auth_id,json=keyAuthId,proto3" json:"key_auth_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *AuthConfig) Reset() { *x = AuthConfig{} - mi := &file_proto_partition_v1_gateway_proto_msgTypes[2] + mi := &file_proto_partition_v1_gateway_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -220,7 +271,7 @@ func (x *AuthConfig) String() string { func (*AuthConfig) ProtoMessage() {} func (x *AuthConfig) ProtoReflect() protoreflect.Message { - mi := &file_proto_partition_v1_gateway_proto_msgTypes[2] + mi := &file_proto_partition_v1_gateway_proto_msgTypes[4] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -233,49 +284,27 @@ func (x *AuthConfig) ProtoReflect() protoreflect.Message { // Deprecated: Use AuthConfig.ProtoReflect.Descriptor instead. func (*AuthConfig) Descriptor() ([]byte, []int) { - return file_proto_partition_v1_gateway_proto_rawDescGZIP(), []int{2} + return file_proto_partition_v1_gateway_proto_rawDescGZIP(), []int{4} } -func (x *AuthConfig) GetRequireApiKey() bool { +func (x *AuthConfig) GetKeyAuthId() string { if x != nil { - return x.RequireApiKey - } - return false -} - -func (x *AuthConfig) GetKeyspaceId() string { - if x != nil { - return x.KeyspaceId + return x.KeyAuthId } return "" } -func (x *AuthConfig) GetAllowAnonymous() bool { - if x != nil { - return x.AllowAnonymous - } - return false -} - -func (x *AuthConfig) GetEnabled() bool { - if x != nil { - return x.Enabled - } - return false -} - // Request validation middleware configuration type ValidationConfig struct { state protoimpl.MessageState `protogen:"open.v1"` - Enabled bool `protobuf:"varint,1,opt,name=enabled,proto3" json:"enabled,omitempty"` - OpenapiSpec string `protobuf:"bytes,2,opt,name=openapi_spec,json=openapiSpec,proto3" json:"openapi_spec,omitempty"` + OpenapiSpec string `protobuf:"bytes,1,opt,name=openapi_spec,json=openapiSpec,proto3" json:"openapi_spec,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *ValidationConfig) Reset() { *x = ValidationConfig{} - mi := &file_proto_partition_v1_gateway_proto_msgTypes[3] + mi := &file_proto_partition_v1_gateway_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -287,7 +316,7 @@ func (x *ValidationConfig) String() string { func (*ValidationConfig) ProtoMessage() {} func (x *ValidationConfig) ProtoReflect() protoreflect.Message { - mi := &file_proto_partition_v1_gateway_proto_msgTypes[3] + mi := &file_proto_partition_v1_gateway_proto_msgTypes[5] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -300,14 +329,7 @@ func (x *ValidationConfig) ProtoReflect() protoreflect.Message { // Deprecated: Use ValidationConfig.ProtoReflect.Descriptor instead. func (*ValidationConfig) Descriptor() ([]byte, []int) { - return file_proto_partition_v1_gateway_proto_rawDescGZIP(), []int{3} -} - -func (x *ValidationConfig) GetEnabled() bool { - if x != nil { - return x.Enabled - } - return false + return file_proto_partition_v1_gateway_proto_rawDescGZIP(), []int{5} } func (x *ValidationConfig) GetOpenapiSpec() string { @@ -321,36 +343,34 @@ var File_proto_partition_v1_gateway_proto protoreflect.FileDescriptor const file_proto_partition_v1_gateway_proto_rawDesc = "" + "\n" + - " proto/partition/v1/gateway.proto\x12\fpartition.v1\"\xa8\x03\n" + - "\rGatewayConfig\x12\x1d\n" + + " proto/partition/v1/gateway.proto\x12\fpartition.v1\"\xd6\x02\n" + + "\rGatewayConfig\x12/\n" + + "\aproject\x18\x01 \x01(\v2\x15.partition.v1.ProjectR\aproject\x128\n" + + "\n" + + "deployment\x18\x02 \x01(\v2\x18.partition.v1.DeploymentR\n" + + "deployment\x12\"\n" + + "\x03vms\x18\x03 \x03(\v2\x10.partition.v1.VMR\x03vms\x12>\n" + + "\vauth_config\x18\x04 \x01(\v2\x18.partition.v1.AuthConfigH\x00R\n" + + "authConfig\x88\x01\x01\x12P\n" + + "\x11validation_config\x18\x05 \x01(\v2\x1e.partition.v1.ValidationConfigH\x01R\x10validationConfig\x88\x01\x01B\x0e\n" + + "\f_auth_configB\x14\n" + + "\x12_validation_config\";\n" + "\n" + - "is_enabled\x18\x01 \x01(\bR\tisEnabled\x12#\n" + - "\rdeployment_id\x18\x02 \x01(\tR\fdeploymentId\x12!\n" + - "\fworkspace_id\x18\x03 \x01(\tR\vworkspaceId\x12\x1d\n" + + "Deployment\x12\x0e\n" + + "\x02id\x18\x01 \x01(\tR\x02id\x12\x1d\n" + "\n" + - "project_id\x18\x04 \x01(\tR\tprojectId\x12 \n" + - "\venvironment\x18\x05 \x01(\tR\venvironment\x12\"\n" + - "\x03vms\x18\x06 \x03(\v2\x10.partition.v1.VMR\x03vms\x129\n" + - "\vauth_config\x18\n" + - " \x01(\v2\x18.partition.v1.AuthConfigR\n" + - "authConfig\x12K\n" + - "\x11validation_config\x18\v \x01(\v2\x1e.partition.v1.ValidationConfigR\x10validationConfig\x12$\n" + - "\x0egit_commit_sha\x18\x14 \x01(\tR\fgitCommitSha\x12\x1d\n" + + "is_enabled\x18\x02 \x01(\bR\tisEnabled\"8\n" + + "\aProject\x12\x0e\n" + + "\x02id\x18\x01 \x01(\tR\x02id\x12\x1d\n" + "\n" + - "git_branch\x18\x15 \x01(\tR\tgitBranch\",\n" + + "is_enabled\x18\x02 \x01(\bR\tisEnabled\"\x14\n" + "\x02VM\x12\x0e\n" + - "\x02id\x18\x01 \x01(\tR\x02id\x12\x16\n" + - "\x06region\x18\x02 \x01(\tR\x06region\"\x98\x01\n" + + "\x02id\x18\x01 \x01(\tR\x02id\",\n" + "\n" + - "AuthConfig\x12&\n" + - "\x0frequire_api_key\x18\x01 \x01(\bR\rrequireApiKey\x12\x1f\n" + - "\vkeyspace_id\x18\x02 \x01(\tR\n" + - "keyspaceId\x12'\n" + - "\x0fallow_anonymous\x18\x03 \x01(\bR\x0eallowAnonymous\x12\x18\n" + - "\aenabled\x18\x04 \x01(\bR\aenabled\"O\n" + - "\x10ValidationConfig\x12\x18\n" + - "\aenabled\x18\x01 \x01(\bR\aenabled\x12!\n" + - "\fopenapi_spec\x18\x02 \x01(\tR\vopenapiSpecB@Z>github.com/unkeyed/unkey/go/gen/proto/partition/v1;partitionv1b\x06proto3" + "AuthConfig\x12\x1e\n" + + "\vkey_auth_id\x18\x01 \x01(\tR\tkeyAuthId\"5\n" + + "\x10ValidationConfig\x12!\n" + + "\fopenapi_spec\x18\x01 \x01(\tR\vopenapiSpecB@Z>github.com/unkeyed/unkey/go/gen/proto/partition/v1;partitionv1b\x06proto3" var ( file_proto_partition_v1_gateway_proto_rawDescOnce sync.Once @@ -364,22 +384,26 @@ func file_proto_partition_v1_gateway_proto_rawDescGZIP() []byte { return file_proto_partition_v1_gateway_proto_rawDescData } -var file_proto_partition_v1_gateway_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_proto_partition_v1_gateway_proto_msgTypes = make([]protoimpl.MessageInfo, 6) var file_proto_partition_v1_gateway_proto_goTypes = []any{ (*GatewayConfig)(nil), // 0: partition.v1.GatewayConfig - (*VM)(nil), // 1: partition.v1.VM - (*AuthConfig)(nil), // 2: partition.v1.AuthConfig - (*ValidationConfig)(nil), // 3: partition.v1.ValidationConfig + (*Deployment)(nil), // 1: partition.v1.Deployment + (*Project)(nil), // 2: partition.v1.Project + (*VM)(nil), // 3: partition.v1.VM + (*AuthConfig)(nil), // 4: partition.v1.AuthConfig + (*ValidationConfig)(nil), // 5: partition.v1.ValidationConfig } var file_proto_partition_v1_gateway_proto_depIdxs = []int32{ - 1, // 0: partition.v1.GatewayConfig.vms:type_name -> partition.v1.VM - 2, // 1: partition.v1.GatewayConfig.auth_config:type_name -> partition.v1.AuthConfig - 3, // 2: partition.v1.GatewayConfig.validation_config:type_name -> partition.v1.ValidationConfig - 3, // [3:3] is the sub-list for method output_type - 3, // [3:3] is the sub-list for method input_type - 3, // [3:3] is the sub-list for extension type_name - 3, // [3:3] is the sub-list for extension extendee - 0, // [0:3] is the sub-list for field type_name + 2, // 0: partition.v1.GatewayConfig.project:type_name -> partition.v1.Project + 1, // 1: partition.v1.GatewayConfig.deployment:type_name -> partition.v1.Deployment + 3, // 2: partition.v1.GatewayConfig.vms:type_name -> partition.v1.VM + 4, // 3: partition.v1.GatewayConfig.auth_config:type_name -> partition.v1.AuthConfig + 5, // 4: partition.v1.GatewayConfig.validation_config:type_name -> partition.v1.ValidationConfig + 5, // [5:5] is the sub-list for method output_type + 5, // [5:5] is the sub-list for method input_type + 5, // [5:5] is the sub-list for extension type_name + 5, // [5:5] is the sub-list for extension extendee + 0, // [0:5] is the sub-list for field type_name } func init() { file_proto_partition_v1_gateway_proto_init() } @@ -387,13 +411,14 @@ func file_proto_partition_v1_gateway_proto_init() { if File_proto_partition_v1_gateway_proto != nil { return } + file_proto_partition_v1_gateway_proto_msgTypes[0].OneofWrappers = []any{} type x struct{} out := protoimpl.TypeBuilder{ File: protoimpl.DescBuilder{ GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_proto_partition_v1_gateway_proto_rawDesc), len(file_proto_partition_v1_gateway_proto_rawDesc)), NumEnums: 0, - NumMessages: 4, + NumMessages: 6, NumExtensions: 0, NumServices: 0, }, diff --git a/go/pkg/db/acme_challenge_find_by_token.sql_generated.go b/go/pkg/db/acme_challenge_find_by_token.sql_generated.go new file mode 100644 index 0000000000..284a782c9c --- /dev/null +++ b/go/pkg/db/acme_challenge_find_by_token.sql_generated.go @@ -0,0 +1,41 @@ +// Code generated by sqlc. DO NOT EDIT. +// versions: +// sqlc v1.29.0 +// source: acme_challenge_find_by_token.sql + +package db + +import ( + "context" +) + +const findAcmeChallengeByToken = `-- name: FindAcmeChallengeByToken :one +SELECT id, workspace_id, domain_id, token, type, authorization, status, expires_at, created_at, updated_at FROM acme_challenges WHERE workspace_id = ? AND domain_id = ? AND token = ? +` + +type FindAcmeChallengeByTokenParams struct { + WorkspaceID string `db:"workspace_id"` + DomainID string `db:"domain_id"` + Token string `db:"token"` +} + +// FindAcmeChallengeByToken +// +// SELECT id, workspace_id, domain_id, token, type, authorization, status, expires_at, created_at, updated_at FROM acme_challenges WHERE workspace_id = ? AND domain_id = ? AND token = ? +func (q *Queries) FindAcmeChallengeByToken(ctx context.Context, db DBTX, arg FindAcmeChallengeByTokenParams) (AcmeChallenge, error) { + row := db.QueryRowContext(ctx, findAcmeChallengeByToken, arg.WorkspaceID, arg.DomainID, arg.Token) + var i AcmeChallenge + err := row.Scan( + &i.ID, + &i.WorkspaceID, + &i.DomainID, + &i.Token, + &i.Type, + &i.Authorization, + &i.Status, + &i.ExpiresAt, + &i.CreatedAt, + &i.UpdatedAt, + ) + return i, err +} diff --git a/go/pkg/db/acme_challenge_insert.sql_generated.go b/go/pkg/db/acme_challenge_insert.sql_generated.go new file mode 100644 index 0000000000..9f0b4da745 --- /dev/null +++ b/go/pkg/db/acme_challenge_insert.sql_generated.go @@ -0,0 +1,85 @@ +// Code generated by sqlc. DO NOT EDIT. +// versions: +// sqlc v1.29.0 +// source: acme_challenge_insert.sql + +package db + +import ( + "context" + "database/sql" +) + +const insertAcmeChallenge = `-- name: InsertAcmeChallenge :exec +INSERT INTO acme_challenges ( + workspace_id, + domain_id, + token, + authorization, + status, + type, + created_at, + updated_at, + expires_at +) VALUES ( + ?, + ?, + ?, + ?, + ?, + ?, + ?, + ?, + ? +) +` + +type InsertAcmeChallengeParams struct { + WorkspaceID string `db:"workspace_id"` + DomainID string `db:"domain_id"` + Token string `db:"token"` + Authorization string `db:"authorization"` + Status AcmeChallengesStatus `db:"status"` + Type AcmeChallengesType `db:"type"` + CreatedAt int64 `db:"created_at"` + UpdatedAt sql.NullInt64 `db:"updated_at"` + ExpiresAt int64 `db:"expires_at"` +} + +// InsertAcmeChallenge +// +// INSERT INTO acme_challenges ( +// workspace_id, +// domain_id, +// token, +// authorization, +// status, +// type, +// created_at, +// updated_at, +// expires_at +// ) VALUES ( +// ?, +// ?, +// ?, +// ?, +// ?, +// ?, +// ?, +// ?, +// ? +// ) +func (q *Queries) InsertAcmeChallenge(ctx context.Context, db DBTX, arg InsertAcmeChallengeParams) error { + _, err := db.ExecContext(ctx, insertAcmeChallenge, + arg.WorkspaceID, + arg.DomainID, + arg.Token, + arg.Authorization, + arg.Status, + arg.Type, + arg.CreatedAt, + arg.UpdatedAt, + arg.ExpiresAt, + ) + return err +} diff --git a/go/pkg/db/domain_challenge_list_executable.sql_generated.go b/go/pkg/db/acme_challenge_list_executable.sql_generated.go similarity index 86% rename from go/pkg/db/domain_challenge_list_executable.sql_generated.go rename to go/pkg/db/acme_challenge_list_executable.sql_generated.go index 29d34b73e2..3d3a45b36b 100644 --- a/go/pkg/db/domain_challenge_list_executable.sql_generated.go +++ b/go/pkg/db/acme_challenge_list_executable.sql_generated.go @@ -1,7 +1,7 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 -// source: domain_challenge_list_executable.sql +// sqlc v1.29.0 +// source: acme_challenge_list_executable.sql package db @@ -10,7 +10,7 @@ import ( ) const listExecutableChallenges = `-- name: ListExecutableChallenges :many -SELECT dc.id, dc.workspace_id, domain FROM domain_challenges dc +SELECT dc.id, dc.workspace_id, d.domain FROM acme_challenges dc JOIN domains d ON dc.domain_id = d.id WHERE dc.status = 'waiting' OR (dc.status = 'verified' AND dc.expires_at <= DATE_ADD(NOW(), INTERVAL 30 DAY)) ORDER BY d.created_at ASC @@ -24,7 +24,7 @@ type ListExecutableChallengesRow struct { // ListExecutableChallenges // -// SELECT dc.id, dc.workspace_id, domain FROM domain_challenges dc +// SELECT dc.id, dc.workspace_id, d.domain FROM acme_challenges dc // JOIN domains d ON dc.domain_id = d.id // WHERE dc.status = 'waiting' OR (dc.status = 'verified' AND dc.expires_at <= DATE_ADD(NOW(), INTERVAL 30 DAY)) // ORDER BY d.created_at ASC diff --git a/go/pkg/db/acme_challenge_try_claiming.sql_generated.go b/go/pkg/db/acme_challenge_try_claiming.sql_generated.go new file mode 100644 index 0000000000..00d1978e01 --- /dev/null +++ b/go/pkg/db/acme_challenge_try_claiming.sql_generated.go @@ -0,0 +1,33 @@ +// Code generated by sqlc. DO NOT EDIT. +// versions: +// sqlc v1.29.0 +// source: acme_challenge_try_claiming.sql + +package db + +import ( + "context" + "database/sql" +) + +const updateAcmeChallengeTryClaiming = `-- name: UpdateAcmeChallengeTryClaiming :exec +UPDATE acme_challenges +SET status = ?, updated_at = ? +WHERE domain_id = ? AND status = 'waiting' +` + +type UpdateAcmeChallengeTryClaimingParams struct { + Status AcmeChallengesStatus `db:"status"` + UpdatedAt sql.NullInt64 `db:"updated_at"` + DomainID string `db:"domain_id"` +} + +// UpdateAcmeChallengeTryClaiming +// +// UPDATE acme_challenges +// SET status = ?, updated_at = ? +// WHERE domain_id = ? AND status = 'waiting' +func (q *Queries) UpdateAcmeChallengeTryClaiming(ctx context.Context, db DBTX, arg UpdateAcmeChallengeTryClaimingParams) error { + _, err := db.ExecContext(ctx, updateAcmeChallengeTryClaiming, arg.Status, arg.UpdatedAt, arg.DomainID) + return err +} diff --git a/go/pkg/db/acme_challenge_update_expires_at.sql_generated.go b/go/pkg/db/acme_challenge_update_expires_at.sql_generated.go new file mode 100644 index 0000000000..9097d73a1a --- /dev/null +++ b/go/pkg/db/acme_challenge_update_expires_at.sql_generated.go @@ -0,0 +1,27 @@ +// Code generated by sqlc. DO NOT EDIT. +// versions: +// sqlc v1.29.0 +// source: acme_challenge_update_expires_at.sql + +package db + +import ( + "context" +) + +const updateAcmeChallengeExpiresAt = `-- name: UpdateAcmeChallengeExpiresAt :exec +UPDATE acme_challenges SET expires_at = ? WHERE id = ? +` + +type UpdateAcmeChallengeExpiresAtParams struct { + ExpiresAt int64 `db:"expires_at"` + ID uint64 `db:"id"` +} + +// UpdateAcmeChallengeExpiresAt +// +// UPDATE acme_challenges SET expires_at = ? WHERE id = ? +func (q *Queries) UpdateAcmeChallengeExpiresAt(ctx context.Context, db DBTX, arg UpdateAcmeChallengeExpiresAtParams) error { + _, err := db.ExecContext(ctx, updateAcmeChallengeExpiresAt, arg.ExpiresAt, arg.ID) + return err +} diff --git a/go/pkg/db/acme_challenge_update_pending.sql_generated.go b/go/pkg/db/acme_challenge_update_pending.sql_generated.go new file mode 100644 index 0000000000..2a9bd8bd14 --- /dev/null +++ b/go/pkg/db/acme_challenge_update_pending.sql_generated.go @@ -0,0 +1,41 @@ +// Code generated by sqlc. DO NOT EDIT. +// versions: +// sqlc v1.29.0 +// source: acme_challenge_update_pending.sql + +package db + +import ( + "context" + "database/sql" +) + +const updateAcmeChallengePending = `-- name: UpdateAcmeChallengePending :exec +UPDATE acme_challenges +SET status = ?, token = ?, authorization = ?, updated_at = ? +WHERE domain_id = ? +` + +type UpdateAcmeChallengePendingParams struct { + Status AcmeChallengesStatus `db:"status"` + Token string `db:"token"` + Authorization string `db:"authorization"` + UpdatedAt sql.NullInt64 `db:"updated_at"` + DomainID string `db:"domain_id"` +} + +// UpdateAcmeChallengePending +// +// UPDATE acme_challenges +// SET status = ?, token = ?, authorization = ?, updated_at = ? +// WHERE domain_id = ? +func (q *Queries) UpdateAcmeChallengePending(ctx context.Context, db DBTX, arg UpdateAcmeChallengePendingParams) error { + _, err := db.ExecContext(ctx, updateAcmeChallengePending, + arg.Status, + arg.Token, + arg.Authorization, + arg.UpdatedAt, + arg.DomainID, + ) + return err +} diff --git a/go/pkg/db/acme_challenge_update_status.sql_generated.go b/go/pkg/db/acme_challenge_update_status.sql_generated.go new file mode 100644 index 0000000000..2c6a9d60f6 --- /dev/null +++ b/go/pkg/db/acme_challenge_update_status.sql_generated.go @@ -0,0 +1,33 @@ +// Code generated by sqlc. DO NOT EDIT. +// versions: +// sqlc v1.29.0 +// source: acme_challenge_update_status.sql + +package db + +import ( + "context" + "database/sql" +) + +const updateAcmeChallengeStatus = `-- name: UpdateAcmeChallengeStatus :exec +UPDATE acme_challenges +SET status = ?, updated_at = ? +WHERE domain_id = ? +` + +type UpdateAcmeChallengeStatusParams struct { + Status AcmeChallengesStatus `db:"status"` + UpdatedAt sql.NullInt64 `db:"updated_at"` + DomainID string `db:"domain_id"` +} + +// UpdateAcmeChallengeStatus +// +// UPDATE acme_challenges +// SET status = ?, updated_at = ? +// WHERE domain_id = ? +func (q *Queries) UpdateAcmeChallengeStatus(ctx context.Context, db DBTX, arg UpdateAcmeChallengeStatusParams) error { + _, err := db.ExecContext(ctx, updateAcmeChallengeStatus, arg.Status, arg.UpdatedAt, arg.DomainID) + return err +} diff --git a/go/pkg/db/acme_user_find_by_workspace_id.sql_generated.go b/go/pkg/db/acme_user_find_by_workspace_id.sql_generated.go index 4a8664bf1c..2ae5a38562 100644 --- a/go/pkg/db/acme_user_find_by_workspace_id.sql_generated.go +++ b/go/pkg/db/acme_user_find_by_workspace_id.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: acme_user_find_by_workspace_id.sql package db diff --git a/go/pkg/db/acme_user_insert.sql_generated.go b/go/pkg/db/acme_user_insert.sql_generated.go index c29c612cd5..9d3961c02b 100644 --- a/go/pkg/db/acme_user_insert.sql_generated.go +++ b/go/pkg/db/acme_user_insert.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: acme_user_insert.sql package db diff --git a/go/pkg/db/acme_user_update_registered.sql_generated.go b/go/pkg/db/acme_user_update_registered.sql_generated.go deleted file mode 100644 index bcf036a2e8..0000000000 --- a/go/pkg/db/acme_user_update_registered.sql_generated.go +++ /dev/null @@ -1,27 +0,0 @@ -// Code generated by sqlc. DO NOT EDIT. -// versions: -// sqlc v1.27.0 -// source: acme_user_update_registered.sql - -package db - -import ( - "context" -) - -const updateAcmeUserRegistered = `-- name: UpdateAcmeUserRegistered :exec -UPDATE acme_users SET registered = ? WHERE id = ? -` - -type UpdateAcmeUserRegisteredParams struct { - Registered bool `db:"registered"` - ID uint64 `db:"id"` -} - -// UpdateAcmeUserRegistered -// -// UPDATE acme_users SET registered = ? WHERE id = ? -func (q *Queries) UpdateAcmeUserRegistered(ctx context.Context, db DBTX, arg UpdateAcmeUserRegisteredParams) error { - _, err := db.ExecContext(ctx, updateAcmeUserRegistered, arg.Registered, arg.ID) - return err -} diff --git a/go/pkg/db/acme_user_update_registration_uri.sql_generated.go b/go/pkg/db/acme_user_update_registration_uri.sql_generated.go index fde969db7b..56e2027fc3 100644 --- a/go/pkg/db/acme_user_update_registration_uri.sql_generated.go +++ b/go/pkg/db/acme_user_update_registration_uri.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: acme_user_update_registration_uri.sql package db diff --git a/go/pkg/db/api_find_by_id.sql_generated.go b/go/pkg/db/api_find_by_id.sql_generated.go index 1873587781..bd050823f1 100644 --- a/go/pkg/db/api_find_by_id.sql_generated.go +++ b/go/pkg/db/api_find_by_id.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: api_find_by_id.sql package db diff --git a/go/pkg/db/api_find_live_by_id.sql_generated.go b/go/pkg/db/api_find_live_by_id.sql_generated.go index 04484987d4..cf336c8773 100644 --- a/go/pkg/db/api_find_live_by_id.sql_generated.go +++ b/go/pkg/db/api_find_live_by_id.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: api_find_live_by_id.sql package db diff --git a/go/pkg/db/api_insert.sql_generated.go b/go/pkg/db/api_insert.sql_generated.go index 4c8dcff65c..19d1ba303e 100644 --- a/go/pkg/db/api_insert.sql_generated.go +++ b/go/pkg/db/api_insert.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: api_insert.sql package db diff --git a/go/pkg/db/api_soft_delete.sql_generated.go b/go/pkg/db/api_soft_delete.sql_generated.go index b2115b988b..530b3f7e0e 100644 --- a/go/pkg/db/api_soft_delete.sql_generated.go +++ b/go/pkg/db/api_soft_delete.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: api_soft_delete.sql package db diff --git a/go/pkg/db/api_update_delete_protection.sql_generated.go b/go/pkg/db/api_update_delete_protection.sql_generated.go index 9030e931fc..1628a224ed 100644 --- a/go/pkg/db/api_update_delete_protection.sql_generated.go +++ b/go/pkg/db/api_update_delete_protection.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: api_update_delete_protection.sql package db diff --git a/go/pkg/db/audit_log_find_target_by_id.sql_generated.go b/go/pkg/db/audit_log_find_target_by_id.sql_generated.go index 5d54127ab2..9e41b15e23 100644 --- a/go/pkg/db/audit_log_find_target_by_id.sql_generated.go +++ b/go/pkg/db/audit_log_find_target_by_id.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: audit_log_find_target_by_id.sql package db diff --git a/go/pkg/db/audit_log_insert.sql_generated.go b/go/pkg/db/audit_log_insert.sql_generated.go index c204852578..120da97296 100644 --- a/go/pkg/db/audit_log_insert.sql_generated.go +++ b/go/pkg/db/audit_log_insert.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: audit_log_insert.sql package db diff --git a/go/pkg/db/audit_log_target_insert.sql_generated.go b/go/pkg/db/audit_log_target_insert.sql_generated.go index 8afd7d6547..5d20f7faf0 100644 --- a/go/pkg/db/audit_log_target_insert.sql_generated.go +++ b/go/pkg/db/audit_log_target_insert.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: audit_log_target_insert.sql package db diff --git a/go/pkg/db/build_find_by_id.sql_generated.go b/go/pkg/db/build_find_by_id.sql_generated.go deleted file mode 100644 index 0646b6d33d..0000000000 --- a/go/pkg/db/build_find_by_id.sql_generated.go +++ /dev/null @@ -1,71 +0,0 @@ -// Code generated by sqlc. DO NOT EDIT. -// versions: -// sqlc v1.28.0 -// source: build_find_by_id.sql - -package db - -import ( - "context" -) - -const findBuildById = `-- name: FindBuildById :one -SELECT - id, - workspace_id, - project_id, - deployment_id, - rootfs_image_id, - git_commit_sha, - git_branch, - status, - build_tool, - error_message, - started_at, - completed_at, - created_at, - updated_at -FROM ` + "`" + `builds` + "`" + ` -WHERE id = ? -` - -// FindBuildById -// -// SELECT -// id, -// workspace_id, -// project_id, -// deployment_id, -// rootfs_image_id, -// git_commit_sha, -// git_branch, -// status, -// build_tool, -// error_message, -// started_at, -// completed_at, -// created_at, -// updated_at -// FROM `builds` -// WHERE id = ? -func (q *Queries) FindBuildById(ctx context.Context, db DBTX, id string) (Build, error) { - row := db.QueryRowContext(ctx, findBuildById, id) - var i Build - err := row.Scan( - &i.ID, - &i.WorkspaceID, - &i.ProjectID, - &i.DeploymentID, - &i.RootfsImageID, - &i.GitCommitSha, - &i.GitBranch, - &i.Status, - &i.BuildTool, - &i.ErrorMessage, - &i.StartedAt, - &i.CompletedAt, - &i.CreatedAt, - &i.UpdatedAt, - ) - return i, err -} diff --git a/go/pkg/db/build_find_latest_by_deployment_id.sql_generated.go b/go/pkg/db/build_find_latest_by_deployment_id.sql_generated.go deleted file mode 100644 index fd09780bec..0000000000 --- a/go/pkg/db/build_find_latest_by_deployment_id.sql_generated.go +++ /dev/null @@ -1,75 +0,0 @@ -// Code generated by sqlc. DO NOT EDIT. -// versions: -// sqlc v1.28.0 -// source: build_find_latest_by_deployment_id.sql - -package db - -import ( - "context" -) - -const findLatestBuildByDeploymentId = `-- name: FindLatestBuildByDeploymentId :one -SELECT - id, - workspace_id, - project_id, - deployment_id, - rootfs_image_id, - git_commit_sha, - git_branch, - status, - build_tool, - error_message, - started_at, - completed_at, - created_at, - updated_at -FROM ` + "`" + `builds` + "`" + ` -WHERE deployment_id = ? -ORDER BY created_at DESC -LIMIT 1 -` - -// FindLatestBuildByDeploymentId -// -// SELECT -// id, -// workspace_id, -// project_id, -// deployment_id, -// rootfs_image_id, -// git_commit_sha, -// git_branch, -// status, -// build_tool, -// error_message, -// started_at, -// completed_at, -// created_at, -// updated_at -// FROM `builds` -// WHERE deployment_id = ? -// ORDER BY created_at DESC -// LIMIT 1 -func (q *Queries) FindLatestBuildByDeploymentId(ctx context.Context, db DBTX, deploymentID string) (Build, error) { - row := db.QueryRowContext(ctx, findLatestBuildByDeploymentId, deploymentID) - var i Build - err := row.Scan( - &i.ID, - &i.WorkspaceID, - &i.ProjectID, - &i.DeploymentID, - &i.RootfsImageID, - &i.GitCommitSha, - &i.GitBranch, - &i.Status, - &i.BuildTool, - &i.ErrorMessage, - &i.StartedAt, - &i.CompletedAt, - &i.CreatedAt, - &i.UpdatedAt, - ) - return i, err -} diff --git a/go/pkg/db/build_insert.sql_generated.go b/go/pkg/db/build_insert.sql_generated.go deleted file mode 100644 index 793bb97e9f..0000000000 --- a/go/pkg/db/build_insert.sql_generated.go +++ /dev/null @@ -1,96 +0,0 @@ -// Code generated by sqlc. DO NOT EDIT. -// versions: -// sqlc v1.28.0 -// source: build_insert.sql - -package db - -import ( - "context" -) - -const insertBuild = `-- name: InsertBuild :exec -INSERT INTO builds ( - id, - workspace_id, - project_id, - deployment_id, - rootfs_image_id, - git_commit_sha, - git_branch, - status, - build_tool, - error_message, - started_at, - completed_at, - created_at, - updated_at -) VALUES ( - ?, - ?, - ?, - ?, - NULL, - NULL, - NULL, - 'pending', - 'docker', - NULL, - NULL, - NULL, - ?, - NULL -) -` - -type InsertBuildParams struct { - ID string `db:"id"` - WorkspaceID string `db:"workspace_id"` - ProjectID string `db:"project_id"` - DeploymentID string `db:"deployment_id"` - CreatedAt int64 `db:"created_at"` -} - -// InsertBuild -// -// INSERT INTO builds ( -// id, -// workspace_id, -// project_id, -// deployment_id, -// rootfs_image_id, -// git_commit_sha, -// git_branch, -// status, -// build_tool, -// error_message, -// started_at, -// completed_at, -// created_at, -// updated_at -// ) VALUES ( -// ?, -// ?, -// ?, -// ?, -// NULL, -// NULL, -// NULL, -// 'pending', -// 'docker', -// NULL, -// NULL, -// NULL, -// ?, -// NULL -// ) -func (q *Queries) InsertBuild(ctx context.Context, db DBTX, arg InsertBuildParams) error { - _, err := db.ExecContext(ctx, insertBuild, - arg.ID, - arg.WorkspaceID, - arg.ProjectID, - arg.DeploymentID, - arg.CreatedAt, - ) - return err -} diff --git a/go/pkg/db/build_update_failed.sql_generated.go b/go/pkg/db/build_update_failed.sql_generated.go deleted file mode 100644 index 41a1adf3be..0000000000 --- a/go/pkg/db/build_update_failed.sql_generated.go +++ /dev/null @@ -1,44 +0,0 @@ -// Code generated by sqlc. DO NOT EDIT. -// versions: -// sqlc v1.28.0 -// source: build_update_failed.sql - -package db - -import ( - "context" - "database/sql" -) - -const updateBuildFailed = `-- name: UpdateBuildFailed :exec -UPDATE builds SET - status = 'failed', - completed_at = ?, - error_message = ?, - updated_at = ? -WHERE id = ? -` - -type UpdateBuildFailedParams struct { - Now sql.NullInt64 `db:"now"` - ErrorMessage sql.NullString `db:"error_message"` - ID string `db:"id"` -} - -// UpdateBuildFailed -// -// UPDATE builds SET -// status = 'failed', -// completed_at = ?, -// error_message = ?, -// updated_at = ? -// WHERE id = ? -func (q *Queries) UpdateBuildFailed(ctx context.Context, db DBTX, arg UpdateBuildFailedParams) error { - _, err := db.ExecContext(ctx, updateBuildFailed, - arg.Now, - arg.ErrorMessage, - arg.Now, - arg.ID, - ) - return err -} diff --git a/go/pkg/db/build_update_status.sql_generated.go b/go/pkg/db/build_update_status.sql_generated.go deleted file mode 100644 index 5d03cb0e4f..0000000000 --- a/go/pkg/db/build_update_status.sql_generated.go +++ /dev/null @@ -1,35 +0,0 @@ -// Code generated by sqlc. DO NOT EDIT. -// versions: -// sqlc v1.28.0 -// source: build_update_status.sql - -package db - -import ( - "context" - "database/sql" -) - -const updateBuildStatus = `-- name: UpdateBuildStatus :exec -UPDATE builds SET - status = ?, - updated_at = ? -WHERE id = ? -` - -type UpdateBuildStatusParams struct { - Status BuildsStatus `db:"status"` - Now sql.NullInt64 `db:"now"` - ID string `db:"id"` -} - -// UpdateBuildStatus -// -// UPDATE builds SET -// status = ?, -// updated_at = ? -// WHERE id = ? -func (q *Queries) UpdateBuildStatus(ctx context.Context, db DBTX, arg UpdateBuildStatusParams) error { - _, err := db.ExecContext(ctx, updateBuildStatus, arg.Status, arg.Now, arg.ID) - return err -} diff --git a/go/pkg/db/build_update_succeeded.sql_generated.go b/go/pkg/db/build_update_succeeded.sql_generated.go deleted file mode 100644 index 5df0d35bd8..0000000000 --- a/go/pkg/db/build_update_succeeded.sql_generated.go +++ /dev/null @@ -1,36 +0,0 @@ -// Code generated by sqlc. DO NOT EDIT. -// versions: -// sqlc v1.28.0 -// source: build_update_succeeded.sql - -package db - -import ( - "context" - "database/sql" -) - -const updateBuildSucceeded = `-- name: UpdateBuildSucceeded :exec -UPDATE builds SET - status = 'succeeded', - completed_at = ?, - updated_at = ? -WHERE id = ? -` - -type UpdateBuildSucceededParams struct { - Now sql.NullInt64 `db:"now"` - ID string `db:"id"` -} - -// UpdateBuildSucceeded -// -// UPDATE builds SET -// status = 'succeeded', -// completed_at = ?, -// updated_at = ? -// WHERE id = ? -func (q *Queries) UpdateBuildSucceeded(ctx context.Context, db DBTX, arg UpdateBuildSucceededParams) error { - _, err := db.ExecContext(ctx, updateBuildSucceeded, arg.Now, arg.Now, arg.ID) - return err -} diff --git a/go/pkg/db/bulk_domain_challenge_insert.sql.go b/go/pkg/db/bulk_acme_challenge_insert.sql.go similarity index 56% rename from go/pkg/db/bulk_domain_challenge_insert.sql.go rename to go/pkg/db/bulk_acme_challenge_insert.sql.go index 6ece1f8b46..3b4a3f100b 100644 --- a/go/pkg/db/bulk_domain_challenge_insert.sql.go +++ b/go/pkg/db/bulk_acme_challenge_insert.sql.go @@ -8,11 +8,11 @@ import ( "strings" ) -// bulkInsertDomainChallenge is the base query for bulk insert -const bulkInsertDomainChallenge = `INSERT INTO domain_challenges ( workspace_id, domain_id, token, authorization, status, created_at, updated_at, expires_at ) VALUES %s` +// bulkInsertAcmeChallenge is the base query for bulk insert +const bulkInsertAcmeChallenge = `INSERT INTO acme_challenges ( workspace_id, domain_id, token, authorization, status, type, created_at, updated_at, expires_at ) VALUES %s` -// InsertDomainChallenges performs bulk insert in a single query -func (q *BulkQueries) InsertDomainChallenges(ctx context.Context, db DBTX, args []InsertDomainChallengeParams) error { +// InsertAcmeChallenges performs bulk insert in a single query +func (q *BulkQueries) InsertAcmeChallenges(ctx context.Context, db DBTX, args []InsertAcmeChallengeParams) error { if len(args) == 0 { return nil @@ -21,10 +21,10 @@ func (q *BulkQueries) InsertDomainChallenges(ctx context.Context, db DBTX, args // Build the bulk insert query valueClauses := make([]string, len(args)) for i := range args { - valueClauses[i] = "( ?, ?, ?, ?, ?, ?, ?, ? )" + valueClauses[i] = "( ?, ?, ?, ?, ?, ?, ?, ?, ? )" } - bulkQuery := fmt.Sprintf(bulkInsertDomainChallenge, strings.Join(valueClauses, ", ")) + bulkQuery := fmt.Sprintf(bulkInsertAcmeChallenge, strings.Join(valueClauses, ", ")) // Collect all arguments var allArgs []any @@ -34,6 +34,7 @@ func (q *BulkQueries) InsertDomainChallenges(ctx context.Context, db DBTX, args allArgs = append(allArgs, arg.Token) allArgs = append(allArgs, arg.Authorization) allArgs = append(allArgs, arg.Status) + allArgs = append(allArgs, arg.Type) allArgs = append(allArgs, arg.CreatedAt) allArgs = append(allArgs, arg.UpdatedAt) allArgs = append(allArgs, arg.ExpiresAt) diff --git a/go/pkg/db/bulk_build_insert.sql.go b/go/pkg/db/bulk_build_insert.sql.go deleted file mode 100644 index b0fb0d52f3..0000000000 --- a/go/pkg/db/bulk_build_insert.sql.go +++ /dev/null @@ -1,42 +0,0 @@ -// Code generated by sqlc bulk insert plugin. DO NOT EDIT. - -package db - -import ( - "context" - "fmt" - "strings" -) - -// bulkInsertBuild is the base query for bulk insert -const bulkInsertBuild = `INSERT INTO builds ( id, workspace_id, project_id, deployment_id, rootfs_image_id, git_commit_sha, git_branch, status, build_tool, error_message, started_at, completed_at, created_at, updated_at ) VALUES %s` - -// InsertBuilds performs bulk insert in a single query -func (q *BulkQueries) InsertBuilds(ctx context.Context, db DBTX, args []InsertBuildParams) error { - - if len(args) == 0 { - return nil - } - - // Build the bulk insert query - valueClauses := make([]string, len(args)) - for i := range args { - valueClauses[i] = "( ?, ?, ?, ?, NULL, NULL, NULL, 'pending', 'docker', NULL, NULL, NULL, ?, NULL )" - } - - bulkQuery := fmt.Sprintf(bulkInsertBuild, strings.Join(valueClauses, ", ")) - - // Collect all arguments - var allArgs []any - for _, arg := range args { - allArgs = append(allArgs, arg.ID) - allArgs = append(allArgs, arg.WorkspaceID) - allArgs = append(allArgs, arg.ProjectID) - allArgs = append(allArgs, arg.DeploymentID) - allArgs = append(allArgs, arg.CreatedAt) - } - - // Execute the bulk insert - _, err := db.ExecContext(ctx, bulkQuery, allArgs...) - return err -} diff --git a/go/pkg/db/bulk_deployment_insert.sql.go b/go/pkg/db/bulk_deployment_insert.sql.go index 9fea9522c5..fb8b1f66fb 100644 --- a/go/pkg/db/bulk_deployment_insert.sql.go +++ b/go/pkg/db/bulk_deployment_insert.sql.go @@ -9,7 +9,7 @@ import ( ) // bulkInsertDeployment is the base query for bulk insert -const bulkInsertDeployment = `INSERT INTO ` + "`" + `deployments` + "`" + ` ( id, workspace_id, project_id, environment, build_id, rootfs_image_id, git_commit_sha, git_branch, git_commit_message, git_commit_author_name, git_commit_author_username, git_commit_author_avatar_url, git_commit_timestamp, config_snapshot, openapi_spec, status, created_at, updated_at ) VALUES %s` +const bulkInsertDeployment = `INSERT INTO ` + "`" + `deployments` + "`" + ` ( id, workspace_id, project_id, environment_id, git_commit_sha, git_branch, runtime_config, git_commit_message, git_commit_author_name, git_commit_author_username, git_commit_author_avatar_url, git_commit_timestamp, openapi_spec, status, created_at, updated_at ) VALUES %s` // InsertDeployments performs bulk insert in a single query func (q *BulkQueries) InsertDeployments(ctx context.Context, db DBTX, args []InsertDeploymentParams) error { @@ -21,7 +21,7 @@ func (q *BulkQueries) InsertDeployments(ctx context.Context, db DBTX, args []Ins // Build the bulk insert query valueClauses := make([]string, len(args)) for i := range args { - valueClauses[i] = "( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" + valueClauses[i] = "( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" } bulkQuery := fmt.Sprintf(bulkInsertDeployment, strings.Join(valueClauses, ", ")) @@ -32,17 +32,15 @@ func (q *BulkQueries) InsertDeployments(ctx context.Context, db DBTX, args []Ins allArgs = append(allArgs, arg.ID) allArgs = append(allArgs, arg.WorkspaceID) allArgs = append(allArgs, arg.ProjectID) - allArgs = append(allArgs, arg.Environment) - allArgs = append(allArgs, arg.BuildID) - allArgs = append(allArgs, arg.RootfsImageID) + allArgs = append(allArgs, arg.EnvironmentID) allArgs = append(allArgs, arg.GitCommitSha) allArgs = append(allArgs, arg.GitBranch) + allArgs = append(allArgs, arg.RuntimeConfig) allArgs = append(allArgs, arg.GitCommitMessage) allArgs = append(allArgs, arg.GitCommitAuthorName) allArgs = append(allArgs, arg.GitCommitAuthorUsername) allArgs = append(allArgs, arg.GitCommitAuthorAvatarUrl) allArgs = append(allArgs, arg.GitCommitTimestamp) - allArgs = append(allArgs, arg.ConfigSnapshot) allArgs = append(allArgs, arg.OpenapiSpec) allArgs = append(allArgs, arg.Status) allArgs = append(allArgs, arg.CreatedAt) diff --git a/go/pkg/db/bulk_deployment_step_insert.sql.go b/go/pkg/db/bulk_deployment_step_insert.sql.go index 241a543599..c1fee0f52b 100644 --- a/go/pkg/db/bulk_deployment_step_insert.sql.go +++ b/go/pkg/db/bulk_deployment_step_insert.sql.go @@ -9,9 +9,8 @@ import ( ) // bulkInsertDeploymentStep is the base query for bulk insert -const bulkInsertDeploymentStep = `INSERT INTO deployment_steps ( deployment_id, status, message, error_message, created_at ) VALUES %s ON DUPLICATE KEY UPDATE +const bulkInsertDeploymentStep = `INSERT INTO deployment_steps ( workspace_id, project_id, deployment_id, status, message, created_at ) VALUES %s ON DUPLICATE KEY UPDATE message = VALUES(message), - error_message = VALUES(error_message), created_at = VALUES(created_at)` // InsertDeploymentSteps performs bulk insert in a single query @@ -24,7 +23,7 @@ func (q *BulkQueries) InsertDeploymentSteps(ctx context.Context, db DBTX, args [ // Build the bulk insert query valueClauses := make([]string, len(args)) for i := range args { - valueClauses[i] = "( ?, ?, ?, ?, ? )" + valueClauses[i] = "( ?, ?, ?, ?, ?, ? )" } bulkQuery := fmt.Sprintf(bulkInsertDeploymentStep, strings.Join(valueClauses, ", ")) @@ -32,10 +31,11 @@ func (q *BulkQueries) InsertDeploymentSteps(ctx context.Context, db DBTX, args [ // Collect all arguments var allArgs []any for _, arg := range args { + allArgs = append(allArgs, arg.WorkspaceID) + allArgs = append(allArgs, arg.ProjectID) allArgs = append(allArgs, arg.DeploymentID) allArgs = append(allArgs, arg.Status) allArgs = append(allArgs, arg.Message) - allArgs = append(allArgs, arg.ErrorMessage) allArgs = append(allArgs, arg.CreatedAt) } diff --git a/go/pkg/db/bulk_domain_insert.sql.go b/go/pkg/db/bulk_domain_insert.sql.go index 3ad538c398..58ce04e9e5 100644 --- a/go/pkg/db/bulk_domain_insert.sql.go +++ b/go/pkg/db/bulk_domain_insert.sql.go @@ -9,11 +9,11 @@ import ( ) // bulkInsertDomain is the base query for bulk insert -const bulkInsertDomain = `INSERT INTO domains ( id, workspace_id, project_id, domain, type, subdomain_config, created_at ) VALUES %s ON DUPLICATE KEY UPDATE +const bulkInsertDomain = `INSERT INTO domains ( id, workspace_id, project_id, deployment_id, domain, type, created_at ) VALUES %s ON DUPLICATE KEY UPDATE workspace_id = VALUES(workspace_id), project_id = VALUES(project_id), + deployment_id = VALUES(deployment_id), type = VALUES(type), - subdomain_config = VALUES(subdomain_config), updated_at = ?` // InsertDomains performs bulk insert in a single query @@ -26,7 +26,7 @@ func (q *BulkQueries) InsertDomains(ctx context.Context, db DBTX, args []InsertD // Build the bulk insert query valueClauses := make([]string, len(args)) for i := range args { - valueClauses[i] = "( ?, ?, ?, ?, ?, CAST(? AS JSON), ? )" + valueClauses[i] = "( ?, ?, ?, ?, ?, ?, ? )" } bulkQuery := fmt.Sprintf(bulkInsertDomain, strings.Join(valueClauses, ", ")) @@ -37,9 +37,9 @@ func (q *BulkQueries) InsertDomains(ctx context.Context, db DBTX, args []InsertD allArgs = append(allArgs, arg.ID) allArgs = append(allArgs, arg.WorkspaceID) allArgs = append(allArgs, arg.ProjectID) + allArgs = append(allArgs, arg.DeploymentID) allArgs = append(allArgs, arg.Domain) allArgs = append(allArgs, arg.Type) - allArgs = append(allArgs, arg.SubdomainConfig) allArgs = append(allArgs, arg.CreatedAt) } diff --git a/go/pkg/db/bulk_project_insert.sql.go b/go/pkg/db/bulk_project_insert.sql.go index 28c4e8f5d1..01d8a3935c 100644 --- a/go/pkg/db/bulk_project_insert.sql.go +++ b/go/pkg/db/bulk_project_insert.sql.go @@ -9,7 +9,7 @@ import ( ) // bulkInsertProject is the base query for bulk insert -const bulkInsertProject = `INSERT INTO projects ( id, workspace_id, partition_id, name, slug, git_repository_url, default_branch, delete_protection, created_at, updated_at ) VALUES %s` +const bulkInsertProject = `INSERT INTO projects ( id, workspace_id, name, slug, git_repository_url, default_branch, delete_protection, created_at, updated_at ) VALUES %s` // InsertProjects performs bulk insert in a single query func (q *BulkQueries) InsertProjects(ctx context.Context, db DBTX, args []InsertProjectParams) error { @@ -21,7 +21,7 @@ func (q *BulkQueries) InsertProjects(ctx context.Context, db DBTX, args []Insert // Build the bulk insert query valueClauses := make([]string, len(args)) for i := range args { - valueClauses[i] = "( ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )" + valueClauses[i] = "( ?, ?, ?, ?, ?, ?, ?, ?, ? )" } bulkQuery := fmt.Sprintf(bulkInsertProject, strings.Join(valueClauses, ", ")) @@ -31,7 +31,6 @@ func (q *BulkQueries) InsertProjects(ctx context.Context, db DBTX, args []Insert for _, arg := range args { allArgs = append(allArgs, arg.ID) allArgs = append(allArgs, arg.WorkspaceID) - allArgs = append(allArgs, arg.PartitionID) allArgs = append(allArgs, arg.Name) allArgs = append(allArgs, arg.Slug) allArgs = append(allArgs, arg.GitRepositoryUrl) diff --git a/go/pkg/db/bulk_route_insert.sql.go b/go/pkg/db/bulk_route_insert.sql.go deleted file mode 100644 index bc51940ade..0000000000 --- a/go/pkg/db/bulk_route_insert.sql.go +++ /dev/null @@ -1,45 +0,0 @@ -// Code generated by sqlc bulk insert plugin. DO NOT EDIT. - -package db - -import ( - "context" - "fmt" - "strings" -) - -// bulkInsertHostnameRoute is the base query for bulk insert -const bulkInsertHostnameRoute = `INSERT INTO hostname_routes ( id, workspace_id, project_id, hostname, deployment_id, is_enabled, created_at, updated_at ) VALUES %s` - -// InsertHostnameRoutes performs bulk insert in a single query -func (q *BulkQueries) InsertHostnameRoutes(ctx context.Context, db DBTX, args []InsertHostnameRouteParams) error { - - if len(args) == 0 { - return nil - } - - // Build the bulk insert query - valueClauses := make([]string, len(args)) - for i := range args { - valueClauses[i] = "( ?, ?, ?, ?, ?, ?, ?, ? )" - } - - bulkQuery := fmt.Sprintf(bulkInsertHostnameRoute, strings.Join(valueClauses, ", ")) - - // Collect all arguments - var allArgs []any - for _, arg := range args { - allArgs = append(allArgs, arg.ID) - allArgs = append(allArgs, arg.WorkspaceID) - allArgs = append(allArgs, arg.ProjectID) - allArgs = append(allArgs, arg.Hostname) - allArgs = append(allArgs, arg.DeploymentID) - allArgs = append(allArgs, arg.IsEnabled) - allArgs = append(allArgs, arg.CreatedAt) - allArgs = append(allArgs, arg.UpdatedAt) - } - - // Execute the bulk insert - _, err := db.ExecContext(ctx, bulkQuery, allArgs...) - return err -} diff --git a/go/pkg/db/deployment_find_by_id.sql_generated.go b/go/pkg/db/deployment_find_by_id.sql_generated.go index 07930d37f0..c3f70b786f 100644 --- a/go/pkg/db/deployment_find_by_id.sql_generated.go +++ b/go/pkg/db/deployment_find_by_id.sql_generated.go @@ -1,30 +1,30 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: deployment_find_by_id.sql package db import ( "context" + "database/sql" + "encoding/json" ) const findDeploymentById = `-- name: FindDeploymentById :one -SELECT +SELECT id, workspace_id, project_id, - environment, - build_id, - rootfs_image_id, + environment_id, git_commit_sha, git_branch, + runtime_config, git_commit_message, git_commit_author_name, git_commit_author_username, git_commit_author_avatar_url, git_commit_timestamp, - config_snapshot, openapi_spec, status, created_at, @@ -33,47 +33,62 @@ FROM ` + "`" + `deployments` + "`" + ` WHERE id = ? ` +type FindDeploymentByIdRow struct { + ID string `db:"id"` + WorkspaceID string `db:"workspace_id"` + ProjectID string `db:"project_id"` + EnvironmentID string `db:"environment_id"` + GitCommitSha sql.NullString `db:"git_commit_sha"` + GitBranch sql.NullString `db:"git_branch"` + RuntimeConfig json.RawMessage `db:"runtime_config"` + GitCommitMessage sql.NullString `db:"git_commit_message"` + GitCommitAuthorName sql.NullString `db:"git_commit_author_name"` + GitCommitAuthorUsername sql.NullString `db:"git_commit_author_username"` + GitCommitAuthorAvatarUrl sql.NullString `db:"git_commit_author_avatar_url"` + GitCommitTimestamp sql.NullInt64 `db:"git_commit_timestamp"` + OpenapiSpec sql.NullString `db:"openapi_spec"` + Status DeploymentsStatus `db:"status"` + CreatedAt int64 `db:"created_at"` + UpdatedAt sql.NullInt64 `db:"updated_at"` +} + // FindDeploymentById // // SELECT // id, // workspace_id, // project_id, -// environment, -// build_id, -// rootfs_image_id, +// environment_id, // git_commit_sha, // git_branch, +// runtime_config, // git_commit_message, // git_commit_author_name, // git_commit_author_username, // git_commit_author_avatar_url, // git_commit_timestamp, -// config_snapshot, // openapi_spec, // status, // created_at, // updated_at // FROM `deployments` // WHERE id = ? -func (q *Queries) FindDeploymentById(ctx context.Context, db DBTX, id string) (Deployment, error) { +func (q *Queries) FindDeploymentById(ctx context.Context, db DBTX, id string) (FindDeploymentByIdRow, error) { row := db.QueryRowContext(ctx, findDeploymentById, id) - var i Deployment + var i FindDeploymentByIdRow err := row.Scan( &i.ID, &i.WorkspaceID, &i.ProjectID, - &i.Environment, - &i.BuildID, - &i.RootfsImageID, + &i.EnvironmentID, &i.GitCommitSha, &i.GitBranch, + &i.RuntimeConfig, &i.GitCommitMessage, &i.GitCommitAuthorName, &i.GitCommitAuthorUsername, &i.GitCommitAuthorAvatarUrl, &i.GitCommitTimestamp, - &i.ConfigSnapshot, &i.OpenapiSpec, &i.Status, &i.CreatedAt, diff --git a/go/pkg/db/deployment_insert.sql_generated.go b/go/pkg/db/deployment_insert.sql_generated.go index c72b3728a3..7fb05a9714 100644 --- a/go/pkg/db/deployment_insert.sql_generated.go +++ b/go/pkg/db/deployment_insert.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: deployment_insert.sql package db @@ -16,17 +16,15 @@ INSERT INTO ` + "`" + `deployments` + "`" + ` ( id, workspace_id, project_id, - environment, - build_id, - rootfs_image_id, + environment_id, git_commit_sha, git_branch, + runtime_config, git_commit_message, git_commit_author_name, git_commit_author_username, git_commit_author_avatar_url, git_commit_timestamp, -- Unix epoch milliseconds - config_snapshot, openapi_spec, status, created_at, @@ -48,31 +46,27 @@ VALUES ( ?, ?, ?, - ?, - ?, ? ) ` type InsertDeploymentParams struct { - ID string `db:"id"` - WorkspaceID string `db:"workspace_id"` - ProjectID string `db:"project_id"` - Environment DeploymentsEnvironment `db:"environment"` - BuildID sql.NullString `db:"build_id"` - RootfsImageID string `db:"rootfs_image_id"` - GitCommitSha sql.NullString `db:"git_commit_sha"` - GitBranch sql.NullString `db:"git_branch"` - GitCommitMessage sql.NullString `db:"git_commit_message"` - GitCommitAuthorName sql.NullString `db:"git_commit_author_name"` - GitCommitAuthorUsername sql.NullString `db:"git_commit_author_username"` - GitCommitAuthorAvatarUrl sql.NullString `db:"git_commit_author_avatar_url"` - GitCommitTimestamp sql.NullInt64 `db:"git_commit_timestamp"` - ConfigSnapshot json.RawMessage `db:"config_snapshot"` - OpenapiSpec sql.NullString `db:"openapi_spec"` - Status DeploymentsStatus `db:"status"` - CreatedAt int64 `db:"created_at"` - UpdatedAt sql.NullInt64 `db:"updated_at"` + ID string `db:"id"` + WorkspaceID string `db:"workspace_id"` + ProjectID string `db:"project_id"` + EnvironmentID string `db:"environment_id"` + GitCommitSha sql.NullString `db:"git_commit_sha"` + GitBranch sql.NullString `db:"git_branch"` + RuntimeConfig json.RawMessage `db:"runtime_config"` + GitCommitMessage sql.NullString `db:"git_commit_message"` + GitCommitAuthorName sql.NullString `db:"git_commit_author_name"` + GitCommitAuthorUsername sql.NullString `db:"git_commit_author_username"` + GitCommitAuthorAvatarUrl sql.NullString `db:"git_commit_author_avatar_url"` + GitCommitTimestamp sql.NullInt64 `db:"git_commit_timestamp"` + OpenapiSpec sql.NullString `db:"openapi_spec"` + Status DeploymentsStatus `db:"status"` + CreatedAt int64 `db:"created_at"` + UpdatedAt sql.NullInt64 `db:"updated_at"` } // InsertDeployment @@ -81,17 +75,15 @@ type InsertDeploymentParams struct { // id, // workspace_id, // project_id, -// environment, -// build_id, -// rootfs_image_id, +// environment_id, // git_commit_sha, // git_branch, +// runtime_config, // git_commit_message, // git_commit_author_name, // git_commit_author_username, // git_commit_author_avatar_url, // git_commit_timestamp, -- Unix epoch milliseconds -// config_snapshot, // openapi_spec, // status, // created_at, @@ -113,8 +105,6 @@ type InsertDeploymentParams struct { // ?, // ?, // ?, -// ?, -// ?, // ? // ) func (q *Queries) InsertDeployment(ctx context.Context, db DBTX, arg InsertDeploymentParams) error { @@ -122,17 +112,15 @@ func (q *Queries) InsertDeployment(ctx context.Context, db DBTX, arg InsertDeplo arg.ID, arg.WorkspaceID, arg.ProjectID, - arg.Environment, - arg.BuildID, - arg.RootfsImageID, + arg.EnvironmentID, arg.GitCommitSha, arg.GitBranch, + arg.RuntimeConfig, arg.GitCommitMessage, arg.GitCommitAuthorName, arg.GitCommitAuthorUsername, arg.GitCommitAuthorAvatarUrl, arg.GitCommitTimestamp, - arg.ConfigSnapshot, arg.OpenapiSpec, arg.Status, arg.CreatedAt, diff --git a/go/pkg/db/deployment_step_find_by_deployment_id.sql_generated.go b/go/pkg/db/deployment_step_find_by_deployment_id.sql_generated.go index 1fd734e4ed..bf5589309d 100644 --- a/go/pkg/db/deployment_step_find_by_deployment_id.sql_generated.go +++ b/go/pkg/db/deployment_step_find_by_deployment_id.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: deployment_step_find_by_deployment_id.sql package db @@ -10,42 +10,46 @@ import ( ) const findDeploymentStepsByDeploymentId = `-- name: FindDeploymentStepsByDeploymentId :many -SELECT +SELECT deployment_id, status, message, - error_message, created_at -FROM deployment_steps +FROM deployment_steps WHERE deployment_id = ? ORDER BY created_at ASC ` +type FindDeploymentStepsByDeploymentIdRow struct { + DeploymentID string `db:"deployment_id"` + Status DeploymentStepsStatus `db:"status"` + Message string `db:"message"` + CreatedAt int64 `db:"created_at"` +} + // FindDeploymentStepsByDeploymentId // // SELECT // deployment_id, // status, // message, -// error_message, // created_at // FROM deployment_steps // WHERE deployment_id = ? // ORDER BY created_at ASC -func (q *Queries) FindDeploymentStepsByDeploymentId(ctx context.Context, db DBTX, deploymentID string) ([]DeploymentStep, error) { +func (q *Queries) FindDeploymentStepsByDeploymentId(ctx context.Context, db DBTX, deploymentID string) ([]FindDeploymentStepsByDeploymentIdRow, error) { rows, err := db.QueryContext(ctx, findDeploymentStepsByDeploymentId, deploymentID) if err != nil { return nil, err } defer rows.Close() - var items []DeploymentStep + var items []FindDeploymentStepsByDeploymentIdRow for rows.Next() { - var i DeploymentStep + var i FindDeploymentStepsByDeploymentIdRow if err := rows.Scan( &i.DeploymentID, &i.Status, &i.Message, - &i.ErrorMessage, &i.CreatedAt, ); err != nil { return nil, err diff --git a/go/pkg/db/deployment_step_insert.sql_generated.go b/go/pkg/db/deployment_step_insert.sql_generated.go index 29aa4275f9..d49e67789a 100644 --- a/go/pkg/db/deployment_step_insert.sql_generated.go +++ b/go/pkg/db/deployment_step_insert.sql_generated.go @@ -1,60 +1,71 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: deployment_step_insert.sql package db import ( "context" - "database/sql" ) const insertDeploymentStep = `-- name: InsertDeploymentStep :exec INSERT INTO deployment_steps ( + workspace_id, + project_id, deployment_id, status, message, - error_message, created_at ) VALUES ( - ?, ?, ?, ?, ? + ?, + ?, + ?, + ?, + ?, + ? ) ON DUPLICATE KEY UPDATE message = VALUES(message), - error_message = VALUES(error_message), created_at = VALUES(created_at) ` type InsertDeploymentStepParams struct { + WorkspaceID string `db:"workspace_id"` + ProjectID string `db:"project_id"` DeploymentID string `db:"deployment_id"` Status DeploymentStepsStatus `db:"status"` - Message sql.NullString `db:"message"` - ErrorMessage sql.NullString `db:"error_message"` + Message string `db:"message"` CreatedAt int64 `db:"created_at"` } // InsertDeploymentStep // // INSERT INTO deployment_steps ( +// workspace_id, +// project_id, // deployment_id, // status, // message, -// error_message, // created_at // ) VALUES ( -// ?, ?, ?, ?, ? +// ?, +// ?, +// ?, +// ?, +// ?, +// ? // ) // ON DUPLICATE KEY UPDATE // message = VALUES(message), -// error_message = VALUES(error_message), // created_at = VALUES(created_at) func (q *Queries) InsertDeploymentStep(ctx context.Context, db DBTX, arg InsertDeploymentStepParams) error { _, err := db.ExecContext(ctx, insertDeploymentStep, + arg.WorkspaceID, + arg.ProjectID, arg.DeploymentID, arg.Status, arg.Message, - arg.ErrorMessage, arg.CreatedAt, ) return err diff --git a/go/pkg/db/deployment_update_openapi_spec.sql_generated.go b/go/pkg/db/deployment_update_openapi_spec.sql_generated.go index acea166c02..4cd71d47c3 100644 --- a/go/pkg/db/deployment_update_openapi_spec.sql_generated.go +++ b/go/pkg/db/deployment_update_openapi_spec.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: deployment_update_openapi_spec.sql package db diff --git a/go/pkg/db/deployment_update_status.sql_generated.go b/go/pkg/db/deployment_update_status.sql_generated.go index 814ed65aa9..75c40f8041 100644 --- a/go/pkg/db/deployment_update_status.sql_generated.go +++ b/go/pkg/db/deployment_update_status.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: deployment_update_status.sql package db diff --git a/go/pkg/db/domain_challenge_find_by_token.sql_generated.go b/go/pkg/db/domain_challenge_find_by_token.sql_generated.go deleted file mode 100644 index 507a93c320..0000000000 --- a/go/pkg/db/domain_challenge_find_by_token.sql_generated.go +++ /dev/null @@ -1,42 +0,0 @@ -// Code generated by sqlc. DO NOT EDIT. -// versions: -// sqlc v1.28.0 -// source: domain_challenge_find_by_token.sql - -package db - -import ( - "context" - "database/sql" -) - -const findDomainChallengeByToken = `-- name: FindDomainChallengeByToken :one -SELECT id, workspace_id, domain_id, token, authorization, status, type, created_at, updated_at, expires_at FROM domain_challenges WHERE workspace_id = ? AND domain_id = ? AND token = ? -` - -type FindDomainChallengeByTokenParams struct { - WorkspaceID string `db:"workspace_id"` - DomainID string `db:"domain_id"` - Token sql.NullString `db:"token"` -} - -// FindDomainChallengeByToken -// -// SELECT id, workspace_id, domain_id, token, authorization, status, type, created_at, updated_at, expires_at FROM domain_challenges WHERE workspace_id = ? AND domain_id = ? AND token = ? -func (q *Queries) FindDomainChallengeByToken(ctx context.Context, db DBTX, arg FindDomainChallengeByTokenParams) (DomainChallenge, error) { - row := db.QueryRowContext(ctx, findDomainChallengeByToken, arg.WorkspaceID, arg.DomainID, arg.Token) - var i DomainChallenge - err := row.Scan( - &i.ID, - &i.WorkspaceID, - &i.DomainID, - &i.Token, - &i.Authorization, - &i.Status, - &i.Type, - &i.CreatedAt, - &i.UpdatedAt, - &i.ExpiresAt, - ) - return i, err -} diff --git a/go/pkg/db/domain_challenge_insert.sql_generated.go b/go/pkg/db/domain_challenge_insert.sql_generated.go deleted file mode 100644 index 949fd54ed5..0000000000 --- a/go/pkg/db/domain_challenge_insert.sql_generated.go +++ /dev/null @@ -1,79 +0,0 @@ -// Code generated by sqlc. DO NOT EDIT. -// versions: -// sqlc v1.28.0 -// source: domain_challenge_insert.sql - -package db - -import ( - "context" - "database/sql" -) - -const insertDomainChallenge = `-- name: InsertDomainChallenge :exec -INSERT INTO domain_challenges ( - workspace_id, - domain_id, - token, - authorization, - status, - created_at, - updated_at, - expires_at -) VALUES ( - ?, - ?, - ?, - ?, - ?, - ?, - ?, - ? -) -` - -type InsertDomainChallengeParams struct { - WorkspaceID string `db:"workspace_id"` - DomainID string `db:"domain_id"` - Token sql.NullString `db:"token"` - Authorization sql.NullString `db:"authorization"` - Status DomainChallengesStatus `db:"status"` - CreatedAt int64 `db:"created_at"` - UpdatedAt sql.NullInt64 `db:"updated_at"` - ExpiresAt sql.NullInt64 `db:"expires_at"` -} - -// InsertDomainChallenge -// -// INSERT INTO domain_challenges ( -// workspace_id, -// domain_id, -// token, -// authorization, -// status, -// created_at, -// updated_at, -// expires_at -// ) VALUES ( -// ?, -// ?, -// ?, -// ?, -// ?, -// ?, -// ?, -// ? -// ) -func (q *Queries) InsertDomainChallenge(ctx context.Context, db DBTX, arg InsertDomainChallengeParams) error { - _, err := db.ExecContext(ctx, insertDomainChallenge, - arg.WorkspaceID, - arg.DomainID, - arg.Token, - arg.Authorization, - arg.Status, - arg.CreatedAt, - arg.UpdatedAt, - arg.ExpiresAt, - ) - return err -} diff --git a/go/pkg/db/domain_challenge_try_claiming.sql_generated.go b/go/pkg/db/domain_challenge_try_claiming.sql_generated.go deleted file mode 100644 index d4bd6459cd..0000000000 --- a/go/pkg/db/domain_challenge_try_claiming.sql_generated.go +++ /dev/null @@ -1,33 +0,0 @@ -// Code generated by sqlc. DO NOT EDIT. -// versions: -// sqlc v1.28.0 -// source: domain_challenge_try_claiming.sql - -package db - -import ( - "context" - "database/sql" -) - -const updateDomainChallengeTryClaiming = `-- name: UpdateDomainChallengeTryClaiming :exec -UPDATE domain_challenges -SET status = ?, updated_at = ? -WHERE domain_id = ? AND status = 'waiting' -` - -type UpdateDomainChallengeTryClaimingParams struct { - Status DomainChallengesStatus `db:"status"` - UpdatedAt sql.NullInt64 `db:"updated_at"` - DomainID string `db:"domain_id"` -} - -// UpdateDomainChallengeTryClaiming -// -// UPDATE domain_challenges -// SET status = ?, updated_at = ? -// WHERE domain_id = ? AND status = 'waiting' -func (q *Queries) UpdateDomainChallengeTryClaiming(ctx context.Context, db DBTX, arg UpdateDomainChallengeTryClaimingParams) error { - _, err := db.ExecContext(ctx, updateDomainChallengeTryClaiming, arg.Status, arg.UpdatedAt, arg.DomainID) - return err -} diff --git a/go/pkg/db/domain_challenge_update_expires_at.sql_generated.go b/go/pkg/db/domain_challenge_update_expires_at.sql_generated.go deleted file mode 100644 index a6c0639cc4..0000000000 --- a/go/pkg/db/domain_challenge_update_expires_at.sql_generated.go +++ /dev/null @@ -1,28 +0,0 @@ -// Code generated by sqlc. DO NOT EDIT. -// versions: -// sqlc v1.28.0 -// source: domain_challenge_update_expires_at.sql - -package db - -import ( - "context" - "database/sql" -) - -const updateDomainChallengeExpiresAt = `-- name: UpdateDomainChallengeExpiresAt :exec -UPDATE domain_challenges SET expires_at = ? WHERE domain_id = ? -` - -type UpdateDomainChallengeExpiresAtParams struct { - ExpiresAt sql.NullInt64 `db:"expires_at"` - DomainID string `db:"domain_id"` -} - -// UpdateDomainChallengeExpiresAt -// -// UPDATE domain_challenges SET expires_at = ? WHERE domain_id = ? -func (q *Queries) UpdateDomainChallengeExpiresAt(ctx context.Context, db DBTX, arg UpdateDomainChallengeExpiresAtParams) error { - _, err := db.ExecContext(ctx, updateDomainChallengeExpiresAt, arg.ExpiresAt, arg.DomainID) - return err -} diff --git a/go/pkg/db/domain_challenge_update_pending.sql_generated.go b/go/pkg/db/domain_challenge_update_pending.sql_generated.go deleted file mode 100644 index e9e1fbe179..0000000000 --- a/go/pkg/db/domain_challenge_update_pending.sql_generated.go +++ /dev/null @@ -1,41 +0,0 @@ -// Code generated by sqlc. DO NOT EDIT. -// versions: -// sqlc v1.28.0 -// source: domain_challenge_update_pending.sql - -package db - -import ( - "context" - "database/sql" -) - -const updateDomainChallengePending = `-- name: UpdateDomainChallengePending :exec -UPDATE domain_challenges -SET status = ?, token = ?, authorization = ?, updated_at = ? -WHERE domain_id = ? -` - -type UpdateDomainChallengePendingParams struct { - Status DomainChallengesStatus `db:"status"` - Token sql.NullString `db:"token"` - Authorization sql.NullString `db:"authorization"` - UpdatedAt sql.NullInt64 `db:"updated_at"` - DomainID string `db:"domain_id"` -} - -// UpdateDomainChallengePending -// -// UPDATE domain_challenges -// SET status = ?, token = ?, authorization = ?, updated_at = ? -// WHERE domain_id = ? -func (q *Queries) UpdateDomainChallengePending(ctx context.Context, db DBTX, arg UpdateDomainChallengePendingParams) error { - _, err := db.ExecContext(ctx, updateDomainChallengePending, - arg.Status, - arg.Token, - arg.Authorization, - arg.UpdatedAt, - arg.DomainID, - ) - return err -} diff --git a/go/pkg/db/domain_challenge_update_status.sql_generated.go b/go/pkg/db/domain_challenge_update_status.sql_generated.go deleted file mode 100644 index 2150082f70..0000000000 --- a/go/pkg/db/domain_challenge_update_status.sql_generated.go +++ /dev/null @@ -1,33 +0,0 @@ -// Code generated by sqlc. DO NOT EDIT. -// versions: -// sqlc v1.28.0 -// source: domain_challenge_update_status.sql - -package db - -import ( - "context" - "database/sql" -) - -const updateDomainChallengeStatus = `-- name: UpdateDomainChallengeStatus :exec -UPDATE domain_challenges -SET status = ?, updated_at = ? -WHERE domain_id = ? -` - -type UpdateDomainChallengeStatusParams struct { - Status DomainChallengesStatus `db:"status"` - UpdatedAt sql.NullInt64 `db:"updated_at"` - DomainID string `db:"domain_id"` -} - -// UpdateDomainChallengeStatus -// -// UPDATE domain_challenges -// SET status = ?, updated_at = ? -// WHERE domain_id = ? -func (q *Queries) UpdateDomainChallengeStatus(ctx context.Context, db DBTX, arg UpdateDomainChallengeStatusParams) error { - _, err := db.ExecContext(ctx, updateDomainChallengeStatus, arg.Status, arg.UpdatedAt, arg.DomainID) - return err -} diff --git a/go/pkg/db/domain_find_by_deployment_id.sql_generated.go b/go/pkg/db/domain_find_by_deployment_id.sql_generated.go new file mode 100644 index 0000000000..2a44a4e0d5 --- /dev/null +++ b/go/pkg/db/domain_find_by_deployment_id.sql_generated.go @@ -0,0 +1,79 @@ +// Code generated by sqlc. DO NOT EDIT. +// versions: +// sqlc v1.29.0 +// source: domain_find_by_deployment_id.sql + +package db + +import ( + "context" + "database/sql" +) + +const findDomainsByDeploymentId = `-- name: FindDomainsByDeploymentId :many +SELECT + id, + workspace_id, + project_id, + domain, + deployment_id, + created_at, + updated_at +FROM domains +WHERE deployment_id = ? +ORDER BY created_at ASC +` + +type FindDomainsByDeploymentIdRow struct { + ID string `db:"id"` + WorkspaceID string `db:"workspace_id"` + ProjectID sql.NullString `db:"project_id"` + Domain string `db:"domain"` + DeploymentID sql.NullString `db:"deployment_id"` + CreatedAt int64 `db:"created_at"` + UpdatedAt sql.NullInt64 `db:"updated_at"` +} + +// FindDomainsByDeploymentId +// +// SELECT +// id, +// workspace_id, +// project_id, +// domain, +// deployment_id, +// created_at, +// updated_at +// FROM domains +// WHERE deployment_id = ? +// ORDER BY created_at ASC +func (q *Queries) FindDomainsByDeploymentId(ctx context.Context, db DBTX, deploymentID sql.NullString) ([]FindDomainsByDeploymentIdRow, error) { + rows, err := db.QueryContext(ctx, findDomainsByDeploymentId, deploymentID) + if err != nil { + return nil, err + } + defer rows.Close() + var items []FindDomainsByDeploymentIdRow + for rows.Next() { + var i FindDomainsByDeploymentIdRow + if err := rows.Scan( + &i.ID, + &i.WorkspaceID, + &i.ProjectID, + &i.Domain, + &i.DeploymentID, + &i.CreatedAt, + &i.UpdatedAt, + ); err != nil { + return nil, err + } + items = append(items, i) + } + if err := rows.Close(); err != nil { + return nil, err + } + if err := rows.Err(); err != nil { + return nil, err + } + return items, nil +} diff --git a/go/pkg/db/domain_find_by_domain.sql_generated.go b/go/pkg/db/domain_find_by_domain.sql_generated.go index 8a70c959d2..0c15c3e993 100644 --- a/go/pkg/db/domain_find_by_domain.sql_generated.go +++ b/go/pkg/db/domain_find_by_domain.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: domain_find_by_domain.sql package db @@ -10,12 +10,12 @@ import ( ) const findDomainByDomain = `-- name: FindDomainByDomain :one -SELECT id, workspace_id, project_id, domain, type, subdomain_config, created_at, updated_at FROM domains WHERE domain = ? +SELECT id, workspace_id, project_id, deployment_id, domain, type, created_at, updated_at FROM domains WHERE domain = ? ` // FindDomainByDomain // -// SELECT id, workspace_id, project_id, domain, type, subdomain_config, created_at, updated_at FROM domains WHERE domain = ? +// SELECT id, workspace_id, project_id, deployment_id, domain, type, created_at, updated_at FROM domains WHERE domain = ? func (q *Queries) FindDomainByDomain(ctx context.Context, db DBTX, domain string) (Domain, error) { row := db.QueryRowContext(ctx, findDomainByDomain, domain) var i Domain @@ -23,9 +23,9 @@ func (q *Queries) FindDomainByDomain(ctx context.Context, db DBTX, domain string &i.ID, &i.WorkspaceID, &i.ProjectID, + &i.DeploymentID, &i.Domain, &i.Type, - &i.SubdomainConfig, &i.CreatedAt, &i.UpdatedAt, ) diff --git a/go/pkg/db/domain_insert.sql_generated.go b/go/pkg/db/domain_insert.sql_generated.go index b0873be642..7475f6fdba 100644 --- a/go/pkg/db/domain_insert.sql_generated.go +++ b/go/pkg/db/domain_insert.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: domain_insert.sql package db @@ -8,7 +8,6 @@ package db import ( "context" "database/sql" - "encoding/json" ) const insertDomain = `-- name: InsertDomain :exec @@ -16,9 +15,9 @@ INSERT INTO domains ( id, workspace_id, project_id, + deployment_id, domain, type, - subdomain_config, created_at ) VALUES ( ?, @@ -26,25 +25,25 @@ INSERT INTO domains ( ?, ?, ?, - CAST(? AS JSON), + ?, ? ) ON DUPLICATE KEY UPDATE workspace_id = VALUES(workspace_id), project_id = VALUES(project_id), + deployment_id = VALUES(deployment_id), type = VALUES(type), - subdomain_config = VALUES(subdomain_config), updated_at = ? ` type InsertDomainParams struct { - ID string `db:"id"` - WorkspaceID string `db:"workspace_id"` - ProjectID string `db:"project_id"` - Domain string `db:"domain"` - Type DomainsType `db:"type"` - SubdomainConfig json.RawMessage `db:"subdomain_config"` - CreatedAt int64 `db:"created_at"` - UpdatedAt sql.NullInt64 `db:"updated_at"` + ID string `db:"id"` + WorkspaceID string `db:"workspace_id"` + ProjectID sql.NullString `db:"project_id"` + DeploymentID sql.NullString `db:"deployment_id"` + Domain string `db:"domain"` + Type DomainsType `db:"type"` + CreatedAt int64 `db:"created_at"` + UpdatedAt sql.NullInt64 `db:"updated_at"` } // InsertDomain @@ -53,9 +52,9 @@ type InsertDomainParams struct { // id, // workspace_id, // project_id, +// deployment_id, // domain, // type, -// subdomain_config, // created_at // ) VALUES ( // ?, @@ -63,22 +62,22 @@ type InsertDomainParams struct { // ?, // ?, // ?, -// CAST(? AS JSON), +// ?, // ? // ) ON DUPLICATE KEY UPDATE // workspace_id = VALUES(workspace_id), // project_id = VALUES(project_id), +// deployment_id = VALUES(deployment_id), // type = VALUES(type), -// subdomain_config = VALUES(subdomain_config), // updated_at = ? func (q *Queries) InsertDomain(ctx context.Context, db DBTX, arg InsertDomainParams) error { _, err := db.ExecContext(ctx, insertDomain, arg.ID, arg.WorkspaceID, arg.ProjectID, + arg.DeploymentID, arg.Domain, arg.Type, - arg.SubdomainConfig, arg.CreatedAt, arg.UpdatedAt, ) diff --git a/go/pkg/db/identity_delete.sql_generated.go b/go/pkg/db/identity_delete.sql_generated.go index 1349ec9b5c..dc94acf645 100644 --- a/go/pkg/db/identity_delete.sql_generated.go +++ b/go/pkg/db/identity_delete.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: identity_delete.sql package db diff --git a/go/pkg/db/identity_delete_old_with_ratelimits.sql_generated.go b/go/pkg/db/identity_delete_old_with_ratelimits.sql_generated.go index 6ae8d82b86..344bde2a3c 100644 --- a/go/pkg/db/identity_delete_old_with_ratelimits.sql_generated.go +++ b/go/pkg/db/identity_delete_old_with_ratelimits.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: identity_delete_old_with_ratelimits.sql package db diff --git a/go/pkg/db/identity_find.sql_generated.go b/go/pkg/db/identity_find.sql_generated.go index b72be3c703..7bb2178827 100644 --- a/go/pkg/db/identity_find.sql_generated.go +++ b/go/pkg/db/identity_find.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: identity_find.sql package db diff --git a/go/pkg/db/identity_insert.sql_generated.go b/go/pkg/db/identity_insert.sql_generated.go index f9bd9cd4e5..52fe676740 100644 --- a/go/pkg/db/identity_insert.sql_generated.go +++ b/go/pkg/db/identity_insert.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: identity_insert.sql package db diff --git a/go/pkg/db/identity_insert_ratelimit.sql_generated.go b/go/pkg/db/identity_insert_ratelimit.sql_generated.go index 01022ac8dc..750c46dde4 100644 --- a/go/pkg/db/identity_insert_ratelimit.sql_generated.go +++ b/go/pkg/db/identity_insert_ratelimit.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: identity_insert_ratelimit.sql package db diff --git a/go/pkg/db/identity_list.sql_generated.go b/go/pkg/db/identity_list.sql_generated.go index 48bd1c4698..1e0643dd20 100644 --- a/go/pkg/db/identity_list.sql_generated.go +++ b/go/pkg/db/identity_list.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: identity_list.sql package db diff --git a/go/pkg/db/identity_list_ratelimits.sql_generated.go b/go/pkg/db/identity_list_ratelimits.sql_generated.go index befff535da..90fec5a143 100644 --- a/go/pkg/db/identity_list_ratelimits.sql_generated.go +++ b/go/pkg/db/identity_list_ratelimits.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: identity_list_ratelimits.sql package db diff --git a/go/pkg/db/identity_list_ratelimits_by_id.sql_generated.go b/go/pkg/db/identity_list_ratelimits_by_id.sql_generated.go index d81a099308..ef9b756978 100644 --- a/go/pkg/db/identity_list_ratelimits_by_id.sql_generated.go +++ b/go/pkg/db/identity_list_ratelimits_by_id.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: identity_list_ratelimits_by_id.sql package db diff --git a/go/pkg/db/identity_list_ratelimits_by_ids.sql_generated.go b/go/pkg/db/identity_list_ratelimits_by_ids.sql_generated.go index fc9041101c..f3af6a2462 100644 --- a/go/pkg/db/identity_list_ratelimits_by_ids.sql_generated.go +++ b/go/pkg/db/identity_list_ratelimits_by_ids.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: identity_list_ratelimits_by_ids.sql package db diff --git a/go/pkg/db/identity_soft_delete.sql_generated.go b/go/pkg/db/identity_soft_delete.sql_generated.go index 6405ff3fd1..d787628ad9 100644 --- a/go/pkg/db/identity_soft_delete.sql_generated.go +++ b/go/pkg/db/identity_soft_delete.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: identity_soft_delete.sql package db diff --git a/go/pkg/db/identity_update.sql_generated.go b/go/pkg/db/identity_update.sql_generated.go index be0d6635e5..3e9b6c0080 100644 --- a/go/pkg/db/identity_update.sql_generated.go +++ b/go/pkg/db/identity_update.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: identity_update.sql package db diff --git a/go/pkg/db/key_delete_by_id.sql_generated.go b/go/pkg/db/key_delete_by_id.sql_generated.go index 71482b3edc..4fd2a70558 100644 --- a/go/pkg/db/key_delete_by_id.sql_generated.go +++ b/go/pkg/db/key_delete_by_id.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: key_delete_by_id.sql package db diff --git a/go/pkg/db/key_encryption_find_by_key_id.sql_generated.go b/go/pkg/db/key_encryption_find_by_key_id.sql_generated.go index 2b8ae9d2b2..da71e6439f 100644 --- a/go/pkg/db/key_encryption_find_by_key_id.sql_generated.go +++ b/go/pkg/db/key_encryption_find_by_key_id.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: key_encryption_find_by_key_id.sql package db diff --git a/go/pkg/db/key_encryption_insert.sql_generated.go b/go/pkg/db/key_encryption_insert.sql_generated.go index 97ad53ba62..baf27495f2 100644 --- a/go/pkg/db/key_encryption_insert.sql_generated.go +++ b/go/pkg/db/key_encryption_insert.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: key_encryption_insert.sql package db diff --git a/go/pkg/db/key_find_by_id.sql_generated.go b/go/pkg/db/key_find_by_id.sql_generated.go index db833cd679..adc96c0a42 100644 --- a/go/pkg/db/key_find_by_id.sql_generated.go +++ b/go/pkg/db/key_find_by_id.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: key_find_by_id.sql package db diff --git a/go/pkg/db/key_find_credits.sql_generated.go b/go/pkg/db/key_find_credits.sql_generated.go index 9ff0922398..219a3e85f0 100644 --- a/go/pkg/db/key_find_credits.sql_generated.go +++ b/go/pkg/db/key_find_credits.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: key_find_credits.sql package db diff --git a/go/pkg/db/key_find_for_verification.sql_generated.go b/go/pkg/db/key_find_for_verification.sql_generated.go index ac52556e35..1093c89159 100644 --- a/go/pkg/db/key_find_for_verification.sql_generated.go +++ b/go/pkg/db/key_find_for_verification.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: key_find_for_verification.sql package db diff --git a/go/pkg/db/key_find_live_by_hash.sql_generated.go b/go/pkg/db/key_find_live_by_hash.sql_generated.go index ff835f6f8b..b61f372ec9 100644 --- a/go/pkg/db/key_find_live_by_hash.sql_generated.go +++ b/go/pkg/db/key_find_live_by_hash.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: key_find_live_by_hash.sql package db diff --git a/go/pkg/db/key_find_live_by_id.sql_generated.go b/go/pkg/db/key_find_live_by_id.sql_generated.go index 1b9e5c76b4..a92ee0435c 100644 --- a/go/pkg/db/key_find_live_by_id.sql_generated.go +++ b/go/pkg/db/key_find_live_by_id.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: key_find_live_by_id.sql package db diff --git a/go/pkg/db/key_insert.sql_generated.go b/go/pkg/db/key_insert.sql_generated.go index 05c450142e..e6ef9391d7 100644 --- a/go/pkg/db/key_insert.sql_generated.go +++ b/go/pkg/db/key_insert.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: key_insert.sql package db diff --git a/go/pkg/db/key_insert_ratelimit.sql_generated.go b/go/pkg/db/key_insert_ratelimit.sql_generated.go index 3eb49a8d6e..ec28a3a319 100644 --- a/go/pkg/db/key_insert_ratelimit.sql_generated.go +++ b/go/pkg/db/key_insert_ratelimit.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: key_insert_ratelimit.sql package db diff --git a/go/pkg/db/key_list_by_key_auth_id.sql_generated.go b/go/pkg/db/key_list_by_key_auth_id.sql_generated.go index 43fa4c4a37..87c1ef15cf 100644 --- a/go/pkg/db/key_list_by_key_auth_id.sql_generated.go +++ b/go/pkg/db/key_list_by_key_auth_id.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: key_list_by_key_auth_id.sql package db diff --git a/go/pkg/db/key_list_live_by_auth_id.sql_generated.go b/go/pkg/db/key_list_live_by_auth_id.sql_generated.go index 2c5a4a2add..29591be072 100644 --- a/go/pkg/db/key_list_live_by_auth_id.sql_generated.go +++ b/go/pkg/db/key_list_live_by_auth_id.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: key_list_live_by_auth_id.sql package db diff --git a/go/pkg/db/key_permission_delete_all_by_key_id.sql_generated.go b/go/pkg/db/key_permission_delete_all_by_key_id.sql_generated.go index 5b2e499511..a063b588a3 100644 --- a/go/pkg/db/key_permission_delete_all_by_key_id.sql_generated.go +++ b/go/pkg/db/key_permission_delete_all_by_key_id.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: key_permission_delete_all_by_key_id.sql package db diff --git a/go/pkg/db/key_permission_delete_by_key_and_permission_id.sql_generated.go b/go/pkg/db/key_permission_delete_by_key_and_permission_id.sql_generated.go index 0d85db744f..0d75184f8c 100644 --- a/go/pkg/db/key_permission_delete_by_key_and_permission_id.sql_generated.go +++ b/go/pkg/db/key_permission_delete_by_key_and_permission_id.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: key_permission_delete_by_key_and_permission_id.sql package db diff --git a/go/pkg/db/key_permission_delete_many_by_key_and_permission_ids.sql_generated.go b/go/pkg/db/key_permission_delete_many_by_key_and_permission_ids.sql_generated.go index dcc50ae728..820e5269ae 100644 --- a/go/pkg/db/key_permission_delete_many_by_key_and_permission_ids.sql_generated.go +++ b/go/pkg/db/key_permission_delete_many_by_key_and_permission_ids.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: key_permission_delete_many_by_key_and_permission_ids.sql package db diff --git a/go/pkg/db/key_permission_delete_many_by_permission_id.sql_generated.go b/go/pkg/db/key_permission_delete_many_by_permission_id.sql_generated.go index 36a8bf3ea2..1263bfb37a 100644 --- a/go/pkg/db/key_permission_delete_many_by_permission_id.sql_generated.go +++ b/go/pkg/db/key_permission_delete_many_by_permission_id.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: key_permission_delete_many_by_permission_id.sql package db diff --git a/go/pkg/db/key_permission_insert.sql_generated.go b/go/pkg/db/key_permission_insert.sql_generated.go index 84e41d1763..b7ab5b649e 100644 --- a/go/pkg/db/key_permission_insert.sql_generated.go +++ b/go/pkg/db/key_permission_insert.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: key_permission_insert.sql package db diff --git a/go/pkg/db/key_role_delete_all_by_key_id.sql_generated.go b/go/pkg/db/key_role_delete_all_by_key_id.sql_generated.go index 3292245293..3ab5da899d 100644 --- a/go/pkg/db/key_role_delete_all_by_key_id.sql_generated.go +++ b/go/pkg/db/key_role_delete_all_by_key_id.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: key_role_delete_all_by_key_id.sql package db diff --git a/go/pkg/db/key_role_delete_many_by_key_and_role_ids.sql_generated.go b/go/pkg/db/key_role_delete_many_by_key_and_role_ids.sql_generated.go index 1e8cfdacab..a2e89f2a04 100644 --- a/go/pkg/db/key_role_delete_many_by_key_and_role_ids.sql_generated.go +++ b/go/pkg/db/key_role_delete_many_by_key_and_role_ids.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: key_role_delete_many_by_key_and_role_ids.sql package db diff --git a/go/pkg/db/key_role_delete_many_by_key_id.sql_generated.go b/go/pkg/db/key_role_delete_many_by_key_id.sql_generated.go index 49b0bcd832..d57ef67216 100644 --- a/go/pkg/db/key_role_delete_many_by_key_id.sql_generated.go +++ b/go/pkg/db/key_role_delete_many_by_key_id.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: key_role_delete_many_by_key_id.sql package db diff --git a/go/pkg/db/key_role_delete_many_by_role_id.sql_generated.go b/go/pkg/db/key_role_delete_many_by_role_id.sql_generated.go index ddd0065c97..730caf662c 100644 --- a/go/pkg/db/key_role_delete_many_by_role_id.sql_generated.go +++ b/go/pkg/db/key_role_delete_many_by_role_id.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: key_role_delete_many_by_role_id.sql package db diff --git a/go/pkg/db/key_role_find_by_key_and_role_id.sql_generated.go b/go/pkg/db/key_role_find_by_key_and_role_id.sql_generated.go index 019d235e66..918707e98e 100644 --- a/go/pkg/db/key_role_find_by_key_and_role_id.sql_generated.go +++ b/go/pkg/db/key_role_find_by_key_and_role_id.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: key_role_find_by_key_and_role_id.sql package db diff --git a/go/pkg/db/key_role_insert.sql_generated.go b/go/pkg/db/key_role_insert.sql_generated.go index 2ef9819539..9aa689b257 100644 --- a/go/pkg/db/key_role_insert.sql_generated.go +++ b/go/pkg/db/key_role_insert.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: key_role_insert.sql package db diff --git a/go/pkg/db/key_soft_delete_by_id.sql_generated.go b/go/pkg/db/key_soft_delete_by_id.sql_generated.go index c9b1afb2f9..7efb73b5f3 100644 --- a/go/pkg/db/key_soft_delete_by_id.sql_generated.go +++ b/go/pkg/db/key_soft_delete_by_id.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: key_soft_delete_by_id.sql package db diff --git a/go/pkg/db/key_soft_delete_many_by_key_auth_id.sql_generated.go b/go/pkg/db/key_soft_delete_many_by_key_auth_id.sql_generated.go index 70074663bb..91f492315c 100644 --- a/go/pkg/db/key_soft_delete_many_by_key_auth_id.sql_generated.go +++ b/go/pkg/db/key_soft_delete_many_by_key_auth_id.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: key_soft_delete_many_by_key_auth_id.sql package db diff --git a/go/pkg/db/key_update.sql_generated.go b/go/pkg/db/key_update.sql_generated.go index f3bc6d23f6..65d3b82966 100644 --- a/go/pkg/db/key_update.sql_generated.go +++ b/go/pkg/db/key_update.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: key_update.sql package db diff --git a/go/pkg/db/key_update_credits_decrement.sql_generated.go b/go/pkg/db/key_update_credits_decrement.sql_generated.go index cea121984f..1217d267af 100644 --- a/go/pkg/db/key_update_credits_decrement.sql_generated.go +++ b/go/pkg/db/key_update_credits_decrement.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: key_update_credits_decrement.sql package db diff --git a/go/pkg/db/key_update_credits_increment.sql_generated.go b/go/pkg/db/key_update_credits_increment.sql_generated.go index a41dac6212..a91346bf46 100644 --- a/go/pkg/db/key_update_credits_increment.sql_generated.go +++ b/go/pkg/db/key_update_credits_increment.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: key_update_credits_increment.sql package db diff --git a/go/pkg/db/key_update_credits_refill.sql_generated.go b/go/pkg/db/key_update_credits_refill.sql_generated.go index ac5ca8fd1c..61ee609c1b 100644 --- a/go/pkg/db/key_update_credits_refill.sql_generated.go +++ b/go/pkg/db/key_update_credits_refill.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: key_update_credits_refill.sql package db diff --git a/go/pkg/db/key_update_credits_set.sql_generated.go b/go/pkg/db/key_update_credits_set.sql_generated.go index e0edab27de..624c3bb96c 100644 --- a/go/pkg/db/key_update_credits_set.sql_generated.go +++ b/go/pkg/db/key_update_credits_set.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: key_update_credits_set.sql package db diff --git a/go/pkg/db/keyring_find_by_id.sql_generated.go b/go/pkg/db/keyring_find_by_id.sql_generated.go index dccc11f4ec..aad8bfdb9b 100644 --- a/go/pkg/db/keyring_find_by_id.sql_generated.go +++ b/go/pkg/db/keyring_find_by_id.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: keyring_find_by_id.sql package db diff --git a/go/pkg/db/keyring_insert.sql_generated.go b/go/pkg/db/keyring_insert.sql_generated.go index a5b08b5af7..3c93b52b1d 100644 --- a/go/pkg/db/keyring_insert.sql_generated.go +++ b/go/pkg/db/keyring_insert.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: keyring_insert.sql package db diff --git a/go/pkg/db/keyring_update_key_encryption.sql_generated.go b/go/pkg/db/keyring_update_key_encryption.sql_generated.go index be3519ff3f..4565523112 100644 --- a/go/pkg/db/keyring_update_key_encryption.sql_generated.go +++ b/go/pkg/db/keyring_update_key_encryption.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: keyring_update_key_encryption.sql package db diff --git a/go/pkg/db/models_generated.go b/go/pkg/db/models_generated.go index 42bf56cadf..55ac4a90ae 100644 --- a/go/pkg/db/models_generated.go +++ b/go/pkg/db/models_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 package db @@ -13,134 +13,132 @@ import ( dbtype "github.com/unkeyed/unkey/go/pkg/db/types" ) -type ApisAuthType string +type AcmeChallengesStatus string const ( - ApisAuthTypeKey ApisAuthType = "key" - ApisAuthTypeJwt ApisAuthType = "jwt" + AcmeChallengesStatusWaiting AcmeChallengesStatus = "waiting" + AcmeChallengesStatusPending AcmeChallengesStatus = "pending" + AcmeChallengesStatusVerified AcmeChallengesStatus = "verified" + AcmeChallengesStatusFailed AcmeChallengesStatus = "failed" ) -func (e *ApisAuthType) Scan(src interface{}) error { +func (e *AcmeChallengesStatus) Scan(src interface{}) error { switch s := src.(type) { case []byte: - *e = ApisAuthType(s) + *e = AcmeChallengesStatus(s) case string: - *e = ApisAuthType(s) + *e = AcmeChallengesStatus(s) default: - return fmt.Errorf("unsupported scan type for ApisAuthType: %T", src) + return fmt.Errorf("unsupported scan type for AcmeChallengesStatus: %T", src) } return nil } -type NullApisAuthType struct { - ApisAuthType ApisAuthType - Valid bool // Valid is true if ApisAuthType is not NULL +type NullAcmeChallengesStatus struct { + AcmeChallengesStatus AcmeChallengesStatus + Valid bool // Valid is true if AcmeChallengesStatus is not NULL } // Scan implements the Scanner interface. -func (ns *NullApisAuthType) Scan(value interface{}) error { +func (ns *NullAcmeChallengesStatus) Scan(value interface{}) error { if value == nil { - ns.ApisAuthType, ns.Valid = "", false + ns.AcmeChallengesStatus, ns.Valid = "", false return nil } ns.Valid = true - return ns.ApisAuthType.Scan(value) + return ns.AcmeChallengesStatus.Scan(value) } // Value implements the driver Valuer interface. -func (ns NullApisAuthType) Value() (driver.Value, error) { +func (ns NullAcmeChallengesStatus) Value() (driver.Value, error) { if !ns.Valid { return nil, nil } - return string(ns.ApisAuthType), nil + return string(ns.AcmeChallengesStatus), nil } -type BuildsBuildTool string +type AcmeChallengesType string const ( - BuildsBuildToolDocker BuildsBuildTool = "docker" - BuildsBuildToolDepot BuildsBuildTool = "depot" - BuildsBuildToolCustom BuildsBuildTool = "custom" + AcmeChallengesTypeHTTP01 AcmeChallengesType = "HTTP-01" + AcmeChallengesTypeDNS01 AcmeChallengesType = "DNS-01" ) -func (e *BuildsBuildTool) Scan(src interface{}) error { +func (e *AcmeChallengesType) Scan(src interface{}) error { switch s := src.(type) { case []byte: - *e = BuildsBuildTool(s) + *e = AcmeChallengesType(s) case string: - *e = BuildsBuildTool(s) + *e = AcmeChallengesType(s) default: - return fmt.Errorf("unsupported scan type for BuildsBuildTool: %T", src) + return fmt.Errorf("unsupported scan type for AcmeChallengesType: %T", src) } return nil } -type NullBuildsBuildTool struct { - BuildsBuildTool BuildsBuildTool - Valid bool // Valid is true if BuildsBuildTool is not NULL +type NullAcmeChallengesType struct { + AcmeChallengesType AcmeChallengesType + Valid bool // Valid is true if AcmeChallengesType is not NULL } // Scan implements the Scanner interface. -func (ns *NullBuildsBuildTool) Scan(value interface{}) error { +func (ns *NullAcmeChallengesType) Scan(value interface{}) error { if value == nil { - ns.BuildsBuildTool, ns.Valid = "", false + ns.AcmeChallengesType, ns.Valid = "", false return nil } ns.Valid = true - return ns.BuildsBuildTool.Scan(value) + return ns.AcmeChallengesType.Scan(value) } // Value implements the driver Valuer interface. -func (ns NullBuildsBuildTool) Value() (driver.Value, error) { +func (ns NullAcmeChallengesType) Value() (driver.Value, error) { if !ns.Valid { return nil, nil } - return string(ns.BuildsBuildTool), nil + return string(ns.AcmeChallengesType), nil } -type BuildsStatus string +type ApisAuthType string const ( - BuildsStatusPending BuildsStatus = "pending" - BuildsStatusRunning BuildsStatus = "running" - BuildsStatusSucceeded BuildsStatus = "succeeded" - BuildsStatusFailed BuildsStatus = "failed" - BuildsStatusCancelled BuildsStatus = "cancelled" + ApisAuthTypeKey ApisAuthType = "key" + ApisAuthTypeJwt ApisAuthType = "jwt" ) -func (e *BuildsStatus) Scan(src interface{}) error { +func (e *ApisAuthType) Scan(src interface{}) error { switch s := src.(type) { case []byte: - *e = BuildsStatus(s) + *e = ApisAuthType(s) case string: - *e = BuildsStatus(s) + *e = ApisAuthType(s) default: - return fmt.Errorf("unsupported scan type for BuildsStatus: %T", src) + return fmt.Errorf("unsupported scan type for ApisAuthType: %T", src) } return nil } -type NullBuildsStatus struct { - BuildsStatus BuildsStatus - Valid bool // Valid is true if BuildsStatus is not NULL +type NullApisAuthType struct { + ApisAuthType ApisAuthType + Valid bool // Valid is true if ApisAuthType is not NULL } // Scan implements the Scanner interface. -func (ns *NullBuildsStatus) Scan(value interface{}) error { +func (ns *NullApisAuthType) Scan(value interface{}) error { if value == nil { - ns.BuildsStatus, ns.Valid = "", false + ns.ApisAuthType, ns.Valid = "", false return nil } ns.Valid = true - return ns.BuildsStatus.Scan(value) + return ns.ApisAuthType.Scan(value) } // Value implements the driver Valuer interface. -func (ns NullBuildsStatus) Value() (driver.Value, error) { +func (ns NullApisAuthType) Value() (driver.Value, error) { if !ns.Valid { return nil, nil } - return string(ns.BuildsStatus), nil + return string(ns.ApisAuthType), nil } type DeploymentStepsStatus string @@ -192,57 +190,15 @@ func (ns NullDeploymentStepsStatus) Value() (driver.Value, error) { return string(ns.DeploymentStepsStatus), nil } -type DeploymentsEnvironment string - -const ( - DeploymentsEnvironmentProduction DeploymentsEnvironment = "production" - DeploymentsEnvironmentPreview DeploymentsEnvironment = "preview" -) - -func (e *DeploymentsEnvironment) Scan(src interface{}) error { - switch s := src.(type) { - case []byte: - *e = DeploymentsEnvironment(s) - case string: - *e = DeploymentsEnvironment(s) - default: - return fmt.Errorf("unsupported scan type for DeploymentsEnvironment: %T", src) - } - return nil -} - -type NullDeploymentsEnvironment struct { - DeploymentsEnvironment DeploymentsEnvironment - Valid bool // Valid is true if DeploymentsEnvironment is not NULL -} - -// Scan implements the Scanner interface. -func (ns *NullDeploymentsEnvironment) Scan(value interface{}) error { - if value == nil { - ns.DeploymentsEnvironment, ns.Valid = "", false - return nil - } - ns.Valid = true - return ns.DeploymentsEnvironment.Scan(value) -} - -// Value implements the driver Valuer interface. -func (ns NullDeploymentsEnvironment) Value() (driver.Value, error) { - if !ns.Valid { - return nil, nil - } - return string(ns.DeploymentsEnvironment), nil -} - type DeploymentsStatus string const ( DeploymentsStatusPending DeploymentsStatus = "pending" DeploymentsStatusBuilding DeploymentsStatus = "building" DeploymentsStatusDeploying DeploymentsStatus = "deploying" - DeploymentsStatusActive DeploymentsStatus = "active" + DeploymentsStatusNetwork DeploymentsStatus = "network" + DeploymentsStatusReady DeploymentsStatus = "ready" DeploymentsStatusFailed DeploymentsStatus = "failed" - DeploymentsStatusArchived DeploymentsStatus = "archived" ) func (e *DeploymentsStatus) Scan(src interface{}) error { @@ -280,99 +236,11 @@ func (ns NullDeploymentsStatus) Value() (driver.Value, error) { return string(ns.DeploymentsStatus), nil } -type DomainChallengesStatus string - -const ( - DomainChallengesStatusWaiting DomainChallengesStatus = "waiting" - DomainChallengesStatusPending DomainChallengesStatus = "pending" - DomainChallengesStatusVerified DomainChallengesStatus = "verified" - DomainChallengesStatusFailed DomainChallengesStatus = "failed" - DomainChallengesStatusExpired DomainChallengesStatus = "expired" -) - -func (e *DomainChallengesStatus) Scan(src interface{}) error { - switch s := src.(type) { - case []byte: - *e = DomainChallengesStatus(s) - case string: - *e = DomainChallengesStatus(s) - default: - return fmt.Errorf("unsupported scan type for DomainChallengesStatus: %T", src) - } - return nil -} - -type NullDomainChallengesStatus struct { - DomainChallengesStatus DomainChallengesStatus - Valid bool // Valid is true if DomainChallengesStatus is not NULL -} - -// Scan implements the Scanner interface. -func (ns *NullDomainChallengesStatus) Scan(value interface{}) error { - if value == nil { - ns.DomainChallengesStatus, ns.Valid = "", false - return nil - } - ns.Valid = true - return ns.DomainChallengesStatus.Scan(value) -} - -// Value implements the driver Valuer interface. -func (ns NullDomainChallengesStatus) Value() (driver.Value, error) { - if !ns.Valid { - return nil, nil - } - return string(ns.DomainChallengesStatus), nil -} - -type DomainChallengesType string - -const ( - DomainChallengesTypeHttp01 DomainChallengesType = "http-01" - DomainChallengesTypeDns01 DomainChallengesType = "dns-01" - DomainChallengesTypeTlsAlpn01 DomainChallengesType = "tls-alpn-01" -) - -func (e *DomainChallengesType) Scan(src interface{}) error { - switch s := src.(type) { - case []byte: - *e = DomainChallengesType(s) - case string: - *e = DomainChallengesType(s) - default: - return fmt.Errorf("unsupported scan type for DomainChallengesType: %T", src) - } - return nil -} - -type NullDomainChallengesType struct { - DomainChallengesType DomainChallengesType - Valid bool // Valid is true if DomainChallengesType is not NULL -} - -// Scan implements the Scanner interface. -func (ns *NullDomainChallengesType) Scan(value interface{}) error { - if value == nil { - ns.DomainChallengesType, ns.Valid = "", false - return nil - } - ns.Valid = true - return ns.DomainChallengesType.Scan(value) -} - -// Value implements the driver Valuer interface. -func (ns NullDomainChallengesType) Value() (driver.Value, error) { - if !ns.Valid { - return nil, nil - } - return string(ns.DomainChallengesType), nil -} - type DomainsType string const ( - DomainsTypeCustom DomainsType = "custom" - DomainsTypeGenerated DomainsType = "generated" + DomainsTypeCustom DomainsType = "custom" + DomainsTypeWildcard DomainsType = "wildcard" ) func (e *DomainsType) Scan(src interface{}) error { @@ -410,49 +278,6 @@ func (ns NullDomainsType) Value() (driver.Value, error) { return string(ns.DomainsType), nil } -type PartitionsStatus string - -const ( - PartitionsStatusActive PartitionsStatus = "active" - PartitionsStatusDraining PartitionsStatus = "draining" - PartitionsStatusInactive PartitionsStatus = "inactive" -) - -func (e *PartitionsStatus) Scan(src interface{}) error { - switch s := src.(type) { - case []byte: - *e = PartitionsStatus(s) - case string: - *e = PartitionsStatus(s) - default: - return fmt.Errorf("unsupported scan type for PartitionsStatus: %T", src) - } - return nil -} - -type NullPartitionsStatus struct { - PartitionsStatus PartitionsStatus - Valid bool // Valid is true if PartitionsStatus is not NULL -} - -// Scan implements the Scanner interface. -func (ns *NullPartitionsStatus) Scan(value interface{}) error { - if value == nil { - ns.PartitionsStatus, ns.Valid = "", false - return nil - } - ns.Valid = true - return ns.PartitionsStatus.Scan(value) -} - -// Value implements the driver Valuer interface. -func (ns NullPartitionsStatus) Value() (driver.Value, error) { - if !ns.Valid { - return nil, nil - } - return string(ns.PartitionsStatus), nil -} - type RatelimitOverridesSharding string const ( @@ -622,6 +447,19 @@ func (ns NullWorkspacesPlan) Value() (driver.Value, error) { return string(ns.WorkspacesPlan), nil } +type AcmeChallenge struct { + ID uint64 `db:"id"` + WorkspaceID string `db:"workspace_id"` + DomainID string `db:"domain_id"` + Token string `db:"token"` + Type AcmeChallengesType `db:"type"` + Authorization string `db:"authorization"` + Status AcmeChallengesStatus `db:"status"` + ExpiresAt int64 `db:"expires_at"` + CreatedAt int64 `db:"created_at"` + UpdatedAt sql.NullInt64 `db:"updated_at"` +} + type AcmeUser struct { ID uint64 `db:"id"` WorkspaceID string `db:"workspace_id"` @@ -686,74 +524,44 @@ type AuditLogTarget struct { UpdatedAt sql.NullInt64 `db:"updated_at"` } -type Build struct { - ID string `db:"id"` - WorkspaceID string `db:"workspace_id"` - ProjectID string `db:"project_id"` - DeploymentID string `db:"deployment_id"` - RootfsImageID sql.NullString `db:"rootfs_image_id"` - GitCommitSha sql.NullString `db:"git_commit_sha"` - GitBranch sql.NullString `db:"git_branch"` - Status BuildsStatus `db:"status"` - BuildTool BuildsBuildTool `db:"build_tool"` - ErrorMessage sql.NullString `db:"error_message"` - StartedAt sql.NullInt64 `db:"started_at"` - CompletedAt sql.NullInt64 `db:"completed_at"` - CreatedAt int64 `db:"created_at"` - UpdatedAt sql.NullInt64 `db:"updated_at"` -} - type Deployment struct { - ID string `db:"id"` - WorkspaceID string `db:"workspace_id"` - ProjectID string `db:"project_id"` - Environment DeploymentsEnvironment `db:"environment"` - BuildID sql.NullString `db:"build_id"` - RootfsImageID string `db:"rootfs_image_id"` - GitCommitSha sql.NullString `db:"git_commit_sha"` - GitBranch sql.NullString `db:"git_branch"` - GitCommitMessage sql.NullString `db:"git_commit_message"` - GitCommitAuthorName sql.NullString `db:"git_commit_author_name"` - GitCommitAuthorUsername sql.NullString `db:"git_commit_author_username"` - GitCommitAuthorAvatarUrl sql.NullString `db:"git_commit_author_avatar_url"` - GitCommitTimestamp sql.NullInt64 `db:"git_commit_timestamp"` - ConfigSnapshot json.RawMessage `db:"config_snapshot"` - OpenapiSpec sql.NullString `db:"openapi_spec"` - Status DeploymentsStatus `db:"status"` - CreatedAt int64 `db:"created_at"` - UpdatedAt sql.NullInt64 `db:"updated_at"` + ID string `db:"id"` + WorkspaceID string `db:"workspace_id"` + ProjectID string `db:"project_id"` + EnvironmentID string `db:"environment_id"` + GitCommitSha sql.NullString `db:"git_commit_sha"` + GitBranch sql.NullString `db:"git_branch"` + GitCommitMessage sql.NullString `db:"git_commit_message"` + GitCommitAuthorName sql.NullString `db:"git_commit_author_name"` + GitCommitAuthorEmail sql.NullString `db:"git_commit_author_email"` + GitCommitAuthorUsername sql.NullString `db:"git_commit_author_username"` + GitCommitAuthorAvatarUrl sql.NullString `db:"git_commit_author_avatar_url"` + GitCommitTimestamp sql.NullInt64 `db:"git_commit_timestamp"` + RuntimeConfig json.RawMessage `db:"runtime_config"` + OpenapiSpec sql.NullString `db:"openapi_spec"` + Status DeploymentsStatus `db:"status"` + CreatedAt int64 `db:"created_at"` + UpdatedAt sql.NullInt64 `db:"updated_at"` } type DeploymentStep struct { DeploymentID string `db:"deployment_id"` + WorkspaceID string `db:"workspace_id"` + ProjectID string `db:"project_id"` Status DeploymentStepsStatus `db:"status"` - Message sql.NullString `db:"message"` - ErrorMessage sql.NullString `db:"error_message"` + Message string `db:"message"` CreatedAt int64 `db:"created_at"` } type Domain struct { - ID string `db:"id"` - WorkspaceID string `db:"workspace_id"` - ProjectID string `db:"project_id"` - Domain string `db:"domain"` - Type DomainsType `db:"type"` - SubdomainConfig []byte `db:"subdomain_config"` - CreatedAt int64 `db:"created_at"` - UpdatedAt sql.NullInt64 `db:"updated_at"` -} - -type DomainChallenge struct { - ID uint64 `db:"id"` - WorkspaceID string `db:"workspace_id"` - DomainID string `db:"domain_id"` - Token sql.NullString `db:"token"` - Authorization sql.NullString `db:"authorization"` - Status DomainChallengesStatus `db:"status"` - Type DomainChallengesType `db:"type"` - CreatedAt int64 `db:"created_at"` - UpdatedAt sql.NullInt64 `db:"updated_at"` - ExpiresAt sql.NullInt64 `db:"expires_at"` + ID string `db:"id"` + WorkspaceID string `db:"workspace_id"` + ProjectID sql.NullString `db:"project_id"` + DeploymentID sql.NullString `db:"deployment_id"` + Domain string `db:"domain"` + Type DomainsType `db:"type"` + CreatedAt int64 `db:"created_at"` + UpdatedAt sql.NullInt64 `db:"updated_at"` } type EncryptedKey struct { @@ -765,15 +573,15 @@ type EncryptedKey struct { EncryptionKeyID string `db:"encryption_key_id"` } -type HostnameRoute struct { - ID string `db:"id"` - WorkspaceID string `db:"workspace_id"` - ProjectID string `db:"project_id"` - Hostname string `db:"hostname"` - DeploymentID string `db:"deployment_id"` - IsEnabled bool `db:"is_enabled"` - CreatedAt int64 `db:"created_at"` - UpdatedAt sql.NullInt64 `db:"updated_at"` +type Environment struct { + ID string `db:"id"` + WorkspaceID string `db:"workspace_id"` + ProjectID string `db:"project_id"` + Slug string `db:"slug"` + Description sql.NullString `db:"description"` + DeleteProtection sql.NullBool `db:"delete_protection"` + CreatedAt int64 `db:"created_at"` + UpdatedAt sql.NullInt64 `db:"updated_at"` } type Identity struct { @@ -851,20 +659,6 @@ type KeysRole struct { UpdatedAtM sql.NullInt64 `db:"updated_at_m"` } -type Partition struct { - ID string `db:"id"` - Name string `db:"name"` - Description sql.NullString `db:"description"` - AwsAccountID string `db:"aws_account_id"` - Region string `db:"region"` - IpV4Address sql.NullString `db:"ip_v4_address"` - IpV6Address sql.NullString `db:"ip_v6_address"` - Status PartitionsStatus `db:"status"` - DeleteProtection sql.NullBool `db:"delete_protection"` - CreatedAt int64 `db:"created_at"` - UpdatedAt sql.NullInt64 `db:"updated_at"` -} - type Permission struct { ID string `db:"id"` WorkspaceID string `db:"workspace_id"` @@ -878,7 +672,6 @@ type Permission struct { type Project struct { ID string `db:"id"` WorkspaceID string `db:"workspace_id"` - PartitionID string `db:"partition_id"` Name string `db:"name"` Slug string `db:"slug"` GitRepositoryUrl sql.NullString `db:"git_repository_url"` @@ -949,17 +742,6 @@ type RolesPermission struct { UpdatedAtM sql.NullInt64 `db:"updated_at_m"` } -type RootfsImage struct { - ID string `db:"id"` - WorkspaceID string `db:"workspace_id"` - ProjectID string `db:"project_id"` - S3Bucket string `db:"s3_bucket"` - S3Key string `db:"s3_key"` - SizeBytes int64 `db:"size_bytes"` - CreatedAt int64 `db:"created_at"` - UpdatedAt sql.NullInt64 `db:"updated_at"` -} - type VercelBinding struct { ID string `db:"id"` IntegrationID string `db:"integration_id"` diff --git a/go/pkg/db/permission_delete_by_id.sql_generated.go b/go/pkg/db/permission_delete_by_id.sql_generated.go index bf10c82947..e9bd15332c 100644 --- a/go/pkg/db/permission_delete_by_id.sql_generated.go +++ b/go/pkg/db/permission_delete_by_id.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: permission_delete_by_id.sql package db diff --git a/go/pkg/db/permission_find_by_id.sql_generated.go b/go/pkg/db/permission_find_by_id.sql_generated.go index 69b13d36fd..0be6d98370 100644 --- a/go/pkg/db/permission_find_by_id.sql_generated.go +++ b/go/pkg/db/permission_find_by_id.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: permission_find_by_id.sql package db diff --git a/go/pkg/db/permission_find_by_id_or_slug.sql_generated.go b/go/pkg/db/permission_find_by_id_or_slug.sql_generated.go index 6f3cbe02cd..5dc02d81a1 100644 --- a/go/pkg/db/permission_find_by_id_or_slug.sql_generated.go +++ b/go/pkg/db/permission_find_by_id_or_slug.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: permission_find_by_id_or_slug.sql package db diff --git a/go/pkg/db/permission_find_by_name_and_workspace_id.sql_generated.go b/go/pkg/db/permission_find_by_name_and_workspace_id.sql_generated.go index 18b4463766..260d1dcaba 100644 --- a/go/pkg/db/permission_find_by_name_and_workspace_id.sql_generated.go +++ b/go/pkg/db/permission_find_by_name_and_workspace_id.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: permission_find_by_name_and_workspace_id.sql package db diff --git a/go/pkg/db/permission_find_by_slug_and_workspace_id.sql_generated.go b/go/pkg/db/permission_find_by_slug_and_workspace_id.sql_generated.go index 234f7e0195..9d9fc5fe56 100644 --- a/go/pkg/db/permission_find_by_slug_and_workspace_id.sql_generated.go +++ b/go/pkg/db/permission_find_by_slug_and_workspace_id.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: permission_find_by_slug_and_workspace_id.sql package db diff --git a/go/pkg/db/permission_find_by_slugs.sql_generated.go b/go/pkg/db/permission_find_by_slugs.sql_generated.go index b24c985b60..e07a83f0cf 100644 --- a/go/pkg/db/permission_find_by_slugs.sql_generated.go +++ b/go/pkg/db/permission_find_by_slugs.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: permission_find_by_slugs.sql package db diff --git a/go/pkg/db/permission_insert.sql_generated.go b/go/pkg/db/permission_insert.sql_generated.go index b496033551..3dede4bfce 100644 --- a/go/pkg/db/permission_insert.sql_generated.go +++ b/go/pkg/db/permission_insert.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: permission_insert.sql package db diff --git a/go/pkg/db/permission_list.sql_generated.go b/go/pkg/db/permission_list.sql_generated.go index 3b956a9ac3..b27e4cbc29 100644 --- a/go/pkg/db/permission_list.sql_generated.go +++ b/go/pkg/db/permission_list.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: permission_list.sql package db diff --git a/go/pkg/db/permission_list_by_key_id.sql_generated.go b/go/pkg/db/permission_list_by_key_id.sql_generated.go index 68d6ef055c..a19a5631d8 100644 --- a/go/pkg/db/permission_list_by_key_id.sql_generated.go +++ b/go/pkg/db/permission_list_by_key_id.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: permission_list_by_key_id.sql package db diff --git a/go/pkg/db/permission_list_by_role_id.sql_generated.go b/go/pkg/db/permission_list_by_role_id.sql_generated.go index c553dbba68..fe2e39ace7 100644 --- a/go/pkg/db/permission_list_by_role_id.sql_generated.go +++ b/go/pkg/db/permission_list_by_role_id.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: permission_list_by_role_id.sql package db diff --git a/go/pkg/db/permission_list_direct_by_key_id.sql_generated.go b/go/pkg/db/permission_list_direct_by_key_id.sql_generated.go index 90b7b028cd..e12d41d7b2 100644 --- a/go/pkg/db/permission_list_direct_by_key_id.sql_generated.go +++ b/go/pkg/db/permission_list_direct_by_key_id.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: permission_list_direct_by_key_id.sql package db diff --git a/go/pkg/db/project_find_by_id.sql_generated.go b/go/pkg/db/project_find_by_id.sql_generated.go index f3545a9316..0625a7b6ba 100644 --- a/go/pkg/db/project_find_by_id.sql_generated.go +++ b/go/pkg/db/project_find_by_id.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: project_find_by_id.sql package db @@ -10,10 +10,9 @@ import ( ) const findProjectById = `-- name: FindProjectById :one -SELECT +SELECT id, workspace_id, - partition_id, name, slug, git_repository_url, @@ -21,7 +20,7 @@ SELECT delete_protection, created_at, updated_at -FROM projects +FROM projects WHERE id = ? ` @@ -30,7 +29,6 @@ WHERE id = ? // SELECT // id, // workspace_id, -// partition_id, // name, // slug, // git_repository_url, @@ -46,7 +44,6 @@ func (q *Queries) FindProjectById(ctx context.Context, db DBTX, id string) (Proj err := row.Scan( &i.ID, &i.WorkspaceID, - &i.PartitionID, &i.Name, &i.Slug, &i.GitRepositoryUrl, diff --git a/go/pkg/db/project_find_by_workspace_slug.sql_generated.go b/go/pkg/db/project_find_by_workspace_slug.sql_generated.go index ba44a8e058..a5c729f133 100644 --- a/go/pkg/db/project_find_by_workspace_slug.sql_generated.go +++ b/go/pkg/db/project_find_by_workspace_slug.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: project_find_by_workspace_slug.sql package db @@ -10,10 +10,9 @@ import ( ) const findProjectByWorkspaceSlug = `-- name: FindProjectByWorkspaceSlug :one -SELECT +SELECT id, workspace_id, - partition_id, name, slug, git_repository_url, @@ -21,8 +20,9 @@ SELECT delete_protection, created_at, updated_at -FROM projects +FROM projects WHERE workspace_id = ? AND slug = ? +LIMIT 1 ` type FindProjectByWorkspaceSlugParams struct { @@ -35,7 +35,6 @@ type FindProjectByWorkspaceSlugParams struct { // SELECT // id, // workspace_id, -// partition_id, // name, // slug, // git_repository_url, @@ -45,13 +44,13 @@ type FindProjectByWorkspaceSlugParams struct { // updated_at // FROM projects // WHERE workspace_id = ? AND slug = ? +// LIMIT 1 func (q *Queries) FindProjectByWorkspaceSlug(ctx context.Context, db DBTX, arg FindProjectByWorkspaceSlugParams) (Project, error) { row := db.QueryRowContext(ctx, findProjectByWorkspaceSlug, arg.WorkspaceID, arg.Slug) var i Project err := row.Scan( &i.ID, &i.WorkspaceID, - &i.PartitionID, &i.Name, &i.Slug, &i.GitRepositoryUrl, diff --git a/go/pkg/db/project_insert.sql_generated.go b/go/pkg/db/project_insert.sql_generated.go index e177754d43..b542c2240e 100644 --- a/go/pkg/db/project_insert.sql_generated.go +++ b/go/pkg/db/project_insert.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: project_insert.sql package db @@ -14,7 +14,6 @@ const insertProject = `-- name: InsertProject :exec INSERT INTO projects ( id, workspace_id, - partition_id, name, slug, git_repository_url, @@ -23,14 +22,13 @@ INSERT INTO projects ( created_at, updated_at ) VALUES ( - ?, ?, ?, ?, ?, ?, ?, ?, ?, ? + ?, ?, ?, ?, ?, ?, ?, ?, ? ) ` type InsertProjectParams struct { ID string `db:"id"` WorkspaceID string `db:"workspace_id"` - PartitionID string `db:"partition_id"` Name string `db:"name"` Slug string `db:"slug"` GitRepositoryUrl sql.NullString `db:"git_repository_url"` @@ -45,7 +43,6 @@ type InsertProjectParams struct { // INSERT INTO projects ( // id, // workspace_id, -// partition_id, // name, // slug, // git_repository_url, @@ -54,13 +51,12 @@ type InsertProjectParams struct { // created_at, // updated_at // ) VALUES ( -// ?, ?, ?, ?, ?, ?, ?, ?, ?, ? +// ?, ?, ?, ?, ?, ?, ?, ?, ? // ) func (q *Queries) InsertProject(ctx context.Context, db DBTX, arg InsertProjectParams) error { _, err := db.ExecContext(ctx, insertProject, arg.ID, arg.WorkspaceID, - arg.PartitionID, arg.Name, arg.Slug, arg.GitRepositoryUrl, diff --git a/go/pkg/db/querier_bulk_generated.go b/go/pkg/db/querier_bulk_generated.go index 28cd96b195..5d6483117b 100644 --- a/go/pkg/db/querier_bulk_generated.go +++ b/go/pkg/db/querier_bulk_generated.go @@ -6,14 +6,13 @@ import "context" // BulkQuerier contains bulk insert methods. type BulkQuerier interface { + InsertAcmeChallenges(ctx context.Context, db DBTX, args []InsertAcmeChallengeParams) error InsertAcmeUsers(ctx context.Context, db DBTX, args []InsertAcmeUserParams) error InsertApis(ctx context.Context, db DBTX, args []InsertApiParams) error InsertAuditLogs(ctx context.Context, db DBTX, args []InsertAuditLogParams) error InsertAuditLogTargets(ctx context.Context, db DBTX, args []InsertAuditLogTargetParams) error - InsertBuilds(ctx context.Context, db DBTX, args []InsertBuildParams) error InsertDeployments(ctx context.Context, db DBTX, args []InsertDeploymentParams) error InsertDeploymentSteps(ctx context.Context, db DBTX, args []InsertDeploymentStepParams) error - InsertDomainChallenges(ctx context.Context, db DBTX, args []InsertDomainChallengeParams) error InsertDomains(ctx context.Context, db DBTX, args []InsertDomainParams) error InsertIdentities(ctx context.Context, db DBTX, args []InsertIdentityParams) error InsertIdentityRatelimits(ctx context.Context, db DBTX, args []InsertIdentityRatelimitParams) error @@ -29,7 +28,6 @@ type BulkQuerier interface { InsertRatelimitOverrides(ctx context.Context, db DBTX, args []InsertRatelimitOverrideParams) error InsertRoles(ctx context.Context, db DBTX, args []InsertRoleParams) error InsertRolePermissions(ctx context.Context, db DBTX, args []InsertRolePermissionParams) error - InsertHostnameRoutes(ctx context.Context, db DBTX, args []InsertHostnameRouteParams) error InsertWorkspaces(ctx context.Context, db DBTX, args []InsertWorkspaceParams) error } diff --git a/go/pkg/db/querier_generated.go b/go/pkg/db/querier_generated.go index 8c2276959a..7e986ed5df 100644 --- a/go/pkg/db/querier_generated.go +++ b/go/pkg/db/querier_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 package db @@ -113,6 +113,10 @@ type Querier interface { // DELETE FROM roles // WHERE id = ? DeleteRoleByID(ctx context.Context, db DBTX, roleID string) error + //FindAcmeChallengeByToken + // + // SELECT id, workspace_id, domain_id, token, type, authorization, status, expires_at, created_at, updated_at FROM acme_challenges WHERE workspace_id = ? AND domain_id = ? AND token = ? + FindAcmeChallengeByToken(ctx context.Context, db DBTX, arg FindAcmeChallengeByTokenParams) (AcmeChallenge, error) //FindAcmeUserByWorkspaceID // // SELECT id, workspace_id, encrypted_key, registration_uri, created_at, updated_at FROM acme_users WHERE workspace_id = ? LIMIT 1 @@ -128,85 +132,57 @@ type Querier interface { // JOIN audit_log ON audit_log.id = audit_log_target.audit_log_id // WHERE audit_log_target.id = ? FindAuditLogTargetByID(ctx context.Context, db DBTX, id string) ([]FindAuditLogTargetByIDRow, error) - //FindBuildById - // - // SELECT - // id, - // workspace_id, - // project_id, - // deployment_id, - // rootfs_image_id, - // git_commit_sha, - // git_branch, - // status, - // build_tool, - // error_message, - // started_at, - // completed_at, - // created_at, - // updated_at - // FROM `builds` - // WHERE id = ? - FindBuildById(ctx context.Context, db DBTX, id string) (Build, error) //FindDeploymentById // // SELECT // id, // workspace_id, // project_id, - // environment, - // build_id, - // rootfs_image_id, + // environment_id, // git_commit_sha, // git_branch, + // runtime_config, // git_commit_message, // git_commit_author_name, // git_commit_author_username, // git_commit_author_avatar_url, // git_commit_timestamp, - // config_snapshot, // openapi_spec, // status, // created_at, // updated_at // FROM `deployments` // WHERE id = ? - FindDeploymentById(ctx context.Context, db DBTX, id string) (Deployment, error) + FindDeploymentById(ctx context.Context, db DBTX, id string) (FindDeploymentByIdRow, error) //FindDeploymentStepsByDeploymentId // // SELECT // deployment_id, // status, // message, - // error_message, // created_at // FROM deployment_steps // WHERE deployment_id = ? // ORDER BY created_at ASC - FindDeploymentStepsByDeploymentId(ctx context.Context, db DBTX, deploymentID string) ([]DeploymentStep, error) + FindDeploymentStepsByDeploymentId(ctx context.Context, db DBTX, deploymentID string) ([]FindDeploymentStepsByDeploymentIdRow, error) //FindDomainByDomain // - // SELECT id, workspace_id, project_id, domain, type, subdomain_config, created_at, updated_at FROM domains WHERE domain = ? + // SELECT id, workspace_id, project_id, deployment_id, domain, type, created_at, updated_at FROM domains WHERE domain = ? FindDomainByDomain(ctx context.Context, db DBTX, domain string) (Domain, error) - //FindDomainChallengeByToken - // - // SELECT id, workspace_id, domain_id, token, authorization, status, type, created_at, updated_at, expires_at FROM domain_challenges WHERE workspace_id = ? AND domain_id = ? AND token = ? - FindDomainChallengeByToken(ctx context.Context, db DBTX, arg FindDomainChallengeByTokenParams) (DomainChallenge, error) - //FindHostnameRoutesByDeploymentId + //FindDomainsByDeploymentId // // SELECT // id, // workspace_id, // project_id, - // hostname, + // domain, // deployment_id, - // is_enabled, // created_at, // updated_at - // FROM hostname_routes - // WHERE deployment_id = ? AND is_enabled = true + // FROM domains + // WHERE deployment_id = ? // ORDER BY created_at ASC - FindHostnameRoutesByDeploymentId(ctx context.Context, db DBTX, deploymentID string) ([]HostnameRoute, error) + FindDomainsByDeploymentId(ctx context.Context, db DBTX, deploymentID sql.NullString) ([]FindDomainsByDeploymentIdRow, error) //FindIdentity // // SELECT id, external_id, workspace_id, environment, meta, deleted, created_at, updated_at @@ -318,28 +294,6 @@ type Querier interface { // // SELECT id, workspace_id, created_at_m, updated_at_m, deleted_at_m, store_encrypted_keys, default_prefix, default_bytes, size_approx, size_last_updated_at FROM `key_auth` WHERE id = ? FindKeyringByID(ctx context.Context, db DBTX, id string) (KeyAuth, error) - //FindLatestBuildByDeploymentId - // - // SELECT - // id, - // workspace_id, - // project_id, - // deployment_id, - // rootfs_image_id, - // git_commit_sha, - // git_branch, - // status, - // build_tool, - // error_message, - // started_at, - // completed_at, - // created_at, - // updated_at - // FROM `builds` - // WHERE deployment_id = ? - // ORDER BY created_at DESC - // LIMIT 1 - FindLatestBuildByDeploymentId(ctx context.Context, db DBTX, deploymentID string) (Build, error) //FindLiveApiByID // // SELECT apis.id, apis.name, apis.workspace_id, apis.ip_whitelist, apis.auth_type, apis.key_auth_id, apis.created_at_m, apis.updated_at_m, apis.deleted_at_m, apis.delete_protection, ka.id, ka.workspace_id, ka.created_at_m, ka.updated_at_m, ka.deleted_at_m, ka.store_encrypted_keys, ka.default_prefix, ka.default_bytes, ka.size_approx, ka.size_last_updated_at @@ -615,7 +569,6 @@ type Querier interface { // SELECT // id, // workspace_id, - // partition_id, // name, // slug, // git_repository_url, @@ -631,7 +584,6 @@ type Querier interface { // SELECT // id, // workspace_id, - // partition_id, // name, // slug, // git_repository_url, @@ -641,6 +593,7 @@ type Querier interface { // updated_at // FROM projects // WHERE workspace_id = ? AND slug = ? + // LIMIT 1 FindProjectByWorkspaceSlug(ctx context.Context, db DBTX, arg FindProjectByWorkspaceSlugParams) (Project, error) //FindRatelimitNamespace // @@ -749,6 +702,30 @@ type Querier interface { // WHERE id = ? // AND delete_protection = false HardDeleteWorkspace(ctx context.Context, db DBTX, id string) (sql.Result, error) + //InsertAcmeChallenge + // + // INSERT INTO acme_challenges ( + // workspace_id, + // domain_id, + // token, + // authorization, + // status, + // type, + // created_at, + // updated_at, + // expires_at + // ) VALUES ( + // ?, + // ?, + // ?, + // ?, + // ?, + // ?, + // ?, + // ?, + // ? + // ) + InsertAcmeChallenge(ctx context.Context, db DBTX, arg InsertAcmeChallengeParams) error //InsertAcmeUser // // @@ -837,57 +814,21 @@ type Querier interface { // ? // ) InsertAuditLogTarget(ctx context.Context, db DBTX, arg InsertAuditLogTargetParams) error - //InsertBuild - // - // INSERT INTO builds ( - // id, - // workspace_id, - // project_id, - // deployment_id, - // rootfs_image_id, - // git_commit_sha, - // git_branch, - // status, - // build_tool, - // error_message, - // started_at, - // completed_at, - // created_at, - // updated_at - // ) VALUES ( - // ?, - // ?, - // ?, - // ?, - // NULL, - // NULL, - // NULL, - // 'pending', - // 'docker', - // NULL, - // NULL, - // NULL, - // ?, - // NULL - // ) - InsertBuild(ctx context.Context, db DBTX, arg InsertBuildParams) error //InsertDeployment // // INSERT INTO `deployments` ( // id, // workspace_id, // project_id, - // environment, - // build_id, - // rootfs_image_id, + // environment_id, // git_commit_sha, // git_branch, + // runtime_config, // git_commit_message, // git_commit_author_name, // git_commit_author_username, // git_commit_author_avatar_url, // git_commit_timestamp, -- Unix epoch milliseconds - // config_snapshot, // openapi_spec, // status, // created_at, @@ -909,25 +850,28 @@ type Querier interface { // ?, // ?, // ?, - // ?, - // ?, // ? // ) InsertDeployment(ctx context.Context, db DBTX, arg InsertDeploymentParams) error //InsertDeploymentStep // // INSERT INTO deployment_steps ( + // workspace_id, + // project_id, // deployment_id, // status, // message, - // error_message, // created_at // ) VALUES ( - // ?, ?, ?, ?, ? + // ?, + // ?, + // ?, + // ?, + // ?, + // ? // ) // ON DUPLICATE KEY UPDATE // message = VALUES(message), - // error_message = VALUES(error_message), // created_at = VALUES(created_at) InsertDeploymentStep(ctx context.Context, db DBTX, arg InsertDeploymentStepParams) error //InsertDomain @@ -936,9 +880,9 @@ type Querier interface { // id, // workspace_id, // project_id, + // deployment_id, // domain, // type, - // subdomain_config, // created_at // ) VALUES ( // ?, @@ -946,52 +890,15 @@ type Querier interface { // ?, // ?, // ?, - // CAST(? AS JSON), + // ?, // ? // ) ON DUPLICATE KEY UPDATE // workspace_id = VALUES(workspace_id), // project_id = VALUES(project_id), + // deployment_id = VALUES(deployment_id), // type = VALUES(type), - // subdomain_config = VALUES(subdomain_config), // updated_at = ? InsertDomain(ctx context.Context, db DBTX, arg InsertDomainParams) error - //InsertDomainChallenge - // - // INSERT INTO domain_challenges ( - // workspace_id, - // domain_id, - // token, - // authorization, - // status, - // created_at, - // updated_at, - // expires_at - // ) VALUES ( - // ?, - // ?, - // ?, - // ?, - // ?, - // ?, - // ?, - // ? - // ) - InsertDomainChallenge(ctx context.Context, db DBTX, arg InsertDomainChallengeParams) error - //InsertHostnameRoute - // - // INSERT INTO hostname_routes ( - // id, - // workspace_id, - // project_id, - // hostname, - // deployment_id, - // is_enabled, - // created_at, - // updated_at - // ) VALUES ( - // ?, ?, ?, ?, ?, ?, ?, ? - // ) - InsertHostnameRoute(ctx context.Context, db DBTX, arg InsertHostnameRouteParams) error //InsertIdentity // // INSERT INTO `identities` ( @@ -1182,7 +1089,6 @@ type Querier interface { // INSERT INTO projects ( // id, // workspace_id, - // partition_id, // name, // slug, // git_repository_url, @@ -1191,7 +1097,7 @@ type Querier interface { // created_at, // updated_at // ) VALUES ( - // ?, ?, ?, ?, ?, ?, ?, ?, ?, ? + // ?, ?, ?, ?, ?, ?, ?, ?, ? // ) InsertProject(ctx context.Context, db DBTX, arg InsertProjectParams) error //InsertRatelimitNamespace @@ -1310,7 +1216,7 @@ type Querier interface { ListDirectPermissionsByKeyID(ctx context.Context, db DBTX, keyID string) ([]Permission, error) //ListExecutableChallenges // - // SELECT dc.id, dc.workspace_id, domain FROM domain_challenges dc + // SELECT dc.id, dc.workspace_id, d.domain FROM acme_challenges dc // JOIN domains d ON dc.domain_id = d.id // WHERE dc.status = 'waiting' OR (dc.status = 'verified' AND dc.expires_at <= DATE_ADD(NOW(), INTERVAL 30 DAY)) // ORDER BY d.created_at ASC @@ -1627,6 +1533,28 @@ type Querier interface { // WHERE id = ? // AND delete_protection = false SoftDeleteWorkspace(ctx context.Context, db DBTX, arg SoftDeleteWorkspaceParams) (sql.Result, error) + //UpdateAcmeChallengeExpiresAt + // + // UPDATE acme_challenges SET expires_at = ? WHERE id = ? + UpdateAcmeChallengeExpiresAt(ctx context.Context, db DBTX, arg UpdateAcmeChallengeExpiresAtParams) error + //UpdateAcmeChallengePending + // + // UPDATE acme_challenges + // SET status = ?, token = ?, authorization = ?, updated_at = ? + // WHERE domain_id = ? + UpdateAcmeChallengePending(ctx context.Context, db DBTX, arg UpdateAcmeChallengePendingParams) error + //UpdateAcmeChallengeStatus + // + // UPDATE acme_challenges + // SET status = ?, updated_at = ? + // WHERE domain_id = ? + UpdateAcmeChallengeStatus(ctx context.Context, db DBTX, arg UpdateAcmeChallengeStatusParams) error + //UpdateAcmeChallengeTryClaiming + // + // UPDATE acme_challenges + // SET status = ?, updated_at = ? + // WHERE domain_id = ? AND status = 'waiting' + UpdateAcmeChallengeTryClaiming(ctx context.Context, db DBTX, arg UpdateAcmeChallengeTryClaimingParams) error //UpdateAcmeUserRegistrationURI // // UPDATE acme_users SET registration_uri = ? WHERE id = ? @@ -1637,30 +1565,6 @@ type Querier interface { // SET delete_protection = ? // WHERE id = ? UpdateApiDeleteProtection(ctx context.Context, db DBTX, arg UpdateApiDeleteProtectionParams) error - //UpdateBuildFailed - // - // UPDATE builds SET - // status = 'failed', - // completed_at = ?, - // error_message = ?, - // updated_at = ? - // WHERE id = ? - UpdateBuildFailed(ctx context.Context, db DBTX, arg UpdateBuildFailedParams) error - //UpdateBuildStatus - // - // UPDATE builds SET - // status = ?, - // updated_at = ? - // WHERE id = ? - UpdateBuildStatus(ctx context.Context, db DBTX, arg UpdateBuildStatusParams) error - //UpdateBuildSucceeded - // - // UPDATE builds SET - // status = 'succeeded', - // completed_at = ?, - // updated_at = ? - // WHERE id = ? - UpdateBuildSucceeded(ctx context.Context, db DBTX, arg UpdateBuildSucceededParams) error //UpdateDeploymentOpenapiSpec // // UPDATE deployments @@ -1673,28 +1577,6 @@ type Querier interface { // SET status = ?, updated_at = ? // WHERE id = ? UpdateDeploymentStatus(ctx context.Context, db DBTX, arg UpdateDeploymentStatusParams) error - //UpdateDomainChallengeExpiresAt - // - // UPDATE domain_challenges SET expires_at = ? WHERE domain_id = ? - UpdateDomainChallengeExpiresAt(ctx context.Context, db DBTX, arg UpdateDomainChallengeExpiresAtParams) error - //UpdateDomainChallengePending - // - // UPDATE domain_challenges - // SET status = ?, token = ?, authorization = ?, updated_at = ? - // WHERE domain_id = ? - UpdateDomainChallengePending(ctx context.Context, db DBTX, arg UpdateDomainChallengePendingParams) error - //UpdateDomainChallengeStatus - // - // UPDATE domain_challenges - // SET status = ?, updated_at = ? - // WHERE domain_id = ? - UpdateDomainChallengeStatus(ctx context.Context, db DBTX, arg UpdateDomainChallengeStatusParams) error - //UpdateDomainChallengeTryClaiming - // - // UPDATE domain_challenges - // SET status = ?, updated_at = ? - // WHERE domain_id = ? AND status = 'waiting' - UpdateDomainChallengeTryClaiming(ctx context.Context, db DBTX, arg UpdateDomainChallengeTryClaimingParams) error //UpdateIdentity // // UPDATE `identities` diff --git a/go/pkg/db/queries/acme_challenge_find_by_token.sql b/go/pkg/db/queries/acme_challenge_find_by_token.sql new file mode 100644 index 0000000000..045077f52b --- /dev/null +++ b/go/pkg/db/queries/acme_challenge_find_by_token.sql @@ -0,0 +1,2 @@ +-- name: FindAcmeChallengeByToken :one +SELECT * FROM acme_challenges WHERE workspace_id = ? AND domain_id = ? AND token = ?; diff --git a/go/pkg/db/queries/domain_challenge_insert.sql b/go/pkg/db/queries/acme_challenge_insert.sql similarity index 69% rename from go/pkg/db/queries/domain_challenge_insert.sql rename to go/pkg/db/queries/acme_challenge_insert.sql index f5681e40b8..e215b95822 100644 --- a/go/pkg/db/queries/domain_challenge_insert.sql +++ b/go/pkg/db/queries/acme_challenge_insert.sql @@ -1,10 +1,11 @@ --- name: InsertDomainChallenge :exec -INSERT INTO domain_challenges ( +-- name: InsertAcmeChallenge :exec +INSERT INTO acme_challenges ( workspace_id, domain_id, token, authorization, status, + type, created_at, updated_at, expires_at @@ -16,5 +17,6 @@ INSERT INTO domain_challenges ( ?, ?, ?, + ?, ? ); diff --git a/go/pkg/db/queries/domain_challenge_list_executable.sql b/go/pkg/db/queries/acme_challenge_list_executable.sql similarity index 77% rename from go/pkg/db/queries/domain_challenge_list_executable.sql rename to go/pkg/db/queries/acme_challenge_list_executable.sql index 14b8b40610..07e8342c9a 100644 --- a/go/pkg/db/queries/domain_challenge_list_executable.sql +++ b/go/pkg/db/queries/acme_challenge_list_executable.sql @@ -1,5 +1,5 @@ -- name: ListExecutableChallenges :many -SELECT dc.id, dc.workspace_id, domain FROM domain_challenges dc +SELECT dc.id, dc.workspace_id, d.domain FROM acme_challenges dc JOIN domains d ON dc.domain_id = d.id WHERE dc.status = 'waiting' OR (dc.status = 'verified' AND dc.expires_at <= DATE_ADD(NOW(), INTERVAL 30 DAY)) ORDER BY d.created_at ASC; diff --git a/go/pkg/db/queries/domain_challenge_try_claiming.sql b/go/pkg/db/queries/acme_challenge_try_claiming.sql similarity index 50% rename from go/pkg/db/queries/domain_challenge_try_claiming.sql rename to go/pkg/db/queries/acme_challenge_try_claiming.sql index d2220f204c..c7c4ff2223 100644 --- a/go/pkg/db/queries/domain_challenge_try_claiming.sql +++ b/go/pkg/db/queries/acme_challenge_try_claiming.sql @@ -1,4 +1,4 @@ --- name: UpdateDomainChallengeTryClaiming :exec -UPDATE domain_challenges +-- name: UpdateAcmeChallengeTryClaiming :exec +UPDATE acme_challenges SET status = ?, updated_at = ? WHERE domain_id = ? AND status = 'waiting'; diff --git a/go/pkg/db/queries/acme_challenge_update_expires_at.sql b/go/pkg/db/queries/acme_challenge_update_expires_at.sql new file mode 100644 index 0000000000..0de8f2cc69 --- /dev/null +++ b/go/pkg/db/queries/acme_challenge_update_expires_at.sql @@ -0,0 +1,2 @@ +-- name: UpdateAcmeChallengeExpiresAt :exec +UPDATE acme_challenges SET expires_at = ? WHERE id = ?; diff --git a/go/pkg/db/queries/domain_challenge_update_pending.sql b/go/pkg/db/queries/acme_challenge_update_pending.sql similarity index 54% rename from go/pkg/db/queries/domain_challenge_update_pending.sql rename to go/pkg/db/queries/acme_challenge_update_pending.sql index 66228a75e5..2409433fe1 100644 --- a/go/pkg/db/queries/domain_challenge_update_pending.sql +++ b/go/pkg/db/queries/acme_challenge_update_pending.sql @@ -1,4 +1,4 @@ --- name: UpdateDomainChallengePending :exec -UPDATE domain_challenges +-- name: UpdateAcmeChallengePending :exec +UPDATE acme_challenges SET status = ?, token = ?, authorization = ?, updated_at = ? WHERE domain_id = ?; diff --git a/go/pkg/db/queries/acme_challenge_update_status.sql b/go/pkg/db/queries/acme_challenge_update_status.sql new file mode 100644 index 0000000000..cb5d5e5ad8 --- /dev/null +++ b/go/pkg/db/queries/acme_challenge_update_status.sql @@ -0,0 +1,4 @@ +-- name: UpdateAcmeChallengeStatus :exec +UPDATE acme_challenges +SET status = ?, updated_at = ? +WHERE domain_id = ?; diff --git a/go/pkg/db/queries/build_find_by_id.sql b/go/pkg/db/queries/build_find_by_id.sql deleted file mode 100644 index 27844c0b4c..0000000000 --- a/go/pkg/db/queries/build_find_by_id.sql +++ /dev/null @@ -1,18 +0,0 @@ --- name: FindBuildById :one -SELECT - id, - workspace_id, - project_id, - deployment_id, - rootfs_image_id, - git_commit_sha, - git_branch, - status, - build_tool, - error_message, - started_at, - completed_at, - created_at, - updated_at -FROM `builds` -WHERE id = sqlc.arg(id); \ No newline at end of file diff --git a/go/pkg/db/queries/build_find_latest_by_deployment_id.sql b/go/pkg/db/queries/build_find_latest_by_deployment_id.sql deleted file mode 100644 index 42ee1b34a5..0000000000 --- a/go/pkg/db/queries/build_find_latest_by_deployment_id.sql +++ /dev/null @@ -1,20 +0,0 @@ --- name: FindLatestBuildByDeploymentId :one -SELECT - id, - workspace_id, - project_id, - deployment_id, - rootfs_image_id, - git_commit_sha, - git_branch, - status, - build_tool, - error_message, - started_at, - completed_at, - created_at, - updated_at -FROM `builds` -WHERE deployment_id = sqlc.arg(deployment_id) -ORDER BY created_at DESC -LIMIT 1; \ No newline at end of file diff --git a/go/pkg/db/queries/build_insert.sql b/go/pkg/db/queries/build_insert.sql deleted file mode 100644 index 282628edf8..0000000000 --- a/go/pkg/db/queries/build_insert.sql +++ /dev/null @@ -1,32 +0,0 @@ --- name: InsertBuild :exec -INSERT INTO builds ( - id, - workspace_id, - project_id, - deployment_id, - rootfs_image_id, - git_commit_sha, - git_branch, - status, - build_tool, - error_message, - started_at, - completed_at, - created_at, - updated_at -) VALUES ( - sqlc.arg(id), - sqlc.arg(workspace_id), - sqlc.arg(project_id), - sqlc.arg(deployment_id), - NULL, - NULL, - NULL, - 'pending', - 'docker', - NULL, - NULL, - NULL, - sqlc.arg(created_at), - NULL -); diff --git a/go/pkg/db/queries/build_update_failed.sql b/go/pkg/db/queries/build_update_failed.sql deleted file mode 100644 index c0954e18fb..0000000000 --- a/go/pkg/db/queries/build_update_failed.sql +++ /dev/null @@ -1,7 +0,0 @@ --- name: UpdateBuildFailed :exec -UPDATE builds SET - status = 'failed', - completed_at = sqlc.arg(now), - error_message = sqlc.arg(error_message), - updated_at = sqlc.arg(now) -WHERE id = sqlc.arg(id); \ No newline at end of file diff --git a/go/pkg/db/queries/build_update_status.sql b/go/pkg/db/queries/build_update_status.sql deleted file mode 100644 index d87d4127ec..0000000000 --- a/go/pkg/db/queries/build_update_status.sql +++ /dev/null @@ -1,5 +0,0 @@ --- name: UpdateBuildStatus :exec -UPDATE builds SET - status = sqlc.arg(status), - updated_at = sqlc.arg(now) -WHERE id = sqlc.arg(id); diff --git a/go/pkg/db/queries/build_update_succeeded.sql b/go/pkg/db/queries/build_update_succeeded.sql deleted file mode 100644 index 145c15b8ba..0000000000 --- a/go/pkg/db/queries/build_update_succeeded.sql +++ /dev/null @@ -1,6 +0,0 @@ --- name: UpdateBuildSucceeded :exec -UPDATE builds SET - status = 'succeeded', - completed_at = sqlc.arg(now), - updated_at = sqlc.arg(now) -WHERE id = sqlc.arg(id); \ No newline at end of file diff --git a/go/pkg/db/queries/deployment_find_by_id.sql b/go/pkg/db/queries/deployment_find_by_id.sql index cf921a8073..b617fcd757 100644 --- a/go/pkg/db/queries/deployment_find_by_id.sql +++ b/go/pkg/db/queries/deployment_find_by_id.sql @@ -1,22 +1,20 @@ -- name: FindDeploymentById :one -SELECT +SELECT id, workspace_id, project_id, - environment, - build_id, - rootfs_image_id, + environment_id, git_commit_sha, git_branch, + runtime_config, git_commit_message, git_commit_author_name, git_commit_author_username, git_commit_author_avatar_url, git_commit_timestamp, - config_snapshot, openapi_spec, status, created_at, updated_at FROM `deployments` -WHERE id = sqlc.arg(id); \ No newline at end of file +WHERE id = sqlc.arg(id); diff --git a/go/pkg/db/queries/deployment_insert.sql b/go/pkg/db/queries/deployment_insert.sql index 1ee396b94e..7415304ad7 100644 --- a/go/pkg/db/queries/deployment_insert.sql +++ b/go/pkg/db/queries/deployment_insert.sql @@ -3,17 +3,15 @@ INSERT INTO `deployments` ( id, workspace_id, project_id, - environment, - build_id, - rootfs_image_id, + environment_id, git_commit_sha, git_branch, + runtime_config, git_commit_message, git_commit_author_name, git_commit_author_username, git_commit_author_avatar_url, git_commit_timestamp, -- Unix epoch milliseconds - config_snapshot, openapi_spec, status, created_at, @@ -23,19 +21,17 @@ VALUES ( sqlc.arg(id), sqlc.arg(workspace_id), sqlc.arg(project_id), - sqlc.arg(environment), - sqlc.arg(build_id), - sqlc.arg(rootfs_image_id), + sqlc.arg(environment_id), sqlc.arg(git_commit_sha), sqlc.arg(git_branch), + sqlc.arg(runtime_config), sqlc.arg(git_commit_message), sqlc.arg(git_commit_author_name), sqlc.arg(git_commit_author_username), sqlc.arg(git_commit_author_avatar_url), sqlc.arg(git_commit_timestamp), - sqlc.arg(config_snapshot), sqlc.arg(openapi_spec), sqlc.arg(status), sqlc.arg(created_at), sqlc.arg(updated_at) -); \ No newline at end of file +); diff --git a/go/pkg/db/queries/deployment_step_find_by_deployment_id.sql b/go/pkg/db/queries/deployment_step_find_by_deployment_id.sql index 4ed87e959e..a19540174f 100644 --- a/go/pkg/db/queries/deployment_step_find_by_deployment_id.sql +++ b/go/pkg/db/queries/deployment_step_find_by_deployment_id.sql @@ -1,10 +1,9 @@ -- name: FindDeploymentStepsByDeploymentId :many -SELECT +SELECT deployment_id, status, message, - error_message, created_at -FROM deployment_steps +FROM deployment_steps WHERE deployment_id = ? -ORDER BY created_at ASC; \ No newline at end of file +ORDER BY created_at ASC; diff --git a/go/pkg/db/queries/deployment_step_insert.sql b/go/pkg/db/queries/deployment_step_insert.sql index 926fc558e5..11f97f99e2 100644 --- a/go/pkg/db/queries/deployment_step_insert.sql +++ b/go/pkg/db/queries/deployment_step_insert.sql @@ -1,14 +1,19 @@ -- name: InsertDeploymentStep :exec INSERT INTO deployment_steps ( + workspace_id, + project_id, deployment_id, status, message, - error_message, created_at ) VALUES ( - ?, ?, ?, ?, ? + sqlc.arg(workspace_id), + sqlc.arg(project_id), + sqlc.arg(deployment_id), + sqlc.arg(status), + sqlc.arg(message), + sqlc.arg(created_at) ) ON DUPLICATE KEY UPDATE message = VALUES(message), - error_message = VALUES(error_message), - created_at = VALUES(created_at); \ No newline at end of file + created_at = VALUES(created_at); diff --git a/go/pkg/db/queries/domain_challenge_find_by_token.sql b/go/pkg/db/queries/domain_challenge_find_by_token.sql deleted file mode 100644 index 8c0448d4ad..0000000000 --- a/go/pkg/db/queries/domain_challenge_find_by_token.sql +++ /dev/null @@ -1,2 +0,0 @@ --- name: FindDomainChallengeByToken :one -SELECT * FROM domain_challenges WHERE workspace_id = ? AND domain_id = ? AND token = ?; diff --git a/go/pkg/db/queries/domain_challenge_update_expires_at.sql b/go/pkg/db/queries/domain_challenge_update_expires_at.sql deleted file mode 100644 index 6642e9cbc8..0000000000 --- a/go/pkg/db/queries/domain_challenge_update_expires_at.sql +++ /dev/null @@ -1,2 +0,0 @@ --- name: UpdateDomainChallengeExpiresAt :exec -UPDATE domain_challenges SET expires_at = ? WHERE domain_id = ?; diff --git a/go/pkg/db/queries/domain_challenge_update_status.sql b/go/pkg/db/queries/domain_challenge_update_status.sql deleted file mode 100644 index 140601ba18..0000000000 --- a/go/pkg/db/queries/domain_challenge_update_status.sql +++ /dev/null @@ -1,4 +0,0 @@ --- name: UpdateDomainChallengeStatus :exec -UPDATE domain_challenges -SET status = ?, updated_at = ? -WHERE domain_id = ?; diff --git a/go/pkg/db/queries/domain_find_by_deployment_id.sql b/go/pkg/db/queries/domain_find_by_deployment_id.sql new file mode 100644 index 0000000000..f7e3212429 --- /dev/null +++ b/go/pkg/db/queries/domain_find_by_deployment_id.sql @@ -0,0 +1,12 @@ +-- name: FindDomainsByDeploymentId :many +SELECT + id, + workspace_id, + project_id, + domain, + deployment_id, + created_at, + updated_at +FROM domains +WHERE deployment_id = ? +ORDER BY created_at ASC; diff --git a/go/pkg/db/queries/domain_insert.sql b/go/pkg/db/queries/domain_insert.sql index 5b3005c6a7..cefb9eb086 100644 --- a/go/pkg/db/queries/domain_insert.sql +++ b/go/pkg/db/queries/domain_insert.sql @@ -3,9 +3,9 @@ INSERT INTO domains ( id, workspace_id, project_id, + deployment_id, domain, type, - subdomain_config, created_at ) VALUES ( ?, @@ -13,11 +13,11 @@ INSERT INTO domains ( ?, ?, ?, - CAST(sqlc.arg(subdomain_config) AS JSON), + ?, ? ) ON DUPLICATE KEY UPDATE workspace_id = VALUES(workspace_id), project_id = VALUES(project_id), + deployment_id = VALUES(deployment_id), type = VALUES(type), - subdomain_config = VALUES(subdomain_config), updated_at = ?; diff --git a/go/pkg/db/queries/project_find_by_id.sql b/go/pkg/db/queries/project_find_by_id.sql index f17289f4fb..338afc911f 100644 --- a/go/pkg/db/queries/project_find_by_id.sql +++ b/go/pkg/db/queries/project_find_by_id.sql @@ -1,8 +1,7 @@ -- name: FindProjectById :one -SELECT +SELECT id, workspace_id, - partition_id, name, slug, git_repository_url, @@ -10,5 +9,5 @@ SELECT delete_protection, created_at, updated_at -FROM projects -WHERE id = ?; \ No newline at end of file +FROM projects +WHERE id = ?; diff --git a/go/pkg/db/queries/project_find_by_workspace_slug.sql b/go/pkg/db/queries/project_find_by_workspace_slug.sql index 780a8546c8..2924faa0d0 100644 --- a/go/pkg/db/queries/project_find_by_workspace_slug.sql +++ b/go/pkg/db/queries/project_find_by_workspace_slug.sql @@ -1,8 +1,7 @@ -- name: FindProjectByWorkspaceSlug :one -SELECT +SELECT id, workspace_id, - partition_id, name, slug, git_repository_url, @@ -10,5 +9,6 @@ SELECT delete_protection, created_at, updated_at -FROM projects -WHERE workspace_id = ? AND slug = ?; \ No newline at end of file +FROM projects +WHERE workspace_id = ? AND slug = ? +LIMIT 1; diff --git a/go/pkg/db/queries/project_insert.sql b/go/pkg/db/queries/project_insert.sql index 9b2aadf17b..2c01021c83 100644 --- a/go/pkg/db/queries/project_insert.sql +++ b/go/pkg/db/queries/project_insert.sql @@ -2,7 +2,6 @@ INSERT INTO projects ( id, workspace_id, - partition_id, name, slug, git_repository_url, @@ -11,5 +10,5 @@ INSERT INTO projects ( created_at, updated_at ) VALUES ( - ?, ?, ?, ?, ?, ?, ?, ?, ?, ? -); \ No newline at end of file + ?, ?, ?, ?, ?, ?, ?, ?, ? +); diff --git a/go/pkg/db/queries/route_find_by_deployment_id.sql b/go/pkg/db/queries/route_find_by_deployment_id.sql deleted file mode 100644 index edf12dea35..0000000000 --- a/go/pkg/db/queries/route_find_by_deployment_id.sql +++ /dev/null @@ -1,13 +0,0 @@ --- name: FindHostnameRoutesByDeploymentId :many -SELECT - id, - workspace_id, - project_id, - hostname, - deployment_id, - is_enabled, - created_at, - updated_at -FROM hostname_routes -WHERE deployment_id = ? AND is_enabled = true -ORDER BY created_at ASC; \ No newline at end of file diff --git a/go/pkg/db/queries/route_insert.sql b/go/pkg/db/queries/route_insert.sql deleted file mode 100644 index 23479cd5f3..0000000000 --- a/go/pkg/db/queries/route_insert.sql +++ /dev/null @@ -1,13 +0,0 @@ --- name: InsertHostnameRoute :exec -INSERT INTO hostname_routes ( - id, - workspace_id, - project_id, - hostname, - deployment_id, - is_enabled, - created_at, - updated_at -) VALUES ( - ?, ?, ?, ?, ?, ?, ?, ? -); \ No newline at end of file diff --git a/go/pkg/db/ratelimit_delete.sql_generated.go b/go/pkg/db/ratelimit_delete.sql_generated.go index 260bc582ad..c954d9d569 100644 --- a/go/pkg/db/ratelimit_delete.sql_generated.go +++ b/go/pkg/db/ratelimit_delete.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: ratelimit_delete.sql package db diff --git a/go/pkg/db/ratelimit_delete_many_by_identity_id.sql_generated.go b/go/pkg/db/ratelimit_delete_many_by_identity_id.sql_generated.go index fa3dd3c59d..d3d0ca4e68 100644 --- a/go/pkg/db/ratelimit_delete_many_by_identity_id.sql_generated.go +++ b/go/pkg/db/ratelimit_delete_many_by_identity_id.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: ratelimit_delete_many_by_identity_id.sql package db diff --git a/go/pkg/db/ratelimit_delete_many_by_ids.sql_generated.go b/go/pkg/db/ratelimit_delete_many_by_ids.sql_generated.go index e2f9db52d5..28f1669a89 100644 --- a/go/pkg/db/ratelimit_delete_many_by_ids.sql_generated.go +++ b/go/pkg/db/ratelimit_delete_many_by_ids.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: ratelimit_delete_many_by_ids.sql package db diff --git a/go/pkg/db/ratelimit_list_by_key_id.sql_generated.go b/go/pkg/db/ratelimit_list_by_key_id.sql_generated.go index 2eba8c871b..83716f187e 100644 --- a/go/pkg/db/ratelimit_list_by_key_id.sql_generated.go +++ b/go/pkg/db/ratelimit_list_by_key_id.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: ratelimit_list_by_key_id.sql package db diff --git a/go/pkg/db/ratelimit_list_by_key_ids.sql_generated.go b/go/pkg/db/ratelimit_list_by_key_ids.sql_generated.go index eb6df6c596..b8dde2d5a4 100644 --- a/go/pkg/db/ratelimit_list_by_key_ids.sql_generated.go +++ b/go/pkg/db/ratelimit_list_by_key_ids.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: ratelimit_list_by_key_ids.sql package db diff --git a/go/pkg/db/ratelimit_namespace_delete.sql_generated.go b/go/pkg/db/ratelimit_namespace_delete.sql_generated.go index 2d6bbfa3e6..29f6a71c7b 100644 --- a/go/pkg/db/ratelimit_namespace_delete.sql_generated.go +++ b/go/pkg/db/ratelimit_namespace_delete.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: ratelimit_namespace_delete.sql package db diff --git a/go/pkg/db/ratelimit_namespace_find.sql_generated.go b/go/pkg/db/ratelimit_namespace_find.sql_generated.go index cac3a0e56d..79161f2009 100644 --- a/go/pkg/db/ratelimit_namespace_find.sql_generated.go +++ b/go/pkg/db/ratelimit_namespace_find.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: ratelimit_namespace_find.sql package db diff --git a/go/pkg/db/ratelimit_namespace_find_by_id.sql_generated.go b/go/pkg/db/ratelimit_namespace_find_by_id.sql_generated.go index 860275d0be..472d8c135a 100644 --- a/go/pkg/db/ratelimit_namespace_find_by_id.sql_generated.go +++ b/go/pkg/db/ratelimit_namespace_find_by_id.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: ratelimit_namespace_find_by_id.sql package db diff --git a/go/pkg/db/ratelimit_namespace_find_by_name.sql_generated.go b/go/pkg/db/ratelimit_namespace_find_by_name.sql_generated.go index 5c2fe0ec54..41145cebc9 100644 --- a/go/pkg/db/ratelimit_namespace_find_by_name.sql_generated.go +++ b/go/pkg/db/ratelimit_namespace_find_by_name.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: ratelimit_namespace_find_by_name.sql package db diff --git a/go/pkg/db/ratelimit_namespace_insert.sql_generated.go b/go/pkg/db/ratelimit_namespace_insert.sql_generated.go index d727ae8207..415f029a4b 100644 --- a/go/pkg/db/ratelimit_namespace_insert.sql_generated.go +++ b/go/pkg/db/ratelimit_namespace_insert.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: ratelimit_namespace_insert.sql package db diff --git a/go/pkg/db/ratelimit_namespace_soft_delete.sql_generated.go b/go/pkg/db/ratelimit_namespace_soft_delete.sql_generated.go index 3df1948649..e64d786a15 100644 --- a/go/pkg/db/ratelimit_namespace_soft_delete.sql_generated.go +++ b/go/pkg/db/ratelimit_namespace_soft_delete.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: ratelimit_namespace_soft_delete.sql package db diff --git a/go/pkg/db/ratelimit_override_find_by_id.sql_generated.go b/go/pkg/db/ratelimit_override_find_by_id.sql_generated.go index 5be2e27909..616b8957e8 100644 --- a/go/pkg/db/ratelimit_override_find_by_id.sql_generated.go +++ b/go/pkg/db/ratelimit_override_find_by_id.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: ratelimit_override_find_by_id.sql package db diff --git a/go/pkg/db/ratelimit_override_find_by_identifier.sql_generated.go b/go/pkg/db/ratelimit_override_find_by_identifier.sql_generated.go index 014b19c875..6eaa89eaed 100644 --- a/go/pkg/db/ratelimit_override_find_by_identifier.sql_generated.go +++ b/go/pkg/db/ratelimit_override_find_by_identifier.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: ratelimit_override_find_by_identifier.sql package db diff --git a/go/pkg/db/ratelimit_override_insert.sql_generated.go b/go/pkg/db/ratelimit_override_insert.sql_generated.go index 7d9da02af5..00b8a8342e 100644 --- a/go/pkg/db/ratelimit_override_insert.sql_generated.go +++ b/go/pkg/db/ratelimit_override_insert.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: ratelimit_override_insert.sql package db diff --git a/go/pkg/db/ratelimit_override_list_by_namespace_id.sql_generated.go b/go/pkg/db/ratelimit_override_list_by_namespace_id.sql_generated.go index d9b99881ca..d1bc12214a 100644 --- a/go/pkg/db/ratelimit_override_list_by_namespace_id.sql_generated.go +++ b/go/pkg/db/ratelimit_override_list_by_namespace_id.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: ratelimit_override_list_by_namespace_id.sql package db diff --git a/go/pkg/db/ratelimit_override_soft_delete.sql_generated.go b/go/pkg/db/ratelimit_override_soft_delete.sql_generated.go index 9fd37ee07a..284da98085 100644 --- a/go/pkg/db/ratelimit_override_soft_delete.sql_generated.go +++ b/go/pkg/db/ratelimit_override_soft_delete.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: ratelimit_override_soft_delete.sql package db diff --git a/go/pkg/db/ratelimit_override_update.sql_generated.go b/go/pkg/db/ratelimit_override_update.sql_generated.go index f80b0777b1..f024a7b47f 100644 --- a/go/pkg/db/ratelimit_override_update.sql_generated.go +++ b/go/pkg/db/ratelimit_override_update.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: ratelimit_override_update.sql package db diff --git a/go/pkg/db/ratelimit_update.sql_generated.go b/go/pkg/db/ratelimit_update.sql_generated.go index 658316798a..96d66e90f2 100644 --- a/go/pkg/db/ratelimit_update.sql_generated.go +++ b/go/pkg/db/ratelimit_update.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: ratelimit_update.sql package db diff --git a/go/pkg/db/role_delete_by_id.sql_generated.go b/go/pkg/db/role_delete_by_id.sql_generated.go index d345ca07c6..e29e164ba4 100644 --- a/go/pkg/db/role_delete_by_id.sql_generated.go +++ b/go/pkg/db/role_delete_by_id.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: role_delete_by_id.sql package db diff --git a/go/pkg/db/role_find_by_id.sql_generated.go b/go/pkg/db/role_find_by_id.sql_generated.go index 9e6d11d639..8ecbdb9c5b 100644 --- a/go/pkg/db/role_find_by_id.sql_generated.go +++ b/go/pkg/db/role_find_by_id.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: role_find_by_id.sql package db diff --git a/go/pkg/db/role_find_by_id_or_name_with_perms.sql_generated.go b/go/pkg/db/role_find_by_id_or_name_with_perms.sql_generated.go index 0324f173f2..66701a2f88 100644 --- a/go/pkg/db/role_find_by_id_or_name_with_perms.sql_generated.go +++ b/go/pkg/db/role_find_by_id_or_name_with_perms.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: role_find_by_id_or_name_with_perms.sql package db diff --git a/go/pkg/db/role_find_by_name_and_workspace_id.sql_generated.go b/go/pkg/db/role_find_by_name_and_workspace_id.sql_generated.go index cd20bdb3fc..cbded345e5 100644 --- a/go/pkg/db/role_find_by_name_and_workspace_id.sql_generated.go +++ b/go/pkg/db/role_find_by_name_and_workspace_id.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: role_find_by_name_and_workspace_id.sql package db diff --git a/go/pkg/db/role_find_by_names.sql_generated.go b/go/pkg/db/role_find_by_names.sql_generated.go index d955cdbf76..b1450e467e 100644 --- a/go/pkg/db/role_find_by_names.sql_generated.go +++ b/go/pkg/db/role_find_by_names.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: role_find_by_names.sql package db diff --git a/go/pkg/db/role_find_many_by_id_or_name_with_perms.sql_generated.go b/go/pkg/db/role_find_many_by_id_or_name_with_perms.sql_generated.go index 498c696611..f7cfd1434e 100644 --- a/go/pkg/db/role_find_many_by_id_or_name_with_perms.sql_generated.go +++ b/go/pkg/db/role_find_many_by_id_or_name_with_perms.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: role_find_many_by_id_or_name_with_perms.sql package db diff --git a/go/pkg/db/role_find_many_by_name_with_perms.sql_generated.go b/go/pkg/db/role_find_many_by_name_with_perms.sql_generated.go index 805e006d9b..b3c694f0cc 100644 --- a/go/pkg/db/role_find_many_by_name_with_perms.sql_generated.go +++ b/go/pkg/db/role_find_many_by_name_with_perms.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: role_find_many_by_name_with_perms.sql package db diff --git a/go/pkg/db/role_insert.sql_generated.go b/go/pkg/db/role_insert.sql_generated.go index 3de28982ea..a77ff2a265 100644 --- a/go/pkg/db/role_insert.sql_generated.go +++ b/go/pkg/db/role_insert.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: role_insert.sql package db diff --git a/go/pkg/db/role_list.sql_generated.go b/go/pkg/db/role_list.sql_generated.go index c9b6b969a3..fa8454c43a 100644 --- a/go/pkg/db/role_list.sql_generated.go +++ b/go/pkg/db/role_list.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: role_list.sql package db diff --git a/go/pkg/db/role_list_by_key_id.sql_generated.go b/go/pkg/db/role_list_by_key_id.sql_generated.go index 51af8c1300..2949cf2e2a 100644 --- a/go/pkg/db/role_list_by_key_id.sql_generated.go +++ b/go/pkg/db/role_list_by_key_id.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: role_list_by_key_id.sql package db diff --git a/go/pkg/db/role_permission_delete_many_by_permission_id.sql_generated.go b/go/pkg/db/role_permission_delete_many_by_permission_id.sql_generated.go index 32a4b7e7ae..c49e9898da 100644 --- a/go/pkg/db/role_permission_delete_many_by_permission_id.sql_generated.go +++ b/go/pkg/db/role_permission_delete_many_by_permission_id.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: role_permission_delete_many_by_permission_id.sql package db diff --git a/go/pkg/db/role_permission_delete_many_by_role_id.sql_generated.go b/go/pkg/db/role_permission_delete_many_by_role_id.sql_generated.go index 10c155f650..045cc9aa5a 100644 --- a/go/pkg/db/role_permission_delete_many_by_role_id.sql_generated.go +++ b/go/pkg/db/role_permission_delete_many_by_role_id.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: role_permission_delete_many_by_role_id.sql package db diff --git a/go/pkg/db/role_permission_find_by_role_and_permission_id.sql_generated.go b/go/pkg/db/role_permission_find_by_role_and_permission_id.sql_generated.go index 2d6ea50b84..e2ac534db6 100644 --- a/go/pkg/db/role_permission_find_by_role_and_permission_id.sql_generated.go +++ b/go/pkg/db/role_permission_find_by_role_and_permission_id.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: role_permission_find_by_role_and_permission_id.sql package db diff --git a/go/pkg/db/role_permission_insert.sql_generated.go b/go/pkg/db/role_permission_insert.sql_generated.go index d385613e3a..22134fecb7 100644 --- a/go/pkg/db/role_permission_insert.sql_generated.go +++ b/go/pkg/db/role_permission_insert.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: role_permission_insert.sql package db diff --git a/go/pkg/db/route_find_by_deployment_id.sql_generated.go b/go/pkg/db/route_find_by_deployment_id.sql_generated.go deleted file mode 100644 index 27c81367c6..0000000000 --- a/go/pkg/db/route_find_by_deployment_id.sql_generated.go +++ /dev/null @@ -1,71 +0,0 @@ -// Code generated by sqlc. DO NOT EDIT. -// versions: -// sqlc v1.28.0 -// source: route_find_by_deployment_id.sql - -package db - -import ( - "context" -) - -const findHostnameRoutesByDeploymentId = `-- name: FindHostnameRoutesByDeploymentId :many -SELECT - id, - workspace_id, - project_id, - hostname, - deployment_id, - is_enabled, - created_at, - updated_at -FROM hostname_routes -WHERE deployment_id = ? AND is_enabled = true -ORDER BY created_at ASC -` - -// FindHostnameRoutesByDeploymentId -// -// SELECT -// id, -// workspace_id, -// project_id, -// hostname, -// deployment_id, -// is_enabled, -// created_at, -// updated_at -// FROM hostname_routes -// WHERE deployment_id = ? AND is_enabled = true -// ORDER BY created_at ASC -func (q *Queries) FindHostnameRoutesByDeploymentId(ctx context.Context, db DBTX, deploymentID string) ([]HostnameRoute, error) { - rows, err := db.QueryContext(ctx, findHostnameRoutesByDeploymentId, deploymentID) - if err != nil { - return nil, err - } - defer rows.Close() - var items []HostnameRoute - for rows.Next() { - var i HostnameRoute - if err := rows.Scan( - &i.ID, - &i.WorkspaceID, - &i.ProjectID, - &i.Hostname, - &i.DeploymentID, - &i.IsEnabled, - &i.CreatedAt, - &i.UpdatedAt, - ); err != nil { - return nil, err - } - items = append(items, i) - } - if err := rows.Close(); err != nil { - return nil, err - } - if err := rows.Err(); err != nil { - return nil, err - } - return items, nil -} diff --git a/go/pkg/db/route_insert.sql_generated.go b/go/pkg/db/route_insert.sql_generated.go deleted file mode 100644 index c2f2df32de..0000000000 --- a/go/pkg/db/route_insert.sql_generated.go +++ /dev/null @@ -1,65 +0,0 @@ -// Code generated by sqlc. DO NOT EDIT. -// versions: -// sqlc v1.28.0 -// source: route_insert.sql - -package db - -import ( - "context" - "database/sql" -) - -const insertHostnameRoute = `-- name: InsertHostnameRoute :exec -INSERT INTO hostname_routes ( - id, - workspace_id, - project_id, - hostname, - deployment_id, - is_enabled, - created_at, - updated_at -) VALUES ( - ?, ?, ?, ?, ?, ?, ?, ? -) -` - -type InsertHostnameRouteParams struct { - ID string `db:"id"` - WorkspaceID string `db:"workspace_id"` - ProjectID string `db:"project_id"` - Hostname string `db:"hostname"` - DeploymentID string `db:"deployment_id"` - IsEnabled bool `db:"is_enabled"` - CreatedAt int64 `db:"created_at"` - UpdatedAt sql.NullInt64 `db:"updated_at"` -} - -// InsertHostnameRoute -// -// INSERT INTO hostname_routes ( -// id, -// workspace_id, -// project_id, -// hostname, -// deployment_id, -// is_enabled, -// created_at, -// updated_at -// ) VALUES ( -// ?, ?, ?, ?, ?, ?, ?, ? -// ) -func (q *Queries) InsertHostnameRoute(ctx context.Context, db DBTX, arg InsertHostnameRouteParams) error { - _, err := db.ExecContext(ctx, insertHostnameRoute, - arg.ID, - arg.WorkspaceID, - arg.ProjectID, - arg.Hostname, - arg.DeploymentID, - arg.IsEnabled, - arg.CreatedAt, - arg.UpdatedAt, - ) - return err -} diff --git a/go/pkg/db/schema.sql b/go/pkg/db/schema.sql index 9ac0ece189..58ed0b5f26 100644 --- a/go/pkg/db/schema.sql +++ b/go/pkg/db/schema.sql @@ -289,25 +289,22 @@ CREATE TABLE `audit_log_target` ( CONSTRAINT `audit_log_target_audit_log_id_id_pk` PRIMARY KEY(`audit_log_id`,`id`) ); -CREATE TABLE `partitions` ( +CREATE TABLE `environments` ( `id` varchar(256) NOT NULL, - `name` varchar(256) NOT NULL, - `description` text, - `aws_account_id` varchar(256) NOT NULL, - `region` varchar(256) NOT NULL, - `ip_v4_address` varchar(15), - `ip_v6_address` varchar(39), - `status` enum('active','draining','inactive') NOT NULL DEFAULT 'active', + `workspace_id` varchar(256) NOT NULL, + `project_id` varchar(256) NOT NULL, + `slug` varchar(256) NOT NULL, + `description` varchar(255), `delete_protection` boolean DEFAULT false, `created_at` bigint NOT NULL, `updated_at` bigint, - CONSTRAINT `partitions_id` PRIMARY KEY(`id`) + CONSTRAINT `environments_id` PRIMARY KEY(`id`), + CONSTRAINT `environments_workspace_id_slug_idx` UNIQUE(`workspace_id`,`slug`) ); CREATE TABLE `projects` ( `id` varchar(256) NOT NULL, `workspace_id` varchar(256) NOT NULL, - `partition_id` varchar(256) NOT NULL, `name` varchar(256) NOT NULL, `slug` varchar(256) NOT NULL, `git_repository_url` varchar(500), @@ -319,67 +316,37 @@ CREATE TABLE `projects` ( CONSTRAINT `workspace_slug_idx` UNIQUE(`workspace_id`,`slug`) ); -CREATE TABLE `rootfs_images` ( - `id` varchar(256) NOT NULL, - `workspace_id` varchar(256) NOT NULL, - `project_id` varchar(256) NOT NULL, - `s3_bucket` varchar(256) NOT NULL, - `s3_key` varchar(500) NOT NULL, - `size_bytes` bigint NOT NULL, - `created_at` bigint NOT NULL, - `updated_at` bigint, - CONSTRAINT `rootfs_images_id` PRIMARY KEY(`id`) -); - -CREATE TABLE `builds` ( - `id` varchar(256) NOT NULL, - `workspace_id` varchar(256) NOT NULL, - `project_id` varchar(256) NOT NULL, - `deployment_id` varchar(256) NOT NULL, - `rootfs_image_id` varchar(256), - `git_commit_sha` varchar(40), - `git_branch` varchar(256), - `status` enum('pending','running','succeeded','failed','cancelled') NOT NULL DEFAULT 'pending', - `build_tool` enum('docker','depot','custom') NOT NULL DEFAULT 'docker', - `error_message` text, - `started_at` bigint, - `completed_at` bigint, - `created_at` bigint NOT NULL, - `updated_at` bigint, - CONSTRAINT `builds_id` PRIMARY KEY(`id`) -); - -CREATE TABLE `deployment_steps` ( - `deployment_id` varchar(256) NOT NULL, - `status` enum('pending','downloading_docker_image','building_rootfs','uploading_rootfs','creating_vm','booting_vm','assigning_domains','completed','failed') NOT NULL, - `message` text, - `error_message` text, - `created_at` bigint NOT NULL, - CONSTRAINT `deployment_steps_deployment_id_status_pk` PRIMARY KEY(`deployment_id`,`status`) -); - CREATE TABLE `deployments` ( `id` varchar(256) NOT NULL, `workspace_id` varchar(256) NOT NULL, `project_id` varchar(256) NOT NULL, - `environment` enum('production','preview') NOT NULL DEFAULT 'preview', - `build_id` varchar(256), - `rootfs_image_id` varchar(256) NOT NULL, + `environment_id` varchar(256) NOT NULL, `git_commit_sha` varchar(40), `git_branch` varchar(256), `git_commit_message` text, `git_commit_author_name` varchar(256), + `git_commit_author_email` varchar(256), `git_commit_author_username` varchar(256), `git_commit_author_avatar_url` varchar(512), - `git_commit_timestamp` bigint, -- Unix epoch milliseconds - `config_snapshot` json NOT NULL, + `git_commit_timestamp` bigint, + `runtime_config` json NOT NULL, `openapi_spec` text, - `status` enum('pending','building','deploying','active','failed','archived') NOT NULL DEFAULT 'pending', + `status` enum('pending','building','deploying','network','ready','failed') NOT NULL DEFAULT 'pending', `created_at` bigint NOT NULL, `updated_at` bigint, CONSTRAINT `deployments_id` PRIMARY KEY(`id`) ); +CREATE TABLE `deployment_steps` ( + `deployment_id` varchar(256) NOT NULL, + `workspace_id` varchar(256) NOT NULL, + `project_id` varchar(256) NOT NULL, + `status` enum('pending','downloading_docker_image','building_rootfs','uploading_rootfs','creating_vm','booting_vm','assigning_domains','completed','failed') NOT NULL, + `message` varchar(1024) NOT NULL, + `created_at` bigint NOT NULL, + CONSTRAINT `deployment_steps_deployment_id_status_pk` PRIMARY KEY(`deployment_id`,`status`) +); + CREATE TABLE `acme_users` ( `id` bigint unsigned AUTO_INCREMENT NOT NULL, `workspace_id` varchar(255) NOT NULL, @@ -390,45 +357,30 @@ CREATE TABLE `acme_users` ( CONSTRAINT `acme_users_id` PRIMARY KEY(`id`) ); -CREATE TABLE `hostname_routes` ( +CREATE TABLE `domains` ( `id` varchar(256) NOT NULL, `workspace_id` varchar(256) NOT NULL, - `project_id` varchar(256) NOT NULL, - `hostname` varchar(256) NOT NULL, - `deployment_id` varchar(256) NOT NULL, - `is_enabled` boolean NOT NULL DEFAULT true, + `project_id` varchar(256), + `deployment_id` varchar(256), + `domain` varchar(256) NOT NULL, + `type` enum('custom','wildcard') NOT NULL, `created_at` bigint NOT NULL, `updated_at` bigint, - CONSTRAINT `hostname_routes_id` PRIMARY KEY(`id`), - CONSTRAINT `hostname_idx` UNIQUE(`hostname`) + CONSTRAINT `domains_id` PRIMARY KEY(`id`) ); -CREATE TABLE `domain_challenges` ( +CREATE TABLE `acme_challenges` ( `id` bigint unsigned AUTO_INCREMENT NOT NULL, - `workspace_id` varchar(255) NOT NULL, - `domain_id` varchar(255) NOT NULL, - `token` varchar(255), - `authorization` varchar(255), - `status` enum('waiting','pending','verified','failed','expired') NOT NULL DEFAULT 'pending', - `type` enum('http-01','dns-01','tls-alpn-01') NOT NULL DEFAULT 'http-01', - `created_at` bigint NOT NULL, - `updated_at` bigint, - `expires_at` bigint unsigned, - CONSTRAINT `domain_challenges_id` PRIMARY KEY(`id`), - CONSTRAINT `domainIdWorkspaceId_idx` UNIQUE(`domain_id`,`workspace_id`) -); - -CREATE TABLE `domains` ( - `id` varchar(255) NOT NULL, - `workspace_id` varchar(255) NOT NULL, - `project_id` varchar(255) NOT NULL, - `domain` varchar(255) NOT NULL, - `type` enum('custom','generated') NOT NULL DEFAULT 'generated', - `subdomain_config` json, + `workspace_id` varchar(256) NOT NULL, + `domain_id` varchar(256) NOT NULL, + `token` varchar(256) NOT NULL, + `type` enum('HTTP-01','DNS-01') NOT NULL, + `authorization` varchar(256) NOT NULL, + `status` enum('waiting','pending','verified','failed') NOT NULL, + `expires_at` bigint NOT NULL, `created_at` bigint NOT NULL, `updated_at` bigint, - CONSTRAINT `domains_id` PRIMARY KEY(`id`), - CONSTRAINT `domain_idx` UNIQUE(`domain`) + CONSTRAINT `acme_challenges_id` PRIMARY KEY(`id`) ); CREATE INDEX `workspace_id_idx` ON `apis` (`workspace_id`); @@ -449,25 +401,11 @@ CREATE INDEX `time_idx` ON `audit_log` (`time`); CREATE INDEX `bucket` ON `audit_log_target` (`bucket`); CREATE INDEX `audit_log_id` ON `audit_log_target` (`audit_log_id`); CREATE INDEX `id_idx` ON `audit_log_target` (`id`); -CREATE INDEX `status_idx` ON `partitions` (`status`); CREATE INDEX `workspace_idx` ON `projects` (`workspace_id`); -CREATE INDEX `partition_idx` ON `projects` (`partition_id`); -CREATE INDEX `workspace_idx` ON `rootfs_images` (`workspace_id`); -CREATE INDEX `project_idx` ON `rootfs_images` (`project_id`); -CREATE INDEX `workspace_idx` ON `builds` (`workspace_id`); -CREATE INDEX `project_idx` ON `builds` (`project_id`); -CREATE INDEX `status_idx` ON `builds` (`status`); -CREATE INDEX `rootfs_image_idx` ON `builds` (`rootfs_image_id`); -CREATE INDEX `idx_deployment_id_created_at` ON `deployment_steps` (`deployment_id`,`created_at`); CREATE INDEX `workspace_idx` ON `deployments` (`workspace_id`); CREATE INDEX `project_idx` ON `deployments` (`project_id`); -CREATE INDEX `environment_idx` ON `deployments` (`environment`); CREATE INDEX `status_idx` ON `deployments` (`status`); -CREATE INDEX `rootfs_image_idx` ON `deployments` (`rootfs_image_id`); CREATE INDEX `domain_idx` ON `acme_users` (`workspace_id`); -CREATE INDEX `workspace_idx` ON `hostname_routes` (`workspace_id`); -CREATE INDEX `project_idx` ON `hostname_routes` (`project_id`); -CREATE INDEX `deployment_idx` ON `hostname_routes` (`deployment_id`); -CREATE INDEX `domain_status_idx` ON `domain_challenges` (`status`); CREATE INDEX `workspace_idx` ON `domains` (`workspace_id`); CREATE INDEX `project_idx` ON `domains` (`project_id`); +CREATE INDEX `workspace_idx` ON `acme_challenges` (`workspace_id`); diff --git a/go/pkg/db/workspace_find_by_id.sql_generated.go b/go/pkg/db/workspace_find_by_id.sql_generated.go index ce32393e4b..4e53f94d90 100644 --- a/go/pkg/db/workspace_find_by_id.sql_generated.go +++ b/go/pkg/db/workspace_find_by_id.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: workspace_find_by_id.sql package db diff --git a/go/pkg/db/workspace_hard_delete.sql_generated.go b/go/pkg/db/workspace_hard_delete.sql_generated.go index 592ec870fe..99918fbba4 100644 --- a/go/pkg/db/workspace_hard_delete.sql_generated.go +++ b/go/pkg/db/workspace_hard_delete.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: workspace_hard_delete.sql package db diff --git a/go/pkg/db/workspace_insert.sql_generated.go b/go/pkg/db/workspace_insert.sql_generated.go index 0377f24988..7b6c36ffaa 100644 --- a/go/pkg/db/workspace_insert.sql_generated.go +++ b/go/pkg/db/workspace_insert.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: workspace_insert.sql package db diff --git a/go/pkg/db/workspace_list.sql_generated.go b/go/pkg/db/workspace_list.sql_generated.go index da94015991..3c633aecd0 100644 --- a/go/pkg/db/workspace_list.sql_generated.go +++ b/go/pkg/db/workspace_list.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: workspace_list.sql package db diff --git a/go/pkg/db/workspace_soft_delete.sql_generated.go b/go/pkg/db/workspace_soft_delete.sql_generated.go index accafa0f19..756d30fd2b 100644 --- a/go/pkg/db/workspace_soft_delete.sql_generated.go +++ b/go/pkg/db/workspace_soft_delete.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: workspace_soft_delete.sql package db diff --git a/go/pkg/db/workspace_update_enabled.sql_generated.go b/go/pkg/db/workspace_update_enabled.sql_generated.go index ca711eabbd..c7ee14d4c6 100644 --- a/go/pkg/db/workspace_update_enabled.sql_generated.go +++ b/go/pkg/db/workspace_update_enabled.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: workspace_update_enabled.sql package db diff --git a/go/pkg/db/workspace_update_plan.sql_generated.go b/go/pkg/db/workspace_update_plan.sql_generated.go index cca72082ee..b31fc6f68e 100644 --- a/go/pkg/db/workspace_update_plan.sql_generated.go +++ b/go/pkg/db/workspace_update_plan.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: workspace_update_plan.sql package db diff --git a/go/pkg/hydra/store/models.go b/go/pkg/hydra/store/models.go index 7580966ecb..e948928a3d 100644 --- a/go/pkg/hydra/store/models.go +++ b/go/pkg/hydra/store/models.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 package store diff --git a/go/pkg/hydra/store/querier.go b/go/pkg/hydra/store/querier.go index 3184dfc0c8..a9a208732a 100644 --- a/go/pkg/hydra/store/querier.go +++ b/go/pkg/hydra/store/querier.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 package store diff --git a/go/pkg/hydra/store/workflows.sql.go b/go/pkg/hydra/store/workflows.sql.go index 9182ff6911..40bbe1dfed 100644 --- a/go/pkg/hydra/store/workflows.sql.go +++ b/go/pkg/hydra/store/workflows.sql.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: workflows.sql package store diff --git a/go/pkg/kv/stores/mysql/db.go b/go/pkg/kv/stores/mysql/db.go index f40d913f1a..03ec3423c3 100644 --- a/go/pkg/kv/stores/mysql/db.go +++ b/go/pkg/kv/stores/mysql/db.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.27.0 +// sqlc v1.28.0 package mysql diff --git a/go/pkg/kv/stores/mysql/delete.sql.go b/go/pkg/kv/stores/mysql/delete.sql.go index 84bc3bd589..a907385bea 100644 --- a/go/pkg/kv/stores/mysql/delete.sql.go +++ b/go/pkg/kv/stores/mysql/delete.sql.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.27.0 +// sqlc v1.28.0 // source: delete.sql package mysql diff --git a/go/pkg/kv/stores/mysql/delete_expired.sql.go b/go/pkg/kv/stores/mysql/delete_expired.sql.go index d03f52ac6b..0229f04753 100644 --- a/go/pkg/kv/stores/mysql/delete_expired.sql.go +++ b/go/pkg/kv/stores/mysql/delete_expired.sql.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.27.0 +// sqlc v1.28.0 // source: delete_expired.sql package mysql diff --git a/go/pkg/kv/stores/mysql/get.sql.go b/go/pkg/kv/stores/mysql/get.sql.go index 187a309701..e36a0c9be3 100644 --- a/go/pkg/kv/stores/mysql/get.sql.go +++ b/go/pkg/kv/stores/mysql/get.sql.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.27.0 +// sqlc v1.28.0 // source: get.sql package mysql diff --git a/go/pkg/kv/stores/mysql/list_by_workspace.sql.go b/go/pkg/kv/stores/mysql/list_by_workspace.sql.go index 93a55564b6..1c1ad699bd 100644 --- a/go/pkg/kv/stores/mysql/list_by_workspace.sql.go +++ b/go/pkg/kv/stores/mysql/list_by_workspace.sql.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.27.0 +// sqlc v1.28.0 // source: list_by_workspace.sql package mysql diff --git a/go/pkg/kv/stores/mysql/models.go b/go/pkg/kv/stores/mysql/models.go index 80dba3ec16..ff7954c3ff 100644 --- a/go/pkg/kv/stores/mysql/models.go +++ b/go/pkg/kv/stores/mysql/models.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.27.0 +// sqlc v1.28.0 package mysql diff --git a/go/pkg/kv/stores/mysql/set.sql.go b/go/pkg/kv/stores/mysql/set.sql.go index e8a4f9fd0a..a58a489437 100644 --- a/go/pkg/kv/stores/mysql/set.sql.go +++ b/go/pkg/kv/stores/mysql/set.sql.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.27.0 +// sqlc v1.28.0 // source: set.sql package mysql diff --git a/go/pkg/partition/db/certificate_find_by_hostname.sql_generated.go b/go/pkg/partition/db/certificate_find_by_hostname.sql_generated.go index 43373f86c7..e2a27d2ba8 100644 --- a/go/pkg/partition/db/certificate_find_by_hostname.sql_generated.go +++ b/go/pkg/partition/db/certificate_find_by_hostname.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: certificate_find_by_hostname.sql package db diff --git a/go/pkg/partition/db/certificate_insert.sql_generated.go b/go/pkg/partition/db/certificate_insert.sql_generated.go index 83c6e4d2f6..cafdc1e4f3 100644 --- a/go/pkg/partition/db/certificate_insert.sql_generated.go +++ b/go/pkg/partition/db/certificate_insert.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: certificate_insert.sql package db diff --git a/go/pkg/partition/db/gateway_delete_by_hostname.sql_generated.go b/go/pkg/partition/db/gateway_delete_by_hostname.sql_generated.go index bb1810e097..6bdc260a22 100644 --- a/go/pkg/partition/db/gateway_delete_by_hostname.sql_generated.go +++ b/go/pkg/partition/db/gateway_delete_by_hostname.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: gateway_delete_by_hostname.sql package db diff --git a/go/pkg/partition/db/gateway_find_config_by_hostname.sql_generated.go b/go/pkg/partition/db/gateway_find_config_by_hostname.sql_generated.go index 155df12f22..5c129edc4b 100644 --- a/go/pkg/partition/db/gateway_find_config_by_hostname.sql_generated.go +++ b/go/pkg/partition/db/gateway_find_config_by_hostname.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: gateway_find_config_by_hostname.sql package db diff --git a/go/pkg/partition/db/gateway_upsert.sql_generated.go b/go/pkg/partition/db/gateway_upsert.sql_generated.go index 3c9cc0beb4..346ba49d34 100644 --- a/go/pkg/partition/db/gateway_upsert.sql_generated.go +++ b/go/pkg/partition/db/gateway_upsert.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: gateway_upsert.sql package db diff --git a/go/pkg/partition/db/models_generated.go b/go/pkg/partition/db/models_generated.go index 149f2c0c7c..68c83330ad 100644 --- a/go/pkg/partition/db/models_generated.go +++ b/go/pkg/partition/db/models_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 package db @@ -54,49 +54,6 @@ func (ns NullMetalHostsStatus) Value() (driver.Value, error) { return string(ns.MetalHostsStatus), nil } -type VmsHealthStatus string - -const ( - VmsHealthStatusUnknown VmsHealthStatus = "unknown" - VmsHealthStatusHealthy VmsHealthStatus = "healthy" - VmsHealthStatusUnhealthy VmsHealthStatus = "unhealthy" -) - -func (e *VmsHealthStatus) Scan(src interface{}) error { - switch s := src.(type) { - case []byte: - *e = VmsHealthStatus(s) - case string: - *e = VmsHealthStatus(s) - default: - return fmt.Errorf("unsupported scan type for VmsHealthStatus: %T", src) - } - return nil -} - -type NullVmsHealthStatus struct { - VmsHealthStatus VmsHealthStatus - Valid bool // Valid is true if VmsHealthStatus is not NULL -} - -// Scan implements the Scanner interface. -func (ns *NullVmsHealthStatus) Scan(value interface{}) error { - if value == nil { - ns.VmsHealthStatus, ns.Valid = "", false - return nil - } - ns.Valid = true - return ns.VmsHealthStatus.Scan(value) -} - -// Value implements the driver Valuer interface. -func (ns NullVmsHealthStatus) Value() (driver.Value, error) { - if !ns.Valid { - return nil, nil - } - return string(ns.VmsHealthStatus), nil -} - type VmsStatus string const ( @@ -155,9 +112,10 @@ type Certificate struct { } type Gateway struct { - ID uint64 `db:"id"` - Hostname string `db:"hostname"` - Config []byte `db:"config"` + ID uint64 `db:"id"` + WorkspaceID string `db:"workspace_id"` + Hostname string `db:"hostname"` + Config []byte `db:"config"` } type MetalHost struct { @@ -176,15 +134,11 @@ type MetalHost struct { } type Vm struct { - ID string `db:"id"` - DeploymentID string `db:"deployment_id"` - MetalHostID sql.NullString `db:"metal_host_id"` - Region string `db:"region"` - PrivateIp sql.NullString `db:"private_ip"` - Port sql.NullInt32 `db:"port"` - CpuMillicores int32 `db:"cpu_millicores"` - MemoryMb int32 `db:"memory_mb"` - Status VmsStatus `db:"status"` - HealthStatus VmsHealthStatus `db:"health_status"` - LastHeartbeat sql.NullInt64 `db:"last_heartbeat"` + ID string `db:"id"` + DeploymentID string `db:"deployment_id"` + MetalHostID sql.NullString `db:"metal_host_id"` + Address sql.NullString `db:"address"` + CpuMillicores int32 `db:"cpu_millicores"` + MemoryMb int32 `db:"memory_mb"` + Status VmsStatus `db:"status"` } diff --git a/go/pkg/partition/db/querier_generated.go b/go/pkg/partition/db/querier_generated.go index 592cb5f6f7..2543394def 100644 --- a/go/pkg/partition/db/querier_generated.go +++ b/go/pkg/partition/db/querier_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 package db @@ -25,7 +25,7 @@ type Querier interface { FindGatewayByHostname(ctx context.Context, db DBTX, hostname string) (FindGatewayByHostnameRow, error) //FindVMById // - // SELECT id, deployment_id, metal_host_id, region, private_ip, port, cpu_millicores, memory_mb, status, health_status, last_heartbeat FROM vms WHERE id = ? + // SELECT id, deployment_id, metal_host_id, address, cpu_millicores, memory_mb, status FROM vms WHERE id = ? FindVMById(ctx context.Context, db DBTX, id string) (Vm, error) //InsertCertificate // @@ -44,17 +44,14 @@ type Querier interface { UpsertGateway(ctx context.Context, db DBTX, arg UpsertGatewayParams) error //UpsertVM // - // INSERT INTO vms (id, deployment_id, region, private_ip, port, cpu_millicores, memory_mb, status, health_status) - // VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) + // INSERT INTO vms (id, deployment_id, address, cpu_millicores, memory_mb, status) + // VALUES (?, ?, ?, ?, ?, ?) // ON DUPLICATE KEY UPDATE // deployment_id = VALUES(deployment_id), - // region = VALUES(region), - // private_ip = VALUES(private_ip), - // port = VALUES(port), + // address = VALUES(address), // cpu_millicores = VALUES(cpu_millicores), // memory_mb = VALUES(memory_mb), - // status = VALUES(status), - // health_status = VALUES(health_status) + // status = VALUES(status) UpsertVM(ctx context.Context, db DBTX, arg UpsertVMParams) error } diff --git a/go/pkg/partition/db/queries/vm_upsert.sql b/go/pkg/partition/db/queries/vm_upsert.sql index 76e2aabe68..2c87a26619 100644 --- a/go/pkg/partition/db/queries/vm_upsert.sql +++ b/go/pkg/partition/db/queries/vm_upsert.sql @@ -1,12 +1,10 @@ -- name: UpsertVM :exec -INSERT INTO vms (id, deployment_id, region, private_ip, port, cpu_millicores, memory_mb, status, health_status) -VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) +INSERT INTO vms (id, deployment_id, address, cpu_millicores, memory_mb, status) +VALUES (?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE deployment_id = VALUES(deployment_id), - region = VALUES(region), - private_ip = VALUES(private_ip), - port = VALUES(port), + address = VALUES(address), cpu_millicores = VALUES(cpu_millicores), memory_mb = VALUES(memory_mb), - status = VALUES(status), - health_status = VALUES(health_status); + status = VALUES(status) + ; diff --git a/go/pkg/partition/db/schema.sql b/go/pkg/partition/db/schema.sql index f0bf68c0c3..06ee30fca4 100644 --- a/go/pkg/partition/db/schema.sql +++ b/go/pkg/partition/db/schema.sql @@ -9,6 +9,7 @@ USE `partition_001`; -- Contains all middleware configuration (auth, rate limiting, validation, etc.) as protobuf CREATE TABLE gateways ( `id` bigint unsigned NOT NULL AUTO_INCREMENT, + `workspace_id` varchar(255) NOT NULL, `hostname` varchar(255) NOT NULL, `config` blob NOT NULL, -- Protobuf with all configuration including deployment_id, workspace_id PRIMARY KEY (`id`), @@ -21,21 +22,14 @@ CREATE TABLE vms ( id VARCHAR(255) NOT NULL PRIMARY KEY, deployment_id VARCHAR(255) NOT NULL, metal_host_id VARCHAR(255), -- NULL until assigned to a host - region VARCHAR(255) NOT NULL, - private_ip VARCHAR(45), -- NULL until provisioned - port INT, -- NULL until provisioned + -- metalhost ip and port + address VARCHAR(255), -- NULL until provisioned cpu_millicores INT NOT NULL, memory_mb INT NOT NULL, status ENUM('allocated', 'provisioning', 'starting', 'running', 'stopping', 'stopped', 'failed') NOT NULL, - health_status ENUM('unknown', 'healthy', 'unhealthy') NOT NULL DEFAULT 'unknown', - last_heartbeat BIGINT, -- NULL until running - INDEX idx_deployment_available (deployment_id, region, status), - INDEX idx_deployment_health (deployment_id, health_status, last_heartbeat), - INDEX idx_host_id (metal_host_id), - INDEX idx_region (region), - INDEX idx_status (status), - UNIQUE KEY unique_ip_port (private_ip, port) + + UNIQUE KEY unique_address (address) ); -- Metal host instances running metald diff --git a/go/pkg/partition/db/vm_find_by_id.sql_generated.go b/go/pkg/partition/db/vm_find_by_id.sql_generated.go index d89f33f182..0be958961a 100644 --- a/go/pkg/partition/db/vm_find_by_id.sql_generated.go +++ b/go/pkg/partition/db/vm_find_by_id.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: vm_find_by_id.sql package db @@ -10,12 +10,12 @@ import ( ) const findVMById = `-- name: FindVMById :one -SELECT id, deployment_id, metal_host_id, region, private_ip, port, cpu_millicores, memory_mb, status, health_status, last_heartbeat FROM vms WHERE id = ? +SELECT id, deployment_id, metal_host_id, address, cpu_millicores, memory_mb, status FROM vms WHERE id = ? ` // FindVMById // -// SELECT id, deployment_id, metal_host_id, region, private_ip, port, cpu_millicores, memory_mb, status, health_status, last_heartbeat FROM vms WHERE id = ? +// SELECT id, deployment_id, metal_host_id, address, cpu_millicores, memory_mb, status FROM vms WHERE id = ? func (q *Queries) FindVMById(ctx context.Context, db DBTX, id string) (Vm, error) { row := db.QueryRowContext(ctx, findVMById, id) var i Vm @@ -23,14 +23,10 @@ func (q *Queries) FindVMById(ctx context.Context, db DBTX, id string) (Vm, error &i.ID, &i.DeploymentID, &i.MetalHostID, - &i.Region, - &i.PrivateIp, - &i.Port, + &i.Address, &i.CpuMillicores, &i.MemoryMb, &i.Status, - &i.HealthStatus, - &i.LastHeartbeat, ) return i, err } diff --git a/go/pkg/partition/db/vm_upsert.sql_generated.go b/go/pkg/partition/db/vm_upsert.sql_generated.go index 1195aa8ea6..7487152706 100644 --- a/go/pkg/partition/db/vm_upsert.sql_generated.go +++ b/go/pkg/partition/db/vm_upsert.sql_generated.go @@ -1,6 +1,6 @@ // Code generated by sqlc. DO NOT EDIT. // versions: -// sqlc v1.28.0 +// sqlc v1.29.0 // source: vm_upsert.sql package db @@ -11,55 +11,43 @@ import ( ) const upsertVM = `-- name: UpsertVM :exec -INSERT INTO vms (id, deployment_id, region, private_ip, port, cpu_millicores, memory_mb, status, health_status) -VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) +INSERT INTO vms (id, deployment_id, address, cpu_millicores, memory_mb, status) +VALUES (?, ?, ?, ?, ?, ?) ON DUPLICATE KEY UPDATE deployment_id = VALUES(deployment_id), - region = VALUES(region), - private_ip = VALUES(private_ip), - port = VALUES(port), + address = VALUES(address), cpu_millicores = VALUES(cpu_millicores), memory_mb = VALUES(memory_mb), - status = VALUES(status), - health_status = VALUES(health_status) + status = VALUES(status) ` type UpsertVMParams struct { - ID string `db:"id"` - DeploymentID string `db:"deployment_id"` - Region string `db:"region"` - PrivateIp sql.NullString `db:"private_ip"` - Port sql.NullInt32 `db:"port"` - CpuMillicores int32 `db:"cpu_millicores"` - MemoryMb int32 `db:"memory_mb"` - Status VmsStatus `db:"status"` - HealthStatus VmsHealthStatus `db:"health_status"` + ID string `db:"id"` + DeploymentID string `db:"deployment_id"` + Address sql.NullString `db:"address"` + CpuMillicores int32 `db:"cpu_millicores"` + MemoryMb int32 `db:"memory_mb"` + Status VmsStatus `db:"status"` } // UpsertVM // -// INSERT INTO vms (id, deployment_id, region, private_ip, port, cpu_millicores, memory_mb, status, health_status) -// VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?) +// INSERT INTO vms (id, deployment_id, address, cpu_millicores, memory_mb, status) +// VALUES (?, ?, ?, ?, ?, ?) // ON DUPLICATE KEY UPDATE // deployment_id = VALUES(deployment_id), -// region = VALUES(region), -// private_ip = VALUES(private_ip), -// port = VALUES(port), +// address = VALUES(address), // cpu_millicores = VALUES(cpu_millicores), // memory_mb = VALUES(memory_mb), -// status = VALUES(status), -// health_status = VALUES(health_status) +// status = VALUES(status) func (q *Queries) UpsertVM(ctx context.Context, db DBTX, arg UpsertVMParams) error { _, err := db.ExecContext(ctx, upsertVM, arg.ID, arg.DeploymentID, - arg.Region, - arg.PrivateIp, - arg.Port, + arg.Address, arg.CpuMillicores, arg.MemoryMb, arg.Status, - arg.HealthStatus, ) return err } diff --git a/go/pkg/uid/uid.go b/go/pkg/uid/uid.go index 0b458b420e..8745871647 100644 --- a/go/pkg/uid/uid.go +++ b/go/pkg/uid/uid.go @@ -45,6 +45,7 @@ const ( BuildPrefix Prefix = "build" RootfsImagePrefix Prefix = "img" DomainPrefix Prefix = "dom" + DeploymentPrefix Prefix = "d" ) // epoch starts more recently so that the 32-bit number space gives a diff --git a/go/proto/ctrl/v1/version.proto b/go/proto/ctrl/v1/deployment.proto similarity index 69% rename from go/proto/ctrl/v1/version.proto rename to go/proto/ctrl/v1/deployment.proto index c58c023255..3d40f82b17 100644 --- a/go/proto/ctrl/v1/version.proto +++ b/go/proto/ctrl/v1/deployment.proto @@ -4,25 +4,24 @@ package ctrl.v1; option go_package = "github.com/unkeyed/unkey/go/gen/proto/ctrl/v1;ctrlv1"; -// Version status enum -enum VersionStatus { - VERSION_STATUS_UNSPECIFIED = 0; - VERSION_STATUS_PENDING = 1; - VERSION_STATUS_BUILDING = 2; - VERSION_STATUS_DEPLOYING = 3; - VERSION_STATUS_ACTIVE = 4; - VERSION_STATUS_FAILED = 5; - VERSION_STATUS_ARCHIVED = 6; +// Deployment status enum +enum DeploymentStatus { + DEPLOYMENT_STATUS_UNSPECIFIED = 0; + DEPLOYMENT_STATUS_PENDING = 1; + DEPLOYMENT_STATUS_BUILDING = 2; + DEPLOYMENT_STATUS_DEPLOYING = 3; + DEPLOYMENT_STATUS_NETWORK = 4; + DEPLOYMENT_STATUS_READY = 5; + DEPLOYMENT_STATUS_FAILED = 6; } - -// Source type for version creation +// Source type for deployment creation enum SourceType { SOURCE_TYPE_UNSPECIFIED = 0; SOURCE_TYPE_GIT = 1; SOURCE_TYPE_CLI_UPLOAD = 2; } -message CreateVersionRequest { +message CreateDeploymentRequest { string workspace_id = 1; string project_id = 2; string branch = 3; @@ -47,20 +46,20 @@ message CreateVersionRequest { int64 git_commit_timestamp = 14; // Unix epoch milliseconds } -message CreateVersionResponse { - string version_id = 1; - VersionStatus status = 2; // Will be PENDING or BUILDING +message CreateDeploymentResponse { + string deployment_id = 1; + DeploymentStatus status = 2; // Will be PENDING or BUILDING } -message GetVersionRequest { - string version_id = 1; +message GetDeploymentRequest { + string deployment_id = 1; } -message GetVersionResponse { - Version version = 1; +message GetDeploymentResponse { + Deployment deployment = 1; } -message Version { +message Deployment { string id = 1; string workspace_id = 2; string project_id = 3; @@ -71,8 +70,8 @@ message Version { string git_branch = 6; // Status and lifecycle - VersionStatus status = 7; - string error_message = 8; // For failed versions + DeploymentStatus status = 7; + string error_message = 8; // For failed deployments // Configuration snapshot (resolved at creation time) map environment_variables = 9; @@ -84,7 +83,7 @@ message Version { int64 created_at = 11; int64 updated_at = 12; - // Associated hostnames for this version + // Associated hostnames for this deployment repeated string hostnames = 13; // Build information @@ -92,7 +91,7 @@ message Version { string build_id = 15; // Deployment steps - repeated VersionStep steps = 16; + repeated DeploymentStep steps = 16; // Extended git information string git_commit_message = 17; @@ -103,7 +102,7 @@ message Version { int64 git_commit_timestamp = 22; // Unix epoch milliseconds } -message VersionStep { +message DeploymentStep { string status = 1; string message = 2; string error_message = 3; @@ -129,10 +128,10 @@ message RegionalConfig { int32 max_instances = 3; } -service VersionService { - // Create a new version - rpc CreateVersion(CreateVersionRequest) returns (CreateVersionResponse) {} +service DeploymentService { + // Create a new deployment + rpc CreateDeployment(CreateDeploymentRequest) returns (CreateDeploymentResponse) {} - // Get version details - rpc GetVersion(GetVersionRequest) returns (GetVersionResponse) {} + // Get deployment details + rpc GetDeployment(GetDeploymentRequest) returns (GetDeploymentResponse) {} } diff --git a/go/proto/metal/vmprovisioner/v1/wip.proto b/go/proto/metal/vmprovisioner/v1/wip.proto new file mode 100644 index 0000000000..babbb08d92 --- /dev/null +++ b/go/proto/metal/vmprovisioner/v1/wip.proto @@ -0,0 +1,38 @@ +syntax = "proto3"; + +package metal.vmprovisioner.v1; + +option go_package = "github.com/unkeyed/unkey/go/gen/proto/metal/vmprovisioner/v1;vmprovisionerv1"; + + +// from our call, ian +// lmk what you think, it's not hooked up yet and we can change it as you wish. +message CreateVmRequestV2 { + string vm_id = 1; + // I know you want this elsewhere but I really don't understand what you want me to do. + // cause just defining it as `message DeploymentId string` doesn't make anything better. + // please send help + string deployment_id = 2; + + // 1024 = 1 vcpu + uint32 cpu_millicores = 3; // millicores, e.g., 1024 = 1 vCPU + uint64 memory_bytes = 4; // bytes + string docker_image = 5; // full image ref: registry/repo:tag or digest + NetworkSize network_size = 6; // default: NETWORK_SIZE_UNSPECIFIED +} + +message CreateVmRespomseV2 { + // metalhost_ip:port + string address = 1; + + // can't figure out the damn import path + // VmState state = 2; + +} + +enum NetworkSize { + // These are made up + NETWORK_SIZE_SMALL = 0; + NETWORK_SIZE_MEDIUM = 1; + NETWORK_SIZE_LARGE = 2; +} diff --git a/go/proto/partition/v1/gateway.proto b/go/proto/partition/v1/gateway.proto index e2c7a3ff6e..1711bc5bb9 100644 --- a/go/proto/partition/v1/gateway.proto +++ b/go/proto/partition/v1/gateway.proto @@ -7,41 +7,41 @@ option go_package = "github.com/unkeyed/unkey/go/gen/proto/partition/v1;partitio // GatewayConfig contains all configuration needed for a hostname // including deployment metadata and middleware configurations message GatewayConfig { - // Routing configuration - bool is_enabled = 1; + Project project= 1; // Deployment information - string deployment_id = 2; - string workspace_id = 3; - string project_id = 4; - string environment = 5; + Deployment deployment = 2; - repeated VM vms = 6; + repeated VM vms = 3; // Middleware configurations - AuthConfig auth_config = 10; - ValidationConfig validation_config = 11; + optional AuthConfig auth_config = 4; + optional ValidationConfig validation_config = 5; - // Deployment metadata - string git_commit_sha = 20; - string git_branch = 21; +} + +message Deployment { + string id = 1; + + bool is_enabled = 2; +} + +message Project { + string id = 1; + + bool is_enabled = 2; } message VM { string id = 1; - string region = 2; } // Authentication middleware configuration message AuthConfig { - bool require_api_key = 1; - string keyspace_id = 2; - bool allow_anonymous = 3; - bool enabled = 4; + string key_auth_id = 1; } // Request validation middleware configuration message ValidationConfig { - bool enabled = 1; - string openapi_spec = 2; + string openapi_spec = 1; } diff --git a/internal/db/drizzle/0000_amused_havok.sql b/internal/db/drizzle/0000_useful_nextwave.sql similarity index 77% rename from internal/db/drizzle/0000_amused_havok.sql rename to internal/db/drizzle/0000_useful_nextwave.sql index 50603fe16e..5829eb4505 100644 --- a/internal/db/drizzle/0000_amused_havok.sql +++ b/internal/db/drizzle/0000_useful_nextwave.sql @@ -289,25 +289,22 @@ CREATE TABLE `audit_log_target` ( CONSTRAINT `audit_log_target_audit_log_id_id_pk` PRIMARY KEY(`audit_log_id`,`id`) ); --> statement-breakpoint -CREATE TABLE `partitions` ( +CREATE TABLE `environments` ( `id` varchar(256) NOT NULL, - `name` varchar(256) NOT NULL, - `description` text, - `aws_account_id` varchar(256) NOT NULL, - `region` varchar(256) NOT NULL, - `ip_v4_address` varchar(15), - `ip_v6_address` varchar(39), - `status` enum('active','draining','inactive') NOT NULL DEFAULT 'active', + `workspace_id` varchar(256) NOT NULL, + `project_id` varchar(256) NOT NULL, + `slug` varchar(256) NOT NULL, + `description` varchar(255), `delete_protection` boolean DEFAULT false, `created_at` bigint NOT NULL, `updated_at` bigint, - CONSTRAINT `partitions_id` PRIMARY KEY(`id`) + CONSTRAINT `environments_id` PRIMARY KEY(`id`), + CONSTRAINT `environments_workspace_id_slug_idx` UNIQUE(`workspace_id`,`slug`) ); --> statement-breakpoint CREATE TABLE `projects` ( `id` varchar(256) NOT NULL, `workspace_id` varchar(256) NOT NULL, - `partition_id` varchar(256) NOT NULL, `name` varchar(256) NOT NULL, `slug` varchar(256) NOT NULL, `git_repository_url` varchar(500), @@ -319,60 +316,35 @@ CREATE TABLE `projects` ( CONSTRAINT `workspace_slug_idx` UNIQUE(`workspace_id`,`slug`) ); --> statement-breakpoint -CREATE TABLE `rootfs_images` ( - `id` varchar(256) NOT NULL, - `workspace_id` varchar(256) NOT NULL, - `project_id` varchar(256) NOT NULL, - `s3_bucket` varchar(256) NOT NULL, - `s3_key` varchar(500) NOT NULL, - `size_bytes` bigint NOT NULL, - `created_at` bigint NOT NULL, - `updated_at` bigint, - CONSTRAINT `rootfs_images_id` PRIMARY KEY(`id`) -); ---> statement-breakpoint -CREATE TABLE `builds` ( +CREATE TABLE `deployments` ( `id` varchar(256) NOT NULL, `workspace_id` varchar(256) NOT NULL, `project_id` varchar(256) NOT NULL, - `deployment_id` varchar(256) NOT NULL, - `rootfs_image_id` varchar(256), + `environment_id` varchar(256) NOT NULL, `git_commit_sha` varchar(40), `git_branch` varchar(256), - `status` enum('pending','running','succeeded','failed','cancelled') NOT NULL DEFAULT 'pending', - `build_tool` enum('docker','depot','custom') NOT NULL DEFAULT 'docker', - `error_message` text, - `started_at` bigint, - `completed_at` bigint, + `git_commit_message` text, + `git_commit_author_name` varchar(256), + `git_commit_author_email` varchar(256), + `git_commit_author_username` varchar(256), + `git_commit_author_avatar_url` varchar(512), + `git_commit_timestamp` bigint, + `runtime_config` json NOT NULL, + `openapi_spec` text, + `status` enum('pending','building','deploying','network','ready','failed') NOT NULL DEFAULT 'pending', `created_at` bigint NOT NULL, `updated_at` bigint, - CONSTRAINT `builds_id` PRIMARY KEY(`id`) + CONSTRAINT `deployments_id` PRIMARY KEY(`id`) ); --> statement-breakpoint CREATE TABLE `deployment_steps` ( `deployment_id` varchar(256) NOT NULL, - `status` enum('pending','downloading_docker_image','building_rootfs','uploading_rootfs','creating_vm','booting_vm','assigning_domains','completed','failed') NOT NULL, - `message` text, - `error_message` text, - `created_at` bigint NOT NULL, - CONSTRAINT `deployment_steps_deployment_id_status_pk` PRIMARY KEY(`deployment_id`,`status`) -); ---> statement-breakpoint -CREATE TABLE `deployments` ( - `id` varchar(256) NOT NULL, `workspace_id` varchar(256) NOT NULL, `project_id` varchar(256) NOT NULL, - `environment` enum('production','preview') NOT NULL DEFAULT 'preview', - `build_id` varchar(256), - `rootfs_image_id` varchar(256) NOT NULL, - `git_commit_sha` varchar(40), - `git_branch` varchar(256), - `config_snapshot` json NOT NULL, - `openapi_spec` text, - `status` enum('pending','building','deploying','active','failed','archived') NOT NULL DEFAULT 'pending', + `status` enum('pending','downloading_docker_image','building_rootfs','uploading_rootfs','creating_vm','booting_vm','assigning_domains','completed','failed') NOT NULL, + `message` varchar(1024) NOT NULL, `created_at` bigint NOT NULL, - `updated_at` bigint, - CONSTRAINT `deployments_id` PRIMARY KEY(`id`) + CONSTRAINT `deployment_steps_deployment_id_status_pk` PRIMARY KEY(`deployment_id`,`status`) ); --> statement-breakpoint CREATE TABLE `acme_users` ( @@ -385,45 +357,30 @@ CREATE TABLE `acme_users` ( CONSTRAINT `acme_users_id` PRIMARY KEY(`id`) ); --> statement-breakpoint -CREATE TABLE `hostname_routes` ( +CREATE TABLE `domains` ( `id` varchar(256) NOT NULL, `workspace_id` varchar(256) NOT NULL, - `project_id` varchar(256) NOT NULL, - `hostname` varchar(256) NOT NULL, - `deployment_id` varchar(256) NOT NULL, - `is_enabled` boolean NOT NULL DEFAULT true, + `project_id` varchar(256), + `deployment_id` varchar(256), + `domain` varchar(256) NOT NULL, + `type` enum('custom','wildcard') NOT NULL, `created_at` bigint NOT NULL, `updated_at` bigint, - CONSTRAINT `hostname_routes_id` PRIMARY KEY(`id`), - CONSTRAINT `hostname_idx` UNIQUE(`hostname`) + CONSTRAINT `domains_id` PRIMARY KEY(`id`) ); --> statement-breakpoint -CREATE TABLE `domain_challenges` ( +CREATE TABLE `acme_challenges` ( `id` bigint unsigned AUTO_INCREMENT NOT NULL, - `workspace_id` varchar(255) NOT NULL, - `domain_id` varchar(255) NOT NULL, - `token` varchar(255), - `authorization` varchar(255), - `status` enum('waiting','pending','verified','failed','expired') NOT NULL DEFAULT 'pending', - `type` enum('http-01','dns-01','tls-alpn-01') NOT NULL DEFAULT 'http-01', - `created_at` bigint NOT NULL, - `updated_at` bigint, - `expires_at` bigint unsigned, - CONSTRAINT `domain_challenges_id` PRIMARY KEY(`id`), - CONSTRAINT `domainIdWorkspaceId_idx` UNIQUE(`domain_id`,`workspace_id`) -); ---> statement-breakpoint -CREATE TABLE `domains` ( - `id` varchar(255) NOT NULL, - `workspace_id` varchar(255) NOT NULL, - `project_id` varchar(255) NOT NULL, - `domain` varchar(255) NOT NULL, - `type` enum('custom','generated') NOT NULL DEFAULT 'generated', - `subdomain_config` json, + `workspace_id` varchar(256) NOT NULL, + `domain_id` varchar(256) NOT NULL, + `token` varchar(256) NOT NULL, + `type` enum('HTTP-01','DNS-01') NOT NULL, + `authorization` varchar(256) NOT NULL, + `status` enum('waiting','pending','verified','failed') NOT NULL, + `expires_at` bigint NOT NULL, `created_at` bigint NOT NULL, `updated_at` bigint, - CONSTRAINT `domains_id` PRIMARY KEY(`id`), - CONSTRAINT `domain_idx` UNIQUE(`domain`) + CONSTRAINT `acme_challenges_id` PRIMARY KEY(`id`) ); --> statement-breakpoint CREATE INDEX `workspace_id_idx` ON `apis` (`workspace_id`);--> statement-breakpoint @@ -444,25 +401,11 @@ CREATE INDEX `time_idx` ON `audit_log` (`time`);--> statement-breakpoint CREATE INDEX `bucket` ON `audit_log_target` (`bucket`);--> statement-breakpoint CREATE INDEX `audit_log_id` ON `audit_log_target` (`audit_log_id`);--> statement-breakpoint CREATE INDEX `id_idx` ON `audit_log_target` (`id`);--> statement-breakpoint -CREATE INDEX `status_idx` ON `partitions` (`status`);--> statement-breakpoint CREATE INDEX `workspace_idx` ON `projects` (`workspace_id`);--> statement-breakpoint -CREATE INDEX `partition_idx` ON `projects` (`partition_id`);--> statement-breakpoint -CREATE INDEX `workspace_idx` ON `rootfs_images` (`workspace_id`);--> statement-breakpoint -CREATE INDEX `project_idx` ON `rootfs_images` (`project_id`);--> statement-breakpoint -CREATE INDEX `workspace_idx` ON `builds` (`workspace_id`);--> statement-breakpoint -CREATE INDEX `project_idx` ON `builds` (`project_id`);--> statement-breakpoint -CREATE INDEX `status_idx` ON `builds` (`status`);--> statement-breakpoint -CREATE INDEX `rootfs_image_idx` ON `builds` (`rootfs_image_id`);--> statement-breakpoint -CREATE INDEX `idx_deployment_id_created_at` ON `deployment_steps` (`deployment_id`,`created_at`);--> statement-breakpoint CREATE INDEX `workspace_idx` ON `deployments` (`workspace_id`);--> statement-breakpoint CREATE INDEX `project_idx` ON `deployments` (`project_id`);--> statement-breakpoint -CREATE INDEX `environment_idx` ON `deployments` (`environment`);--> statement-breakpoint CREATE INDEX `status_idx` ON `deployments` (`status`);--> statement-breakpoint -CREATE INDEX `rootfs_image_idx` ON `deployments` (`rootfs_image_id`);--> statement-breakpoint CREATE INDEX `domain_idx` ON `acme_users` (`workspace_id`);--> statement-breakpoint -CREATE INDEX `workspace_idx` ON `hostname_routes` (`workspace_id`);--> statement-breakpoint -CREATE INDEX `project_idx` ON `hostname_routes` (`project_id`);--> statement-breakpoint -CREATE INDEX `deployment_idx` ON `hostname_routes` (`deployment_id`);--> statement-breakpoint -CREATE INDEX `domain_status_idx` ON `domain_challenges` (`status`);--> statement-breakpoint CREATE INDEX `workspace_idx` ON `domains` (`workspace_id`);--> statement-breakpoint -CREATE INDEX `project_idx` ON `domains` (`project_id`); \ No newline at end of file +CREATE INDEX `project_idx` ON `domains` (`project_id`);--> statement-breakpoint +CREATE INDEX `workspace_idx` ON `acme_challenges` (`workspace_id`); diff --git a/internal/db/drizzle/meta/0000_snapshot.json b/internal/db/drizzle/meta/0000_snapshot.json index 0958a9b96e..1c839581e7 100644 --- a/internal/db/drizzle/meta/0000_snapshot.json +++ b/internal/db/drizzle/meta/0000_snapshot.json @@ -1,7 +1,7 @@ { "version": "5", "dialect": "mysql", - "id": "88a1691a-f40b-497a-ae77-dbf5265dd6b5", + "id": "1c1b2291-b582-4d8f-9bd7-a76d34a8af62", "prevId": "00000000-0000-0000-0000-000000000000", "tables": { "apis": { @@ -1849,8 +1849,8 @@ }, "uniqueConstraints": {} }, - "partitions": { - "name": "partitions", + "environments": { + "name": "environments", "columns": { "id": { "name": "id", @@ -1859,56 +1859,34 @@ "notNull": true, "autoincrement": false }, - "name": { - "name": "name", + "workspace_id": { + "name": "workspace_id", "type": "varchar(256)", "primaryKey": false, "notNull": true, "autoincrement": false }, - "description": { - "name": "description", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "aws_account_id": { - "name": "aws_account_id", + "project_id": { + "name": "project_id", "type": "varchar(256)", "primaryKey": false, "notNull": true, "autoincrement": false }, - "region": { - "name": "region", + "slug": { + "name": "slug", "type": "varchar(256)", "primaryKey": false, "notNull": true, "autoincrement": false }, - "ip_v4_address": { - "name": "ip_v4_address", - "type": "varchar(15)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "ip_v6_address": { - "name": "ip_v6_address", - "type": "varchar(39)", + "description": { + "name": "description", + "type": "varchar(255)", "primaryKey": false, "notNull": false, "autoincrement": false }, - "status": { - "name": "status", - "type": "enum('active','draining','inactive')", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "'active'" - }, "delete_protection": { "name": "delete_protection", "type": "boolean", @@ -1933,16 +1911,16 @@ } }, "indexes": { - "status_idx": { - "name": "status_idx", - "columns": ["status"], - "isUnique": false + "environments_workspace_id_slug_idx": { + "name": "environments_workspace_id_slug_idx", + "columns": ["workspace_id", "slug"], + "isUnique": true } }, "foreignKeys": {}, "compositePrimaryKeys": { - "partitions_id": { - "name": "partitions_id", + "environments_id": { + "name": "environments_id", "columns": ["id"] } }, @@ -1965,13 +1943,6 @@ "notNull": true, "autoincrement": false }, - "partition_id": { - "name": "partition_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, "name": { "name": "name", "type": "varchar(256)", @@ -2030,11 +2001,6 @@ "columns": ["workspace_id"], "isUnique": false }, - "partition_idx": { - "name": "partition_idx", - "columns": ["partition_id"], - "isUnique": false - }, "workspace_slug_idx": { "name": "workspace_slug_idx", "columns": ["workspace_id", "slug"], @@ -2050,8 +2016,8 @@ }, "uniqueConstraints": {} }, - "rootfs_images": { - "name": "rootfs_images", + "deployments": { + "name": "deployments", "columns": { "id": { "name": "id", @@ -2074,152 +2040,91 @@ "notNull": true, "autoincrement": false }, - "s3_bucket": { - "name": "s3_bucket", + "environment_id": { + "name": "environment_id", "type": "varchar(256)", "primaryKey": false, "notNull": true, "autoincrement": false }, - "s3_key": { - "name": "s3_key", - "type": "varchar(500)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "size_bytes": { - "name": "size_bytes", - "type": "bigint", + "git_commit_sha": { + "name": "git_commit_sha", + "type": "varchar(40)", "primaryKey": false, - "notNull": true, + "notNull": false, "autoincrement": false }, - "created_at": { - "name": "created_at", - "type": "bigint", + "git_branch": { + "name": "git_branch", + "type": "varchar(256)", "primaryKey": false, - "notNull": true, + "notNull": false, "autoincrement": false }, - "updated_at": { - "name": "updated_at", - "type": "bigint", + "git_commit_message": { + "name": "git_commit_message", + "type": "text", "primaryKey": false, "notNull": false, "autoincrement": false - } - }, - "indexes": { - "workspace_idx": { - "name": "workspace_idx", - "columns": ["workspace_id"], - "isUnique": false }, - "project_idx": { - "name": "project_idx", - "columns": ["project_id"], - "isUnique": false - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "rootfs_images_id": { - "name": "rootfs_images_id", - "columns": ["id"] - } - }, - "uniqueConstraints": {} - }, - "builds": { - "name": "builds", - "columns": { - "id": { - "name": "id", + "git_commit_author_name": { + "name": "git_commit_author_name", "type": "varchar(256)", "primaryKey": false, - "notNull": true, + "notNull": false, "autoincrement": false }, - "workspace_id": { - "name": "workspace_id", + "git_commit_author_email": { + "name": "git_commit_author_email", "type": "varchar(256)", "primaryKey": false, - "notNull": true, + "notNull": false, "autoincrement": false }, - "project_id": { - "name": "project_id", + "git_commit_author_username": { + "name": "git_commit_author_username", "type": "varchar(256)", "primaryKey": false, - "notNull": true, + "notNull": false, "autoincrement": false }, - "deployment_id": { - "name": "deployment_id", - "type": "varchar(256)", + "git_commit_author_avatar_url": { + "name": "git_commit_author_avatar_url", + "type": "varchar(512)", "primaryKey": false, - "notNull": true, + "notNull": false, "autoincrement": false }, - "rootfs_image_id": { - "name": "rootfs_image_id", - "type": "varchar(256)", + "git_commit_timestamp": { + "name": "git_commit_timestamp", + "type": "bigint", "primaryKey": false, "notNull": false, "autoincrement": false }, - "git_commit_sha": { - "name": "git_commit_sha", - "type": "varchar(40)", + "runtime_config": { + "name": "runtime_config", + "type": "json", "primaryKey": false, - "notNull": false, + "notNull": true, "autoincrement": false }, - "git_branch": { - "name": "git_branch", - "type": "varchar(256)", + "openapi_spec": { + "name": "openapi_spec", + "type": "text", "primaryKey": false, "notNull": false, "autoincrement": false }, "status": { "name": "status", - "type": "enum('pending','running','succeeded','failed','cancelled')", + "type": "enum('pending','building','deploying','network','ready','failed')", "primaryKey": false, "notNull": true, "autoincrement": false, "default": "'pending'" }, - "build_tool": { - "name": "build_tool", - "type": "enum('docker','depot','custom')", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "'docker'" - }, - "error_message": { - "name": "error_message", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "started_at": { - "name": "started_at", - "type": "bigint", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "completed_at": { - "name": "completed_at", - "type": "bigint", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, "created_at": { "name": "created_at", "type": "bigint", @@ -2250,17 +2155,12 @@ "name": "status_idx", "columns": ["status"], "isUnique": false - }, - "rootfs_image_idx": { - "name": "rootfs_image_idx", - "columns": ["rootfs_image_id"], - "isUnique": false } }, "foreignKeys": {}, "compositePrimaryKeys": { - "builds_id": { - "name": "builds_id", + "deployments_id": { + "name": "deployments_id", "columns": ["id"] } }, @@ -2276,61 +2176,6 @@ "notNull": true, "autoincrement": false }, - "status": { - "name": "status", - "type": "enum('pending','downloading_docker_image','building_rootfs','uploading_rootfs','creating_vm','booting_vm','assigning_domains','completed','failed')", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "message": { - "name": "message", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "error_message": { - "name": "error_message", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "created_at": { - "name": "created_at", - "type": "bigint", - "primaryKey": false, - "notNull": true, - "autoincrement": false - } - }, - "indexes": { - "idx_deployment_id_created_at": { - "name": "idx_deployment_id_created_at", - "columns": ["deployment_id", "created_at"], - "isUnique": false - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "deployment_steps_deployment_id_status_pk": { - "name": "deployment_steps_deployment_id_status_pk", - "columns": ["deployment_id", "status"] - } - }, - "uniqueConstraints": {} - }, - "deployments": { - "name": "deployments", - "columns": { - "id": { - "name": "id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, "workspace_id": { "name": "workspace_id", "type": "varchar(256)", @@ -2345,111 +2190,34 @@ "notNull": true, "autoincrement": false }, - "environment": { - "name": "environment", - "type": "enum('production','preview')", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "'preview'" - }, - "build_id": { - "name": "build_id", - "type": "varchar(256)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "rootfs_image_id": { - "name": "rootfs_image_id", - "type": "varchar(256)", + "status": { + "name": "status", + "type": "enum('pending','downloading_docker_image','building_rootfs','uploading_rootfs','creating_vm','booting_vm','assigning_domains','completed','failed')", "primaryKey": false, "notNull": true, "autoincrement": false }, - "git_commit_sha": { - "name": "git_commit_sha", - "type": "varchar(40)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "git_branch": { - "name": "git_branch", - "type": "varchar(256)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "config_snapshot": { - "name": "config_snapshot", - "type": "json", + "message": { + "name": "message", + "type": "varchar(1024)", "primaryKey": false, "notNull": true, "autoincrement": false }, - "openapi_spec": { - "name": "openapi_spec", - "type": "text", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "status": { - "name": "status", - "type": "enum('pending','building','deploying','active','failed','archived')", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "'pending'" - }, "created_at": { "name": "created_at", "type": "bigint", "primaryKey": false, "notNull": true, "autoincrement": false - }, - "updated_at": { - "name": "updated_at", - "type": "bigint", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "workspace_idx": { - "name": "workspace_idx", - "columns": ["workspace_id"], - "isUnique": false - }, - "project_idx": { - "name": "project_idx", - "columns": ["project_id"], - "isUnique": false - }, - "environment_idx": { - "name": "environment_idx", - "columns": ["environment"], - "isUnique": false - }, - "status_idx": { - "name": "status_idx", - "columns": ["status"], - "isUnique": false - }, - "rootfs_image_idx": { - "name": "rootfs_image_idx", - "columns": ["rootfs_image_id"], - "isUnique": false } }, + "indexes": {}, "foreignKeys": {}, "compositePrimaryKeys": { - "deployments_id": { - "name": "deployments_id", - "columns": ["id"] + "deployment_steps_deployment_id_status_pk": { + "name": "deployment_steps_deployment_id_status_pk", + "columns": ["deployment_id", "status"] } }, "uniqueConstraints": {} @@ -2516,8 +2284,8 @@ }, "uniqueConstraints": {} }, - "hostname_routes": { - "name": "hostname_routes", + "domains": { + "name": "domains", "columns": { "id": { "name": "id", @@ -2537,30 +2305,29 @@ "name": "project_id", "type": "varchar(256)", "primaryKey": false, - "notNull": true, + "notNull": false, "autoincrement": false }, - "hostname": { - "name": "hostname", + "deployment_id": { + "name": "deployment_id", "type": "varchar(256)", "primaryKey": false, - "notNull": true, + "notNull": false, "autoincrement": false }, - "deployment_id": { - "name": "deployment_id", + "domain": { + "name": "domain", "type": "varchar(256)", "primaryKey": false, "notNull": true, "autoincrement": false }, - "is_enabled": { - "name": "is_enabled", - "type": "boolean", + "type": { + "name": "type", + "type": "enum('custom','wildcard')", "primaryKey": false, "notNull": true, - "autoincrement": false, - "default": true + "autoincrement": false }, "created_at": { "name": "created_at", @@ -2587,29 +2354,19 @@ "name": "project_idx", "columns": ["project_id"], "isUnique": false - }, - "hostname_idx": { - "name": "hostname_idx", - "columns": ["hostname"], - "isUnique": true - }, - "deployment_idx": { - "name": "deployment_idx", - "columns": ["deployment_id"], - "isUnique": false } }, "foreignKeys": {}, "compositePrimaryKeys": { - "hostname_routes_id": { - "name": "hostname_routes_id", + "domains_id": { + "name": "domains_id", "columns": ["id"] } }, "uniqueConstraints": {} }, - "domain_challenges": { - "name": "domain_challenges", + "acme_challenges": { + "name": "acme_challenges", "columns": { "id": { "name": "id", @@ -2620,135 +2377,51 @@ }, "workspace_id": { "name": "workspace_id", - "type": "varchar(255)", + "type": "varchar(256)", "primaryKey": false, "notNull": true, "autoincrement": false }, "domain_id": { "name": "domain_id", - "type": "varchar(255)", + "type": "varchar(256)", "primaryKey": false, "notNull": true, "autoincrement": false }, "token": { "name": "token", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "authorization": { - "name": "authorization", - "type": "varchar(255)", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "status": { - "name": "status", - "type": "enum('waiting','pending','verified','failed','expired')", + "type": "varchar(256)", "primaryKey": false, "notNull": true, - "autoincrement": false, - "default": "'pending'" + "autoincrement": false }, "type": { "name": "type", - "type": "enum('http-01','dns-01','tls-alpn-01')", - "primaryKey": false, - "notNull": true, - "autoincrement": false, - "default": "'http-01'" - }, - "created_at": { - "name": "created_at", - "type": "bigint", + "type": "enum('HTTP-01','DNS-01')", "primaryKey": false, "notNull": true, "autoincrement": false }, - "updated_at": { - "name": "updated_at", - "type": "bigint", - "primaryKey": false, - "notNull": false, - "autoincrement": false - }, - "expires_at": { - "name": "expires_at", - "type": "bigint unsigned", - "primaryKey": false, - "notNull": false, - "autoincrement": false - } - }, - "indexes": { - "domainIdWorkspaceId_idx": { - "name": "domainIdWorkspaceId_idx", - "columns": ["domain_id", "workspace_id"], - "isUnique": true - }, - "domain_status_idx": { - "name": "domain_status_idx", - "columns": ["status"], - "isUnique": false - } - }, - "foreignKeys": {}, - "compositePrimaryKeys": { - "domain_challenges_id": { - "name": "domain_challenges_id", - "columns": ["id"] - } - }, - "uniqueConstraints": {} - }, - "domains": { - "name": "domains", - "columns": { - "id": { - "name": "id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "workspace_id": { - "name": "workspace_id", - "type": "varchar(255)", - "primaryKey": false, - "notNull": true, - "autoincrement": false - }, - "project_id": { - "name": "project_id", - "type": "varchar(255)", + "authorization": { + "name": "authorization", + "type": "varchar(256)", "primaryKey": false, "notNull": true, "autoincrement": false }, - "domain": { - "name": "domain", - "type": "varchar(255)", + "status": { + "name": "status", + "type": "enum('waiting','pending','verified','failed')", "primaryKey": false, "notNull": true, "autoincrement": false }, - "type": { - "name": "type", - "type": "enum('custom','generated')", + "expires_at": { + "name": "expires_at", + "type": "bigint", "primaryKey": false, "notNull": true, - "autoincrement": false, - "default": "'generated'" - }, - "subdomain_config": { - "name": "subdomain_config", - "type": "json", - "primaryKey": false, - "notNull": false, "autoincrement": false }, "created_at": { @@ -2771,22 +2444,12 @@ "name": "workspace_idx", "columns": ["workspace_id"], "isUnique": false - }, - "project_idx": { - "name": "project_idx", - "columns": ["project_id"], - "isUnique": false - }, - "domain_idx": { - "name": "domain_idx", - "columns": ["domain"], - "isUnique": true } }, "foreignKeys": {}, "compositePrimaryKeys": { - "domains_id": { - "name": "domains_id", + "acme_challenges_id": { + "name": "acme_challenges_id", "columns": ["id"] } }, diff --git a/internal/db/drizzle/meta/_journal.json b/internal/db/drizzle/meta/_journal.json index e1a1974c00..c0a76867b9 100644 --- a/internal/db/drizzle/meta/_journal.json +++ b/internal/db/drizzle/meta/_journal.json @@ -5,8 +5,8 @@ { "idx": 0, "version": "5", - "when": 1756367347372, - "tag": "0000_amused_havok", + "when": 1756627798938, + "tag": "0000_useful_nextwave", "breakpoints": true } ] diff --git a/internal/db/src/schema/acme_challenges.ts b/internal/db/src/schema/acme_challenges.ts new file mode 100644 index 0000000000..9432a06a23 --- /dev/null +++ b/internal/db/src/schema/acme_challenges.ts @@ -0,0 +1,35 @@ +import { relations } from "drizzle-orm"; +import { bigint, index, mysqlEnum, mysqlTable, varchar } from "drizzle-orm/mysql-core"; +import { domains } from "./domains"; +import { lifecycleDates } from "./util/lifecycle_dates"; +import { workspaces } from "./workspaces"; + +export const acmeChallenges = mysqlTable( + "acme_challenges", + { + id: bigint("id", { mode: "number", unsigned: true }).autoincrement().primaryKey(), + workspaceId: varchar("workspace_id", { length: 256 }).notNull(), + domainId: varchar("domain_id", { length: 256 }).notNull(), + token: varchar("token", { length: 256 }).notNull(), + type: mysqlEnum("type", ["HTTP-01", "DNS-01"]).notNull(), + authorization: varchar("authorization", { length: 256 }).notNull(), + status: mysqlEnum("status", ["waiting", "pending", "verified", "failed"]).notNull(), + expiresAt: bigint("expires_at", { mode: "number" }).notNull(), + + ...lifecycleDates, + }, + (table) => ({ + workspaceIdx: index("workspace_idx").on(table.workspaceId), + }), +); + +export const acmeChallengeRelations = relations(acmeChallenges, ({ one }) => ({ + workspace: one(workspaces, { + fields: [acmeChallenges.workspaceId], + references: [workspaces.id], + }), + domain: one(domains, { + fields: [acmeChallenges.domainId], + references: [domains.id], + }), +})); diff --git a/internal/db/src/schema/builds.ts b/internal/db/src/schema/builds.ts deleted file mode 100644 index fd21377927..0000000000 --- a/internal/db/src/schema/builds.ts +++ /dev/null @@ -1,105 +0,0 @@ -import { relations } from "drizzle-orm"; -import { - bigint, - index, - mysqlEnum, - mysqlTable, - primaryKey, - text, - varchar, -} from "drizzle-orm/mysql-core"; -import { deployments } from "./deployments"; -import { projects } from "./projects"; -import { rootfsImages } from "./rootfs_images"; -import { lifecycleDates } from "./util/lifecycle_dates"; -import { workspaces } from "./workspaces"; -export const builds = mysqlTable( - "builds", - { - id: varchar("id", { length: 256 }).primaryKey(), - workspaceId: varchar("workspace_id", { length: 256 }).notNull(), - projectId: varchar("project_id", { length: 256 }).notNull(), - deploymentId: varchar("deployment_id", { length: 256 }).notNull(), - - // Build result - rootfsImageId: varchar("rootfs_image_id", { length: 256 }), // Null until build completes - - // Git information - gitCommitSha: varchar("git_commit_sha", { length: 40 }), - gitBranch: varchar("git_branch", { length: 256 }), - - // Build status - status: mysqlEnum("status", ["pending", "running", "succeeded", "failed", "cancelled"]) - .notNull() - .default("pending"), - - // Build configuration - buildTool: mysqlEnum("build_tool", ["docker", "depot", "custom"]).notNull().default("docker"), - - // Error tracking - errorMessage: text("error_message"), - - // Timing - startedAt: bigint("started_at", { mode: "number" }), - completedAt: bigint("completed_at", { mode: "number" }), - - ...lifecycleDates, - }, - (table) => ({ - workspaceIdx: index("workspace_idx").on(table.workspaceId), - projectIdx: index("project_idx").on(table.projectId), - statusIdx: index("status_idx").on(table.status), - rootfsImageIdx: index("rootfs_image_idx").on(table.rootfsImageId), - }), -); - -export const deploymentSteps = mysqlTable( - "deployment_steps", - { - deploymentId: varchar("deployment_id", { length: 256 }).notNull(), - status: mysqlEnum("status", [ - "pending", - "downloading_docker_image", - "building_rootfs", - "uploading_rootfs", - "creating_vm", - "booting_vm", - "assigning_domains", - "completed", - "failed", - ]).notNull(), - message: text("message"), - errorMessage: text("error_message"), - createdAt: bigint("created_at", { mode: "number" }).notNull(), - }, - (table) => ({ - pk: primaryKey({ columns: [table.deploymentId, table.status] }), - deploymentIdCreatedAtIdx: index("idx_deployment_id_created_at").on( - table.deploymentId, - table.createdAt, - ), - }), -); - -export const buildsRelations = relations(builds, ({ one }) => ({ - workspace: one(workspaces, { - fields: [builds.workspaceId], - references: [workspaces.id], - }), - project: one(projects, { - fields: [builds.projectId], - references: [projects.id], - }), - rootfsImage: one(rootfsImages, { - fields: [builds.rootfsImageId], - references: [rootfsImages.id], - }), - deployment: one(deployments), -})); - -export const deploymentStepsRelations = relations(deploymentSteps, ({ one }) => ({ - deployment: one(deployments, { - fields: [deploymentSteps.deploymentId], - references: [deployments.id], - }), -})); diff --git a/internal/db/src/schema/deployment_steps.ts b/internal/db/src/schema/deployment_steps.ts new file mode 100644 index 0000000000..831f69268c --- /dev/null +++ b/internal/db/src/schema/deployment_steps.ts @@ -0,0 +1,38 @@ +import { relations } from "drizzle-orm"; +import { bigint, mysqlEnum, mysqlTable, primaryKey, varchar } from "drizzle-orm/mysql-core"; +import { deployments } from "./deployments"; + +export const deploymentSteps = mysqlTable( + "deployment_steps", + { + deploymentId: varchar("deployment_id", { length: 256 }).notNull(), + workspaceId: varchar("workspace_id", { length: 256 }).notNull(), + projectId: varchar("project_id", { length: 256 }).notNull(), + + status: mysqlEnum("status", [ + "pending", + "downloading_docker_image", + "building_rootfs", + "uploading_rootfs", + "creating_vm", + "booting_vm", + "assigning_domains", + "completed", + "failed", + ]).notNull(), + message: varchar("message", { length: 1024 }).notNull(), + createdAt: bigint("created_at", { mode: "number" }).notNull(), + }, + (table) => ({ + pk: primaryKey({ columns: [table.deploymentId, table.status] }), + }), +); + +export const deploymentStepsRelations = relations(deploymentSteps, ({ one }) => ({ + deployment: one(deployments, { + fields: [deploymentSteps.deploymentId], + references: [deployments.id], + }), + // routes: many(routes), + // hostnames: many(hostnames), +})); diff --git a/internal/db/src/schema/deployments.ts b/internal/db/src/schema/deployments.ts index 0f366fbd00..4cd6b3ff79 100644 --- a/internal/db/src/schema/deployments.ts +++ b/internal/db/src/schema/deployments.ts @@ -1,8 +1,9 @@ import { relations } from "drizzle-orm"; import { bigint, index, json, mysqlEnum, mysqlTable, text, varchar } from "drizzle-orm/mysql-core"; -import { builds } from "./builds"; +import { deploymentSteps } from "./deployment_steps"; +import { environments } from "./environments"; import { projects } from "./projects"; -import { rootfsImages } from "./rootfs_images"; +import { lifecycleDates } from "./util/lifecycle_dates"; import { workspaces } from "./workspaces"; export const deployments = mysqlTable( @@ -13,11 +14,7 @@ export const deployments = mysqlTable( projectId: varchar("project_id", { length: 256 }).notNull(), // Environment configuration (production, preview, etc.) - environment: mysqlEnum("environment", ["production", "preview"]).notNull().default("preview"), - - // Build information - buildId: varchar("build_id", { length: 256 }), - rootfsImageId: varchar("rootfs_image_id", { length: 256 }).notNull(), + environmentId: varchar("environment_id", { length: 256 }).notNull(), // Git information gitCommitSha: varchar("git_commit_sha", { length: 40 }), @@ -30,12 +27,11 @@ export const deployments = mysqlTable( gitCommitTimestamp: bigint("git_commit_timestamp", { mode: "number" }), // Unix epoch milliseconds // Immutable configuration snapshot - configSnapshot: json("config_snapshot") + runtimeConfig: json("runtime_config") .$type<{ - // Resolved environment variables - envVariables: Record; - // Any other configuration captured at version creation - metadata?: Record; + regions: Array<{ region: string; vmCount: number }>; + cpus: number; + memory: number; }>() .notNull(), @@ -43,46 +39,31 @@ export const deployments = mysqlTable( openapiSpec: text("openapi_spec"), // Deployment status - status: mysqlEnum("status", [ - "pending", - "building", - "deploying", - "active", - "failed", - "archived", - ]) + status: mysqlEnum("status", ["pending", "building", "deploying", "network", "ready", "failed"]) .notNull() .default("pending"), - - createdAt: bigint("created_at", { mode: "number" }).notNull(), - updatedAt: bigint("updated_at", { mode: "number" }), + ...lifecycleDates, }, (table) => ({ workspaceIdx: index("workspace_idx").on(table.workspaceId), projectIdx: index("project_idx").on(table.projectId), - environmentIdx: index("environment_idx").on(table.environment), statusIdx: index("status_idx").on(table.status), - rootfsImageIdx: index("rootfs_image_idx").on(table.rootfsImageId), }), ); -export const deploymentsRelations = relations(deployments, ({ one }) => ({ +export const deploymentsRelations = relations(deployments, ({ one, many }) => ({ workspace: one(workspaces, { fields: [deployments.workspaceId], references: [workspaces.id], }), + environment: one(environments, { + fields: [deployments.environmentId], + references: [environments.id], + }), project: one(projects, { fields: [deployments.projectId], references: [projects.id], }), - build: one(builds, { - fields: [deployments.buildId], - references: [builds.id], - }), - rootfsImage: one(rootfsImages, { - fields: [deployments.rootfsImageId], - references: [rootfsImages.id], - }), - // routes: many(routes), - // hostnames: many(hostnames), + + steps: many(deploymentSteps), })); diff --git a/internal/db/src/schema/domains.ts b/internal/db/src/schema/domains.ts index 1a9c54f88d..bdeb50cb59 100644 --- a/internal/db/src/schema/domains.ts +++ b/internal/db/src/schema/domains.ts @@ -1,78 +1,20 @@ -import { relations } from "drizzle-orm"; -import { - bigint, - index, - json, - mysqlEnum, - mysqlTable, - uniqueIndex, - varchar, -} from "drizzle-orm/mysql-core"; +import { index, mysqlEnum, mysqlTable, varchar } from "drizzle-orm/mysql-core"; import { lifecycleDates } from "./util/lifecycle_dates"; export const domains = mysqlTable( "domains", { - id: varchar("id", { length: 255 }).primaryKey(), - - workspaceId: varchar("workspace_id", { length: 255 }).notNull(), - - projectId: varchar("project_id", { length: 255 }).notNull(), - - // Domain information - domain: varchar("domain", { length: 255 }).notNull(), - - type: mysqlEnum("type", ["custom", "generated"]).notNull().default("generated"), - - // Auto-generated subdomain configuration - subdomainConfig: json("subdomain_config").$type<{ - // For *.unkey.app subdomains - prefix?: string; // commit-hash, branch-name, etc. - type?: "commit" | "branch" | "version" | "custom"; - autoUpdate?: boolean; // Whether to update when new versions are created - }>(), + id: varchar("id", { length: 256 }).primaryKey(), + workspaceId: varchar("workspace_id", { length: 256 }).notNull(), + projectId: varchar("project_id", { length: 256 }), + deploymentId: varchar("deployment_id", { length: 256 }), + domain: varchar("domain", { length: 256 }).notNull(), + type: mysqlEnum("type", ["custom", "wildcard"]).notNull(), ...lifecycleDates, }, (table) => ({ workspaceIdx: index("workspace_idx").on(table.workspaceId), projectIdx: index("project_idx").on(table.projectId), - domainIdx: uniqueIndex("domain_idx").on(table.domain), }), ); - -export const domainChallenges = mysqlTable( - "domain_challenges", - { - id: bigint("id", { mode: "number", unsigned: true }).primaryKey().autoincrement(), - workspaceId: varchar("workspace_id", { length: 255 }).notNull(), - domainId: varchar("domain_id", { length: 255 }).notNull(), - token: varchar("token", { length: 255 }), - authorization: varchar("authorization", { length: 255 }), - // waiting mean's we haven't picked it up yet and it's not started - status: mysqlEnum("status", ["waiting", "pending", "verified", "failed", "expired"]) - .notNull() - .default("pending"), - type: mysqlEnum("type", ["http-01", "dns-01", "tls-alpn-01"]).notNull().default("http-01"), - ...lifecycleDates, - expiresAt: bigint("expires_at", { - mode: "number", - unsigned: true, - }), - }, - (table) => ({ - domainIdWorkspaceIdIdx: uniqueIndex("domainIdWorkspaceId_idx").on( - table.domainId, - table.workspaceId, - ), - domainStatus: index("domain_status_idx").on(table.status), - }), -); - -export const domainRelations = relations(domains, () => ({ - // Relations defined but no foreign keys enforced - // workspace: one(workspaces), - // project: one(projects), - // certificate: one(certificates), - // route: one(routes), -})); diff --git a/internal/db/src/schema/environment_variables.ts b/internal/db/src/schema/environment_variables.ts new file mode 100644 index 0000000000..c1500f393b --- /dev/null +++ b/internal/db/src/schema/environment_variables.ts @@ -0,0 +1,39 @@ +import { relations } from "drizzle-orm"; +import { mysqlEnum, mysqlTable, uniqueIndex, varchar } from "drizzle-orm/mysql-core"; +import { deleteProtection } from "./util/delete_protection"; +import { lifecycleDates } from "./util/lifecycle_dates"; +import { workspaces } from "./workspaces"; + +import { environments } from "./environments"; +export const environmentVariables = mysqlTable( + "environment_variables", + { + id: varchar("id", { length: 256 }).primaryKey(), + workspaceId: varchar("workspace_id", { length: 256 }).notNull(), + environmentId: varchar("environment_id", { length: 256 }).notNull(), + + key: varchar("key", { length: 256 }).notNull(), + // Either the plaintext value or a vault encrypted response + value: varchar("value", { length: 1024 }).notNull(), + type: mysqlEnum("type", ["plaintext", "secret"]).notNull(), + + description: varchar("description", { length: 255 }), + + ...deleteProtection, + ...lifecycleDates, + }, + (table) => ({ + uniqueKey: uniqueIndex("environment_id_key").on(table.environmentId, table.key), + }), +); + +export const environmentVariablesRelations = relations(environmentVariables, ({ one }) => ({ + workspace: one(workspaces, { + fields: [environmentVariables.workspaceId], + references: [workspaces.id], + }), + project: one(environments, { + fields: [environmentVariables.environmentId], + references: [environments.id], + }), +})); diff --git a/internal/db/src/schema/environments.ts b/internal/db/src/schema/environments.ts new file mode 100644 index 0000000000..8a5766be05 --- /dev/null +++ b/internal/db/src/schema/environments.ts @@ -0,0 +1,35 @@ +import { relations } from "drizzle-orm"; +import { mysqlTable, uniqueIndex, varchar } from "drizzle-orm/mysql-core"; +import { deleteProtection } from "./util/delete_protection"; +import { lifecycleDates } from "./util/lifecycle_dates"; +import { workspaces } from "./workspaces"; + +import { projects } from "./projects"; +export const environments = mysqlTable( + "environments", + { + id: varchar("id", { length: 256 }).primaryKey(), + workspaceId: varchar("workspace_id", { length: 256 }).notNull(), + projectId: varchar("project_id", { length: 256 }).notNull(), + + slug: varchar("slug", { length: 256 }).notNull(), // URL-safe identifier within workspace + description: varchar("description", { length: 255 }), + + ...deleteProtection, + ...lifecycleDates, + }, + (table) => ({ + uniqueSlug: uniqueIndex("environments_workspace_id_slug_idx").on(table.workspaceId, table.slug), + }), +); + +export const environmentsRelations = relations(environments, ({ one }) => ({ + workspace: one(workspaces, { + fields: [environments.workspaceId], + references: [workspaces.id], + }), + project: one(projects, { + fields: [environments.projectId], + references: [projects.id], + }), +})); diff --git a/internal/db/src/schema/index.ts b/internal/db/src/schema/index.ts index 3b40d057af..f2f2c451ea 100644 --- a/internal/db/src/schema/index.ts +++ b/internal/db/src/schema/index.ts @@ -9,15 +9,13 @@ export * from "./key_migrations"; export * from "./identity"; export * from "./quota"; export * from "./audit_logs"; +export * from "./environments"; // Deployment platform tables -export * from "./partitions"; export * from "./projects"; -export * from "./rootfs_images"; -export * from "./builds"; export * from "./deployments"; +export * from "./deployment_steps"; export * from "./acme_users"; -// Routing and traffic management -export * from "./routes"; export * from "./domains"; +export * from "./acme_challenges"; diff --git a/internal/db/src/schema/partitions.ts b/internal/db/src/schema/partitions.ts deleted file mode 100644 index a7035e94c6..0000000000 --- a/internal/db/src/schema/partitions.ts +++ /dev/null @@ -1,36 +0,0 @@ -import { relations } from "drizzle-orm"; -import { index, mysqlEnum, mysqlTable, text, varchar } from "drizzle-orm/mysql-core"; -import { deleteProtection } from "./util/delete_protection"; -import { lifecycleDates } from "./util/lifecycle_dates"; - -export const partitions = mysqlTable( - "partitions", - { - id: varchar("id", { length: 256 }).primaryKey(), - name: varchar("name", { length: 256 }).notNull(), - description: text("description"), - - // AWS account information - awsAccountId: varchar("aws_account_id", { length: 256 }).notNull(), - region: varchar("region", { length: 256 }).notNull(), // Primary AWS region - - // ips from global accelerator - ipV4Address: varchar("ip_v4_address", { length: 15 }), - ipV6Address: varchar("ip_v6_address", { length: 39 }), - - // Status management - status: mysqlEnum("status", ["active", "draining", "inactive"]).notNull().default("active"), - - ...deleteProtection, - ...lifecycleDates, - }, - (table) => ({ - statusIdx: index("status_idx").on(table.status), - }), -); - -export const partitionsRelations = relations(partitions, () => ({ - // workspaces: many(workspaces), // We'll add this after updating workspaces table - // metalHosts: many(metalHosts), - // regions: many(regions), -})); diff --git a/internal/db/src/schema/projects.ts b/internal/db/src/schema/projects.ts index c2d1eae13d..70447eeacf 100644 --- a/internal/db/src/schema/projects.ts +++ b/internal/db/src/schema/projects.ts @@ -5,13 +5,11 @@ import { lifecycleDates } from "./util/lifecycle_dates"; import { workspaces } from "./workspaces"; import { deployments } from "./deployments"; -import { partitions } from "./partitions"; export const projects = mysqlTable( "projects", { id: varchar("id", { length: 256 }).primaryKey(), workspaceId: varchar("workspace_id", { length: 256 }).notNull(), - partitionId: varchar("partition_id", { length: 256 }).notNull(), name: varchar("name", { length: 256 }).notNull(), slug: varchar("slug", { length: 256 }).notNull(), // URL-safe identifier within workspace @@ -25,7 +23,6 @@ export const projects = mysqlTable( }, (table) => ({ workspaceIdx: index("workspace_idx").on(table.workspaceId), - partitionIdx: index("partition_idx").on(table.partitionId), workspaceSlugIdx: uniqueIndex("workspace_slug_idx").on(table.workspaceId, table.slug), }), ); @@ -35,10 +32,6 @@ export const projectsRelations = relations(projects, ({ one, many }) => ({ fields: [projects.workspaceId], references: [workspaces.id], }), - partition: one(partitions, { - fields: [projects.partitionId], - references: [partitions.id], - }), deployments: many(deployments), // environments: many(projectEnvironments), })); diff --git a/internal/db/src/schema/rootfs_images.ts b/internal/db/src/schema/rootfs_images.ts deleted file mode 100644 index c977296093..0000000000 --- a/internal/db/src/schema/rootfs_images.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { relations } from "drizzle-orm"; -import { bigint, index, mysqlTable, varchar } from "drizzle-orm/mysql-core"; -import { projects } from "./projects"; -import { lifecycleDates } from "./util/lifecycle_dates"; -import { workspaces } from "./workspaces"; - -export const rootfsImages = mysqlTable( - "rootfs_images", - { - id: varchar("id", { length: 256 }).primaryKey(), - workspaceId: varchar("workspace_id", { length: 256 }).notNull(), - projectId: varchar("project_id", { length: 256 }).notNull(), - - // S3 storage location - // S3 key is just the rootfs image ID - s3Bucket: varchar("s3_bucket", { length: 256 }).notNull(), - s3Key: varchar("s3_key", { length: 500 }).notNull(), - - // Metadata - sizeBytes: bigint("size_bytes", { mode: "number" }).notNull(), - - ...lifecycleDates, - }, - (table) => ({ - workspaceIdx: index("workspace_idx").on(table.workspaceId), - projectIdx: index("project_idx").on(table.projectId), - }), -); - -export const rootfsImagesRelations = relations(rootfsImages, ({ one }) => ({ - workspace: one(workspaces, { - fields: [rootfsImages.workspaceId], - references: [workspaces.id], - }), - project: one(projects, { - fields: [rootfsImages.projectId], - references: [projects.id], - }), - // builds: many(builds), - // versions: many(versions), -})); diff --git a/internal/db/src/schema/workspaces.ts b/internal/db/src/schema/workspaces.ts index 12945a42a7..9bcc384f66 100644 --- a/internal/db/src/schema/workspaces.ts +++ b/internal/db/src/schema/workspaces.ts @@ -2,11 +2,9 @@ import type { Subscriptions } from "@unkey/billing"; import { relations } from "drizzle-orm"; import { boolean, json, mysqlEnum, mysqlTable, varchar } from "drizzle-orm/mysql-core"; import { apis } from "./apis"; -import { deployments } from "./deployments"; import { identities } from "./identity"; import { keyAuth } from "./keyAuth"; import { keys } from "./keys"; -import { partitions } from "./partitions"; import { projects } from "./projects"; import { quotas } from "./quota"; import { ratelimitNamespaces } from "./ratelimit"; @@ -120,11 +118,5 @@ export const workspacesRelations = relations(workspaces, ({ many, one }) => ({ identities: many(identities), quotas: one(quotas), - // Deployment platform relations (no foreign keys enforced) - partition: one(partitions), projects: many(projects), - // environments: many(environments), - deployments: many(deployments), - // hostnames: many(hostnames), - // certificates: many(certificates), })); diff --git a/internal/id/src/generate.ts b/internal/id/src/generate.ts index a21498d1bf..7b6e1e3c2b 100644 --- a/internal/id/src/generate.ts +++ b/internal/id/src/generate.ts @@ -28,6 +28,7 @@ const prefixes = { auditLogBucket: "buk", auditLog: "log", fake: "fake", + environment: "env", project: "proj", } as const; diff --git a/internal/schema/src/auditlog.ts b/internal/schema/src/auditlog.ts index dfa867b3ee..8117e2e133 100644 --- a/internal/schema/src/auditlog.ts +++ b/internal/schema/src/auditlog.ts @@ -54,6 +54,7 @@ export const unkeyAuditLogEvents = z.enum([ "ratelimit.delete_override", "auditLogBucket.create", "project.create", + "environment.create", ]); export const auditLogSchemaV1 = z.object({