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,35 @@
|
||||
package infra
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// DockerVolumeList lista los volumes Docker disponibles localmente.
|
||||
// Retorna un slice de maps con campos Driver, Name, Scope, Labels, Mountpoint.
|
||||
func DockerVolumeList() ([]map[string]string, error) {
|
||||
out, err := exec.Command("docker", "volume", "ls", "--format", "{{json .}}").Output()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("docker volume ls: %w", err)
|
||||
}
|
||||
|
||||
if len(strings.TrimSpace(string(out))) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
var volumes []map[string]string
|
||||
for _, line := range splitLines(out) {
|
||||
if len(line) == 0 {
|
||||
continue
|
||||
}
|
||||
var raw map[string]string
|
||||
if err := json.Unmarshal(line, &raw); err != nil {
|
||||
continue
|
||||
}
|
||||
volumes = append(volumes, raw)
|
||||
}
|
||||
|
||||
return volumes, nil
|
||||
}
|
||||
Reference in New Issue
Block a user