feat: funciones infra — Docker, deploy, build y health check
Funciones impuras para gestión de contenedores: docker_build_image, docker_compose_up/down, docker_volume_create/list/remove, generate_dockerfile, write_dockerfile, go_build_binary, health_check_http, deploy_app y stop_app. Todas con tests unitarios donde aplica. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
---
|
||||
name: write_dockerfile
|
||||
kind: function
|
||||
lang: go
|
||||
domain: infra
|
||||
version: "1.0.0"
|
||||
purity: impure
|
||||
signature: "func WriteDockerfile(dir, content string) (string, error)"
|
||||
description: "Escribe content en dir/Dockerfile. Crea el directorio si no existe. Retorna el path absoluto del archivo escrito. Compañera impura de generate_dockerfile."
|
||||
tags: [docker, dockerfile, io, write, deploy, infra]
|
||||
uses_functions: [generate_dockerfile_go_infra]
|
||||
uses_types: []
|
||||
returns: []
|
||||
returns_optional: false
|
||||
error_type: "error_go_core"
|
||||
imports: [fmt, os, path/filepath]
|
||||
tested: true
|
||||
tests: ["escribe Dockerfile en directorio existente", "crea directorio si no existe", "retorna path absoluto correcto", "error si dir es path invalido"]
|
||||
test_file_path: "functions/infra/write_dockerfile_test.go"
|
||||
file_path: "functions/infra/write_dockerfile.go"
|
||||
---
|
||||
|
||||
## Ejemplo
|
||||
|
||||
```go
|
||||
// Patron puro+impuro: generar contenido y luego escribir
|
||||
content := GenerateDockerfile("myapp", 8080, map[string]string{"PORT": "8080"})
|
||||
path, err := WriteDockerfile("/home/user/apps/myapp", content)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
fmt.Println("Dockerfile escrito en:", path)
|
||||
// /home/user/apps/myapp/Dockerfile
|
||||
```
|
||||
|
||||
## Notas
|
||||
|
||||
Patron puro+impuro: generate_dockerfile produce el texto (pura, testeable sin I/O), write_dockerfile lo persiste (impura, efecto secundario aislado). Esto facilita testear la generacion del contenido independientemente de la escritura. Sobreescribe cualquier Dockerfile existente en el directorio.
|
||||
Reference in New Issue
Block a user