0
0
Fork 0
mirror of https://github.com/crazy-max/diun.git synced 2025-01-12 11:38:11 +00:00
crazy-max_diun/pkg/docker/service.go
2019-12-14 17:45:52 +01:00

25 lines
547 B
Go

package docker
import (
"sort"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/swarm"
)
// ServiceList returns Swarm services
func (c *Client) ServiceList(filterArgs filters.Args) ([]swarm.Service, error) {
services, err := c.API.ServiceList(c.ctx, types.ServiceListOptions{
Filters: filterArgs,
})
if err != nil {
return nil, err
}
sort.Slice(services, func(i, j int) bool {
return services[i].Spec.Name < services[j].Spec.Name
})
return services, nil
}