示例#1
0
// 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
}
示例#2
0
func ListExisting(do *definitions.Do) error {
	logger.Debugln("Asking Docker Client for the Existing Containers.")
	if do.Quiet {
		do.Result = strings.Join(util.ServiceContainerNames(true), "\n")
		if len(do.Args) != 0 && do.Args[0] != "testing" {
			logger.Printf("%s\n", "\n")
		}
	} else {
		perform.PrintTableReport("service", true) // TODO: return this as a string.
	}
	return nil
}