move getDockerSocketPath to daemon.go

This commit is contained in:
Zettat123 2023-06-30 11:52:13 +08:00
parent c6d75e0ab2
commit ba20ddb2f7
2 changed files with 14 additions and 27 deletions

View file

@ -159,3 +159,17 @@ func initLogging(cfg *config.Config) {
}
}
}
func getDockerSocketPath(configDockerHost string) (string, error) {
// a `-` means don't mount the docker socket to job containers
if configDockerHost != "" && configDockerHost != "-" {
return configDockerHost, nil
}
socket, found := os.LookupEnv("DOCKER_HOST")
if found {
return socket, nil
}
return "", fmt.Errorf("daemon Docker Engine socket not found and docker_host config was invalid")
}

View file

@ -1,27 +0,0 @@
// Copyright 2023 The Gitea Authors. All rights reserved.
// SPDX-License-Identifier: MIT
package cmd
import (
"fmt"
"os"
)
func getDockerSocketPath(configDockerHost string) (string, error) {
var socketPath string
// a `-` means don't mount the docker socket to job containers
if configDockerHost != "" && configDockerHost != "-" {
socketPath = configDockerHost
} else {
socket, found := os.LookupEnv("DOCKER_HOST")
if !found {
return "", fmt.Errorf("daemon Docker Engine socket not found and docker_host config was invalid")
} else {
socketPath = socket
}
}
return socketPath, nil
}