allow multiple docker providers, added file provider support

This commit is contained in:
yusing
2024-03-11 10:31:01 +00:00
parent e736fe1f1e
commit d3684b62b7
25 changed files with 627 additions and 246 deletions

View File

@@ -6,6 +6,7 @@ import (
"io"
"net"
"net/http"
"os"
"path"
"path/filepath"
"regexp"
@@ -53,20 +54,18 @@ func (u *Utils) findUseFreePort(startingPort int) (int, error) {
return -1, fmt.Errorf("unable to find free port: %v", err)
}
func (u *Utils) resetPortsInUse() {
u.portsInUseMutex.Lock()
for port := range u.PortsInUse {
u.PortsInUse[port] = false
}
u.portsInUseMutex.Unlock()
}
func (u *Utils) markPortInUse(port int) {
u.portsInUseMutex.Lock()
u.PortsInUse[port] = true
u.portsInUseMutex.Unlock()
}
func (u *Utils) unmarkPortInUse(port int) {
u.portsInUseMutex.Lock()
delete(u.PortsInUse, port)
u.portsInUseMutex.Unlock()
}
func (*Utils) healthCheckHttp(targetUrl string) error {
// try HEAD first
// if HEAD is not allowed, try GET
@@ -189,3 +188,8 @@ func (*Utils) respJSSubPath(r *http.Response, p string) error {
r.Body = io.NopCloser(strings.NewReader(js))
return nil
}
func (*Utils) fileOK(path string) bool {
_, err := os.Stat(path)
return err == nil
}