Skip to content
This repository was archived by the owner on Sep 26, 2025. It is now read-only.

Commit 2eb145f

Browse files
authored
fix: make linter happy (#963)
1 parent b2f7802 commit 2eb145f

File tree

1 file changed

+23
-12
lines changed

1 file changed

+23
-12
lines changed

dockercompose/compose.go

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package dockercompose
22

33
import (
44
"fmt"
5+
"net/url"
56
"os"
67
"path/filepath"
78
"regexp"
@@ -10,7 +11,6 @@ import (
1011

1112
"github.com/nhost/be/services/mimir/model"
1213
"github.com/nhost/cli/ssl"
13-
"net/url"
1414
)
1515

1616
const (
@@ -205,21 +205,32 @@ func trafikFiles(dotnhostfolder string) error {
205205
return nil
206206
}
207207

208+
func getDockerHost() (string, error) {
209+
socket, ok := os.LookupEnv("DOCKER_HOST")
210+
if !ok {
211+
return "/var/run/docker.sock", nil
212+
}
213+
214+
u, err := url.Parse(socket)
215+
if err != nil {
216+
return "", fmt.Errorf("failed to parse DOCKER_HOST: %w", err)
217+
}
218+
if u.Scheme != "unix" {
219+
return "", fmt.Errorf( //nolint:err113
220+
"unsupported scheme %s in DOCKER_HOST, only unix supported",
221+
u.Scheme,
222+
)
223+
}
224+
return u.Path, nil
225+
}
226+
208227
func traefik(subdomain, projectName string, port uint, dotnhostfolder string) (*Service, error) {
209228
if err := trafikFiles(dotnhostfolder); err != nil {
210229
return nil, fmt.Errorf("failed to create traefik files: %w", err)
211230
}
212-
path := "/var/run/docker.sock"
213-
socket, ok := os.LookupEnv("DOCKER_HOST")
214-
if ok {
215-
u, err := url.Parse(socket)
216-
if err != nil {
217-
return nil, fmt.Errorf("failed to parse DOCKER_HOST: %w", err)
218-
}
219-
if u.Scheme != "unix" {
220-
return nil, fmt.Errorf("unsupported scheme %s in DOCKER_HOST, only unix supported", u.Scheme)
221-
}
222-
path = u.Path
231+
path, err := getDockerHost()
232+
if err != nil {
233+
return nil, fmt.Errorf("failed to get docker host: %w", err)
223234
}
224235

225236
return &Service{

0 commit comments

Comments
 (0)