mirror of
https://github.com/Dvorinka/Containr.git
synced 2026-10-28 07:41:27 +00:00
Backend: - GET /services/:id/metrics with real Docker container stats - DELETE /git/providers/:id and GET repo branches endpoint Frontend: - Service detail shows real telemetry or honest empty states - Live status distinguishes idle/polling/reconnecting - Git providers section in Settings; repo+branch pickers in Add Service - Real logo, compact Projects header, canvas fitView fix - index.css deduplicated (1725 -> 1384 lines) - Fixed smoke tests, lint errors, ToastProvider/context unification Repo hygiene: - Added LICENSE (MIT), CONTRIBUTING.md, SECURITY.md; rewrote README - Untracked .env.prod and data/letsencrypt secrets; fixed .gitignore - Removed legacy root src/internal/cmd and stale configs/docs/artifacts - Moved guides and design references under docs/ Generated with [Devin](https://devin.ai) Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
274 lines
6.4 KiB
Go
274 lines
6.4 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.27.0
|
|
// source: templates.sql
|
|
|
|
package sqlcdb
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
|
|
"github.com/google/uuid"
|
|
)
|
|
|
|
const countServicesByProjectAndName = `-- name: CountServicesByProjectAndName :one
|
|
SELECT COUNT(*)
|
|
FROM services
|
|
WHERE project_id = $1 AND name = $2
|
|
`
|
|
|
|
type CountServicesByProjectAndNameParams struct {
|
|
ProjectID uuid.UUID `json:"project_id"`
|
|
Name string `json:"name"`
|
|
}
|
|
|
|
func (q *Queries) CountServicesByProjectAndName(ctx context.Context, arg CountServicesByProjectAndNameParams) (int64, error) {
|
|
row := q.db.QueryRowContext(ctx, countServicesByProjectAndName, arg.ProjectID, arg.Name)
|
|
var count int64
|
|
err := row.Scan(&count)
|
|
return count, err
|
|
}
|
|
|
|
const createServiceFromTemplate = `-- name: CreateServiceFromTemplate :exec
|
|
INSERT INTO services (
|
|
id,
|
|
project_id,
|
|
name,
|
|
environment_id,
|
|
service_type,
|
|
source_type,
|
|
source_url,
|
|
image_name,
|
|
build_command,
|
|
start_command,
|
|
type,
|
|
status,
|
|
image,
|
|
command,
|
|
environment,
|
|
cpu,
|
|
memory,
|
|
created_at,
|
|
updated_at
|
|
)
|
|
VALUES (
|
|
$1,
|
|
$2,
|
|
$3,
|
|
$4,
|
|
$5,
|
|
$6,
|
|
$7,
|
|
$8,
|
|
$9,
|
|
$10,
|
|
$11,
|
|
$12,
|
|
$13,
|
|
$14,
|
|
$15,
|
|
$16,
|
|
$17,
|
|
$18,
|
|
$19
|
|
)
|
|
`
|
|
|
|
type CreateServiceFromTemplateParams struct {
|
|
ID uuid.UUID `json:"id"`
|
|
ProjectID uuid.UUID `json:"project_id"`
|
|
Name string `json:"name"`
|
|
EnvironmentID uuid.UUID `json:"environment_id"`
|
|
ServiceType string `json:"service_type"`
|
|
SourceType string `json:"source_type"`
|
|
SourceUrl sql.NullString `json:"source_url"`
|
|
ImageName sql.NullString `json:"image_name"`
|
|
BuildCommand sql.NullString `json:"build_command"`
|
|
StartCommand sql.NullString `json:"start_command"`
|
|
Type string `json:"type"`
|
|
Status string `json:"status"`
|
|
Image sql.NullString `json:"image"`
|
|
Command sql.NullString `json:"command"`
|
|
Environment sql.NullString `json:"environment"`
|
|
Cpu sql.NullString `json:"cpu"`
|
|
Memory sql.NullString `json:"memory"`
|
|
CreatedAt sql.NullTime `json:"created_at"`
|
|
UpdatedAt sql.NullTime `json:"updated_at"`
|
|
}
|
|
|
|
func (q *Queries) CreateServiceFromTemplate(ctx context.Context, arg CreateServiceFromTemplateParams) error {
|
|
_, err := q.db.ExecContext(ctx, createServiceFromTemplate,
|
|
arg.ID,
|
|
arg.ProjectID,
|
|
arg.Name,
|
|
arg.EnvironmentID,
|
|
arg.ServiceType,
|
|
arg.SourceType,
|
|
arg.SourceUrl,
|
|
arg.ImageName,
|
|
arg.BuildCommand,
|
|
arg.StartCommand,
|
|
arg.Type,
|
|
arg.Status,
|
|
arg.Image,
|
|
arg.Command,
|
|
arg.Environment,
|
|
arg.Cpu,
|
|
arg.Memory,
|
|
arg.CreatedAt,
|
|
arg.UpdatedAt,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const getProjectOwnerID = `-- name: GetProjectOwnerID :one
|
|
SELECT owner_id
|
|
FROM projects
|
|
WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) GetProjectOwnerID(ctx context.Context, id uuid.UUID) (uuid.UUID, error) {
|
|
row := q.db.QueryRowContext(ctx, getProjectOwnerID, id)
|
|
var owner_id uuid.UUID
|
|
err := row.Scan(&owner_id)
|
|
return owner_id, err
|
|
}
|
|
|
|
const getServiceTemplateByID = `-- name: GetServiceTemplateByID :one
|
|
SELECT id, name, description, category, logo, config, variables, is_official, created_at, updated_at
|
|
FROM service_templates
|
|
WHERE id = $1
|
|
`
|
|
|
|
func (q *Queries) GetServiceTemplateByID(ctx context.Context, id string) (ServiceTemplate, error) {
|
|
row := q.db.QueryRowContext(ctx, getServiceTemplateByID, id)
|
|
var i ServiceTemplate
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.Name,
|
|
&i.Description,
|
|
&i.Category,
|
|
&i.Logo,
|
|
&i.Config,
|
|
&i.Variables,
|
|
&i.IsOfficial,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const listServiceTemplates = `-- name: ListServiceTemplates :many
|
|
SELECT id, name, description, category, logo, config, variables, is_official, created_at, updated_at
|
|
FROM service_templates
|
|
ORDER BY is_official DESC, name ASC
|
|
`
|
|
|
|
func (q *Queries) ListServiceTemplates(ctx context.Context) ([]ServiceTemplate, error) {
|
|
rows, err := q.db.QueryContext(ctx, listServiceTemplates)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
items := []ServiceTemplate{}
|
|
for rows.Next() {
|
|
var i ServiceTemplate
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.Name,
|
|
&i.Description,
|
|
&i.Category,
|
|
&i.Logo,
|
|
&i.Config,
|
|
&i.Variables,
|
|
&i.IsOfficial,
|
|
&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
|
|
}
|
|
|
|
const listServiceTemplatesByCategory = `-- name: ListServiceTemplatesByCategory :many
|
|
SELECT id, name, description, category, logo, config, variables, is_official, created_at, updated_at
|
|
FROM service_templates
|
|
WHERE category = $1
|
|
ORDER BY is_official DESC, name ASC
|
|
`
|
|
|
|
func (q *Queries) ListServiceTemplatesByCategory(ctx context.Context, category string) ([]ServiceTemplate, error) {
|
|
rows, err := q.db.QueryContext(ctx, listServiceTemplatesByCategory, category)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
items := []ServiceTemplate{}
|
|
for rows.Next() {
|
|
var i ServiceTemplate
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.Name,
|
|
&i.Description,
|
|
&i.Category,
|
|
&i.Logo,
|
|
&i.Config,
|
|
&i.Variables,
|
|
&i.IsOfficial,
|
|
&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
|
|
}
|
|
|
|
const upsertEnvironmentVariable = `-- name: UpsertEnvironmentVariable :exec
|
|
INSERT INTO environment_variables (id, service_id, key, value, is_secret, created_at, updated_at)
|
|
VALUES ($1, $2, $3, $4, $5, $6, $7)
|
|
ON CONFLICT (service_id, key) DO UPDATE
|
|
SET value = EXCLUDED.value,
|
|
is_secret = EXCLUDED.is_secret,
|
|
updated_at = EXCLUDED.updated_at
|
|
`
|
|
|
|
type UpsertEnvironmentVariableParams struct {
|
|
ID uuid.UUID `json:"id"`
|
|
ServiceID uuid.UUID `json:"service_id"`
|
|
Key string `json:"key"`
|
|
Value string `json:"value"`
|
|
IsSecret sql.NullBool `json:"is_secret"`
|
|
CreatedAt sql.NullTime `json:"created_at"`
|
|
UpdatedAt sql.NullTime `json:"updated_at"`
|
|
}
|
|
|
|
func (q *Queries) UpsertEnvironmentVariable(ctx context.Context, arg UpsertEnvironmentVariableParams) error {
|
|
_, err := q.db.ExecContext(ctx, upsertEnvironmentVariable,
|
|
arg.ID,
|
|
arg.ServiceID,
|
|
arg.Key,
|
|
arg.Value,
|
|
arg.IsSecret,
|
|
arg.CreatedAt,
|
|
arg.UpdatedAt,
|
|
)
|
|
return err
|
|
}
|