add better logs
This commit is contained in:
@@ -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, "/"),
|
||||
|
||||
Reference in New Issue
Block a user