fix(docker): simplify and fix logs api

This commit is contained in:
yusing
2025-09-14 00:32:47 +08:00
parent 6b17272347
commit da71dcf058

View File

@@ -59,21 +59,15 @@ func Logs(c *gin.Context) {
// TODO: implement levels
dockerHost, ok := docker.GetDockerHostByContainerID(id)
if !ok {
c.JSON(http.StatusNotFound, apitypes.Error(fmt.Sprintf("container %s not found in %s", id, c.GetString("server"))))
c.JSON(http.StatusNotFound, apitypes.Error(fmt.Sprintf("container %s not found", id)))
return
}
dockerClient, found, err := getDockerClient(dockerHost)
dockerClient, err := docker.NewClient(dockerHost)
if err != nil {
c.Error(apitypes.InternalServerError(err, "failed to get docker client"))
return
}
if !found {
c.JSON(http.StatusNotFound, apitypes.Error("server not found"))
return
}
defer dockerClient.Close()
opts := container.LogsOptions{