Strip comments from backend and frontend source
Remove Go doc comments, TS/Svelte scaffold comments and explanatory notes left over from the initial scaffold, plus a few leftover Spanish notes in the compose file, SQL scripts and env template. Also drops frontend/src/lib/index.ts, which only held the SvelteKit placeholder comment and was never imported.
This commit is contained in:
@@ -4,7 +4,6 @@ CORS_ALLOWED_ORIGINS=http://localhost:5173
|
|||||||
|
|
||||||
DATABASE_URL=postgres://dockermanager:dockermanager@localhost:5432/dockermanager?sslmode=disable
|
DATABASE_URL=postgres://dockermanager:dockermanager@localhost:5432/dockermanager?sslmode=disable
|
||||||
|
|
||||||
# Se rellenan al configurar la aplicación OIDC en la consola de Zitadel (fase auth).
|
|
||||||
ZITADEL_ISSUER=http://localhost:8081
|
ZITADEL_ISSUER=http://localhost:8081
|
||||||
ZITADEL_CLIENT_ID=
|
ZITADEL_CLIENT_ID=
|
||||||
ZITADEL_CLIENT_SECRET=
|
ZITADEL_CLIENT_SECRET=
|
||||||
@@ -15,5 +14,4 @@ S3_BUCKET=dockermanager
|
|||||||
S3_ACCESS_KEY=
|
S3_ACCESS_KEY=
|
||||||
S3_SECRET_KEY=
|
S3_SECRET_KEY=
|
||||||
|
|
||||||
# Vacío = usar el socket Docker por defecto del sistema.
|
|
||||||
DOCKER_HOST=
|
DOCKER_HOST=
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// Command server arranca la API central de Docker Manager.
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// Package config carga la configuración del backend desde variables de entorno.
|
|
||||||
package config
|
package config
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -7,14 +6,10 @@ import (
|
|||||||
"github.com/caarlos0/env/v11"
|
"github.com/caarlos0/env/v11"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Config agrupa toda la configuración del servidor. Los campos de Zitadel/S3
|
|
||||||
// ya están definidos aunque todavía no se usen: se conectan en las siguientes
|
|
||||||
// fases sin tener que tocar esta struct de nuevo.
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Env string `env:"APP_ENV" envDefault:"development"`
|
Env string `env:"APP_ENV" envDefault:"development"`
|
||||||
Port int `env:"PORT" envDefault:"8080"`
|
Port int `env:"PORT" envDefault:"8080"`
|
||||||
|
|
||||||
// Orígenes permitidos para CORS en desarrollo (el frontend en Vite corre en otro puerto).
|
|
||||||
CORSAllowedOrigins []string `env:"CORS_ALLOWED_ORIGINS" envSeparator:"," envDefault:"http://localhost:5173"`
|
CORSAllowedOrigins []string `env:"CORS_ALLOWED_ORIGINS" envSeparator:"," envDefault:"http://localhost:5173"`
|
||||||
|
|
||||||
DatabaseURL string `env:"DATABASE_URL" envDefault:"postgres://dockermanager:dockermanager@localhost:5432/dockermanager?sslmode=disable"`
|
DatabaseURL string `env:"DATABASE_URL" envDefault:"postgres://dockermanager:dockermanager@localhost:5432/dockermanager?sslmode=disable"`
|
||||||
@@ -29,11 +24,9 @@ type Config struct {
|
|||||||
S3AccessKey string `env:"S3_ACCESS_KEY"`
|
S3AccessKey string `env:"S3_ACCESS_KEY"`
|
||||||
S3SecretKey string `env:"S3_SECRET_KEY"`
|
S3SecretKey string `env:"S3_SECRET_KEY"`
|
||||||
|
|
||||||
// DockerHost vacío = usar el socket por defecto del sistema (DOCKER_HOST estándar del SDK).
|
|
||||||
DockerHost string `env:"DOCKER_HOST"`
|
DockerHost string `env:"DOCKER_HOST"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load lee la configuración desde el entorno del proceso.
|
|
||||||
func Load() (Config, error) {
|
func Load() (Config, error) {
|
||||||
cfg := Config{}
|
cfg := Config{}
|
||||||
if err := env.Parse(&cfg); err != nil {
|
if err := env.Parse(&cfg); err != nil {
|
||||||
|
|||||||
@@ -1,7 +1,3 @@
|
|||||||
// Package docker define la abstracción HostConnector: la interfaz que el
|
|
||||||
// resto del backend usa para hablar con "un host Docker", sin importarle si
|
|
||||||
// es el socket local (LocalConnector, fase 1) o un agente remoto
|
|
||||||
// (AgentConnector, cuando se añada un segundo host más adelante).
|
|
||||||
package docker
|
package docker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -13,8 +9,6 @@ import (
|
|||||||
"github.com/docker/docker/client"
|
"github.com/docker/docker/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Container es la representación simplificada que expone la API HTTP,
|
|
||||||
// desacoplada del tipo interno del SDK de Docker.
|
|
||||||
type Container struct {
|
type Container struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Names []string `json:"names"`
|
Names []string `json:"names"`
|
||||||
@@ -24,22 +18,15 @@ type Container struct {
|
|||||||
Created int64 `json:"created"`
|
Created int64 `json:"created"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// HostConnector es el contrato que debe cumplir cualquier forma de hablar con
|
|
||||||
// un host Docker (local o remoto vía agente).
|
|
||||||
type HostConnector interface {
|
type HostConnector interface {
|
||||||
ListContainers(ctx context.Context) ([]Container, error)
|
ListContainers(ctx context.Context) ([]Container, error)
|
||||||
Close() error
|
Close() error
|
||||||
}
|
}
|
||||||
|
|
||||||
// LocalConnector implementa HostConnector hablando directamente con el
|
|
||||||
// socket Docker del host donde corre el backend.
|
|
||||||
type LocalConnector struct {
|
type LocalConnector struct {
|
||||||
cli *client.Client
|
cli *client.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewLocalConnector crea un conector contra el Docker Engine local.
|
|
||||||
// Si dockerHost está vacío, usa la configuración por defecto del SDK
|
|
||||||
// (respeta la variable de entorno DOCKER_HOST si está definida).
|
|
||||||
func NewLocalConnector(dockerHost string) (*LocalConnector, error) {
|
func NewLocalConnector(dockerHost string) (*LocalConnector, error) {
|
||||||
opts := []client.Opt{client.FromEnv, client.WithAPIVersionNegotiation()}
|
opts := []client.Opt{client.FromEnv, client.WithAPIVersionNegotiation()}
|
||||||
if dockerHost != "" {
|
if dockerHost != "" {
|
||||||
@@ -53,8 +40,6 @@ func NewLocalConnector(dockerHost string) (*LocalConnector, error) {
|
|||||||
return &LocalConnector{cli: cli}, nil
|
return &LocalConnector{cli: cli}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListContainers devuelve todos los contenedores del host, incluidos los
|
|
||||||
// detenidos (equivalente a `docker ps -a`).
|
|
||||||
func (l *LocalConnector) ListContainers(ctx context.Context) ([]Container, error) {
|
func (l *LocalConnector) ListContainers(ctx context.Context) ([]Container, error) {
|
||||||
list, err := l.cli.ContainerList(ctx, container.ListOptions{All: true})
|
list, err := l.cli.ContainerList(ctx, container.ListOptions{All: true})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -75,7 +60,6 @@ func (l *LocalConnector) ListContainers(ctx context.Context) ([]Container, error
|
|||||||
return out, nil
|
return out, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close libera los recursos del cliente Docker subyacente.
|
|
||||||
func (l *LocalConnector) Close() error {
|
func (l *LocalConnector) Close() error {
|
||||||
return l.cli.Close()
|
return l.cli.Close()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
// Package httpserver contiene el router HTTP y los handlers de la API.
|
|
||||||
package httpserver
|
package httpserver
|
||||||
|
|
||||||
import (
|
import (
|
||||||
@@ -13,14 +12,12 @@ import (
|
|||||||
dockerconn "dockermanager/backend/internal/docker"
|
dockerconn "dockermanager/backend/internal/docker"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Deps son las dependencias que necesitan los handlers.
|
|
||||||
type Deps struct {
|
type Deps struct {
|
||||||
Logger *slog.Logger
|
Logger *slog.Logger
|
||||||
Docker dockerconn.HostConnector
|
Docker dockerconn.HostConnector
|
||||||
Origins []string
|
Origins []string
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewRouter construye el router HTTP con todas las rutas de la Fase 1.
|
|
||||||
func NewRouter(deps Deps) http.Handler {
|
func NewRouter(deps Deps) http.Handler {
|
||||||
r := chi.NewRouter()
|
r := chi.NewRouter()
|
||||||
|
|
||||||
@@ -47,7 +44,6 @@ func NewRouter(deps Deps) http.Handler {
|
|||||||
return r
|
return r
|
||||||
}
|
}
|
||||||
|
|
||||||
// slogRequestLogger es un middleware mínimo que registra cada request con slog.
|
|
||||||
func slogRequestLogger(logger *slog.Logger) func(http.Handler) http.Handler {
|
func slogRequestLogger(logger *slog.Logger) func(http.Handler) http.Handler {
|
||||||
return func(next http.Handler) http.Handler {
|
return func(next http.Handler) http.Handler {
|
||||||
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|||||||
@@ -37,5 +37,4 @@ CREATE INDEX idx_services_host_id ON services(host_id);
|
|||||||
CREATE INDEX idx_audit_log_created_at ON audit_log(created_at DESC);
|
CREATE INDEX idx_audit_log_created_at ON audit_log(created_at DESC);
|
||||||
CREATE INDEX idx_audit_log_user_sub ON audit_log(user_sub);
|
CREATE INDEX idx_audit_log_user_sub ON audit_log(user_sub);
|
||||||
|
|
||||||
-- Host único de la Fase 1: el mismo servidor donde corre el backend.
|
|
||||||
INSERT INTO hosts (name, connection_type) VALUES ('local', 'local');
|
INSERT INTO hosts (name, connection_type) VALUES ('local', 'local');
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ services:
|
|||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
command: server -s3 -s3.port=8333 -dir=/data
|
command: server -s3 -s3.port=8333 -dir=/data
|
||||||
ports:
|
ports:
|
||||||
- "8333:8333" # API S3
|
- "8333:8333"
|
||||||
- "9333:9333" # master UI
|
- "9333:9333"
|
||||||
volumes:
|
volumes:
|
||||||
- dm_seaweed_data:/data
|
- dm_seaweed_data:/data
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1 @@
|
|||||||
-- La imagen oficial de postgres solo crea la DB indicada en POSTGRES_DB (dockermanager).
|
|
||||||
-- Zitadel necesita su propia base de datos separada; se crea aquí en el primer arranque.
|
|
||||||
CREATE DATABASE zitadel;
|
CREATE DATABASE zitadel;
|
||||||
|
|||||||
Vendored
-7
@@ -1,12 +1,5 @@
|
|||||||
// See https://svelte.dev/docs/kit/types#app.d.ts
|
|
||||||
// for information about these interfaces
|
|
||||||
declare global {
|
declare global {
|
||||||
namespace App {
|
namespace App {
|
||||||
// interface Error {}
|
|
||||||
// interface Locals {}
|
|
||||||
// interface PageData {}
|
|
||||||
// interface PageState {}
|
|
||||||
// interface Platform {}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1 +0,0 @@
|
|||||||
// place files you want to import through the `$lib` alias in this folder.
|
|
||||||
@@ -12,9 +12,4 @@
|
|||||||
"strict": true,
|
"strict": true,
|
||||||
"moduleResolution": "bundler"
|
"moduleResolution": "bundler"
|
||||||
}
|
}
|
||||||
// Path aliases are handled by https://svelte.dev/docs/kit/configuration#alias
|
|
||||||
// except $lib which is handled by https://svelte.dev/docs/kit/configuration#files
|
|
||||||
//
|
|
||||||
// To make changes to top-level options such as include and exclude, we recommend extending
|
|
||||||
// the generated config; see https://svelte.dev/docs/kit/configuration#typescript
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,14 +8,9 @@ export default defineConfig({
|
|||||||
tailwindcss(),
|
tailwindcss(),
|
||||||
sveltekit({
|
sveltekit({
|
||||||
compilerOptions: {
|
compilerOptions: {
|
||||||
// Force runes mode for the project, except for libraries. Can be removed in svelte 6.
|
|
||||||
runes: ({ filename }) =>
|
runes: ({ filename }) =>
|
||||||
filename.split(/[/\\]/).includes('node_modules') ? undefined : true
|
filename.split(/[/\\]/).includes('node_modules') ? undefined : true
|
||||||
},
|
},
|
||||||
|
|
||||||
// adapter-auto only supports some environments, see https://svelte.dev/docs/kit/adapter-auto for a list.
|
|
||||||
// If your environment is not supported, or you settled on a specific environment, switch out the adapter.
|
|
||||||
// See https://svelte.dev/docs/kit/adapters for more information about adapters.
|
|
||||||
adapter: adapter()
|
adapter: adapter()
|
||||||
})
|
})
|
||||||
]
|
]
|
||||||
|
|||||||
Reference in New Issue
Block a user