Beispiel #1
0
func (s *Stack) LoadTaggedContainers(imageName string, tag string) error {
	util.Log.Debugf("Cargando contenedores filtrando por TAG con filtros: imagen %s - tag %s", imageName, tag)

	containers, err := s.dockerApiHelper.ListTaggedContainers(imageName, tag)
	if err != nil {
		return err
	}

	for k := range containers {
		c, err := s.dockerApiHelper.ContainerInspect(containers[k].ID)
		if err != nil {
			return err
		}
		s.services = append(s.services, service.NewFromContainer(s.createId(), s.dockerApiHelper, c, s.serviceIdNotification))
	}

	return nil
}
Beispiel #2
0
func (s *Stack) LoadFilteredContainers(imageNameFilter string, tagFilter string, containerNameFilter string) error {
	util.Log.Debugf("Cargando contenedores con filtros: imagen %s - nombre contenedor %s", imageNameFilter, containerNameFilter)
	filter := helper.NewContainerFilter()
	//filter.GetStep() = []string{"running"}
	filter.ImageRegexp = imageNameFilter
	filter.TagRegexp = tagFilter
	filter.NameRegexp = containerNameFilter

	containers, err := s.dockerApiHelper.ListContainers(filter)
	if err != nil {
		return err
	}

	for k := range containers {
		c, err := s.dockerApiHelper.ContainerInspect(containers[k].ID)
		if err != nil {
			return err
		}
		s.services = append(s.services, service.NewFromContainer(s.createId(), s.dockerApiHelper, c, s.serviceIdNotification))
	}

	return nil
}