2017-02-07 21:33:23 +00:00
|
|
|
package docker
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"golang.org/x/net/context"
|
|
|
|
|
2017-07-06 14:28:13 +00:00
|
|
|
"github.com/docker/docker/api/types"
|
|
|
|
"github.com/docker/docker/api/types/filters"
|
2017-02-07 21:33:23 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// List lists the containers managed by kermit
|
|
|
|
func (p *Project) List() ([]types.Container, error) {
|
|
|
|
filters := filters.NewArgs()
|
|
|
|
for key, value := range p.Labels {
|
|
|
|
filters.Add("label", fmt.Sprintf("%s=%s", key, value))
|
|
|
|
}
|
|
|
|
containers, err := p.Client.ContainerList(context.Background(), types.ContainerListOptions{
|
2017-07-06 14:28:13 +00:00
|
|
|
Filters: filters,
|
2017-02-07 21:33:23 +00:00
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
return containers, nil
|
|
|
|
}
|