add better logs

This commit is contained in:
2026-04-04 14:37:53 +02:00
parent fe6ce5249e
commit 960e12f967
2 changed files with 55 additions and 20 deletions

View File

@@ -38,6 +38,29 @@ type StackFile struct {
StackFileContent string `json:"StackFileContent"`
}
type Container struct {
ID string `json:"Id"`
Names []string `json:"Names"`
}
// FindContainer returns the container ID for a given name (e.g. "seerr").
// Docker container names have a leading slash, so "/seerr" matches "seerr".
func (c *Client) FindContainer(name string) (string, error) {
var containers []Container
if err := c.get(fmt.Sprintf("/api/endpoints/%d/docker/containers/json", c.endpointID), &containers); err != nil {
return "", err
}
want := "/" + name
for _, ct := range containers {
for _, n := range ct.Names {
if n == want {
return ct.ID, nil
}
}
}
return "", fmt.Errorf("container %q not found", name)
}
func New(baseURL, token, endpointName string) (*Client, error) {
c := &Client{
baseURL: strings.TrimRight(baseURL, "/"),