1d45f232c6
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>
24 lines
527 B
Go
24 lines
527 B
Go
package infra
|
|
|
|
import (
|
|
"fmt"
|
|
"os/exec"
|
|
"strings"
|
|
)
|
|
|
|
// DockerVolumeRemove elimina un volume Docker por nombre.
|
|
// Si force es true, fuerza la eliminación incluso si está en uso.
|
|
func DockerVolumeRemove(name string, force bool) error {
|
|
args := []string{"volume", "rm"}
|
|
if force {
|
|
args = append(args, "-f")
|
|
}
|
|
args = append(args, name)
|
|
|
|
out, err := exec.Command("docker", args...).CombinedOutput()
|
|
if err != nil {
|
|
return fmt.Errorf("docker volume rm %s: %s", name, strings.TrimSpace(string(out)))
|
|
}
|
|
return nil
|
|
}
|