示例#1
0
func (s *CliSuite) GetContainersByProject(c *C, project string) []types.Container {
	client := GetClient(c)
	containers, err := container.ListByFilter(context.Background(), client, labels.PROJECT.Eq(project))

	c.Assert(err, IsNil)

	return containers
}
示例#2
0
func (s *Service) collectContainers(ctx context.Context) ([]*container.Container, error) {
	client := s.clientFactory.Create(s)
	containers, err := container.ListByFilter(ctx, client, labels.SERVICE.Eq(s.name), labels.PROJECT.Eq(s.project.Name))
	if err != nil {
		return nil, err
	}

	result := []*container.Container{}

	for _, cont := range containers {
		c, err := container.New(ctx, client, cont.ID)
		if err != nil {
			return nil, err
		}
		result = append(result, c)
	}

	return result, nil
}