fix(engine): bersihkan output versi compose provider podman + socket env di doctor — verifikasi podman 6.1.4 live
CI / test (push) Successful in 24s

This commit is contained in:
oxpoe committed 2026-10-16 02:13:17 +07:00
1 parent 24a1d634cd
commit 771f7d2452
2 files changed
+18 -1

No files matched your search

+4
View File
@@ -39,8 +39,12 @@ func Doctor(w io.Writer) int {
engineName = engine.Name
host := engine.Host
if host == "" {
if env := os.Getenv("DOCKER_HOST"); env != "" {
host = env
} else {
host = i18n.T("doctor.hostDefault")
}
}
if info, err := cl.Info(ctx); err != nil {
fmt.Fprintf(w, "engine : %s %s %v\n", i18n.T("error.warn"), engine.Name, err)
} else {
+14 -1
View File
@@ -5,6 +5,7 @@ import (
"encoding/json"
"fmt"
"os/exec"
"regexp"
"strings"
)
@@ -85,14 +86,26 @@ func (c *ComposeClient) List(ctx context.Context) ([]ComposeProject, error) {
}
// Version — versi compose ringkas (mis. "5.6.0").
// Provider (mis. `podman compose` → docker-compose) kadang menulis pesan
// peringatan ke output; ambil baris terakhir non-kosong & bersihkan ANSI.
func (c *ComposeClient) Version(ctx context.Context) (string, error) {
out, err := c.Run(ctx, "", "version", "--short")
if err != nil {
return "", err
}
return strings.TrimSpace(out), nil
lines := strings.Split(out, "\n")
for i := len(lines) - 1; i >= 0; i-- {
if l := stripANSI(strings.TrimSpace(lines[i])); l != "" {
return l, nil
}
}
return "", nil
}
var ansiRE = regexp.MustCompile(`\x1b\[[0-9;?<>=]*[A-Za-z]`)
func stripANSI(s string) string { return ansiRE.ReplaceAllString(s, "") }
// --- operasi stack (dipakai manager & CLI companion) ---
func (c *ComposeClient) Up(ctx context.Context, dir string) (string, error) {