// lists the containers running for a chain/service
// eventually remotes/actions
// existing -> true to ls existing; false to ls running
func ListRunningOrExisting(quiet, existing bool, typ string) (result string, err error) {
	re := "Running"
	if existing {
		re = "Existing"
	}
	log.WithField("status", strings.ToLower(re)).Debug("Asking Docker to list containers")
	//gotta go
	if quiet {
		if typ == "services" {
			result = strings.Join(util.ServiceContainerNames(existing), "\n")
		}
		if typ == "chains" {
			result = strings.Join(util.ChainContainerNames(existing), "\n")
		}
	} else {
		if typ == "services" {
			log.WithField("=>", fmt.Sprintf("service:%v", strings.ToLower(re))).Debug("Printing table")
			result, _ = PrintTableReport("service", existing, false) //false is for All, dealt with somewhere else
		}
		if typ == "chains" {
			log.WithField("=>", fmt.Sprintf("chain:%v", strings.ToLower(re))).Debugf("Printing table")
			result, _ = PrintTableReport("chain", existing, false)
		}
	}
	return result, nil
}
Example #2
0
func ListExisting(do *definitions.Do) error {
	if do.Quiet {
		do.Result = strings.Join(util.ChainContainerNames(true), "\n")
		if len(do.Args) != 0 && do.Args[0] != "testing" {
			logger.Printf("%s\n", "\n")
		}
	} else {
		logger.Debugf("ListExistingRaw:PrintTable =>\t%s:%v\n", "chain", true)
		perform.PrintTableReport("chain", true)
	}

	return nil
}