本文整理匯總了Golang中github.com/opentable/sous/core.Sous.LsContainers方法的典型用法代碼示例。如果您正苦於以下問題:Golang Sous.LsContainers方法的具體用法?Golang Sous.LsContainers怎麽用?Golang Sous.LsContainers使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/opentable/sous/core.Sous
的用法示例。
在下文中一共展示了Sous.LsContainers方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Ls
func Ls(sous *core.Sous, args []string) {
//globalFlag := lsFlags.Bool("g", false, "global: list files in all projects sous has built")
//lsFlags.Parse(args)
//global := *globalFlag
args = lsFlags.Args()
if len(args) != 0 {
cli.Fatalf("sous ls does not accept any arguments")
}
_, context := sous.AssembleTargetContext("app")
cli.Outf(" ===> Images")
images := sous.LsImages(context)
if len(images) == 0 {
cli.Logf(" no images for this project")
}
for _, image := range images {
cli.Logf(" %s:%s", image.Name, image.Tag)
}
cli.Outf(" ===> Containers")
containers := sous.LsContainers(context)
if len(containers) == 0 {
cli.Logf(" no containers for this project")
}
for _, container := range containers {
cli.Logf(" %s (%s)", container.Name(), container.CID())
}
cli.Success()
}
示例2: cleanContainers
func cleanContainers(sous *core.Sous, context *core.Context) bool {
success := true
for _, c := range sous.LsContainers(context) {
if err := c.ForceRemove(); err != nil {
cli.Logf("Failed to remove container %s (%s)", c.Name(), c.CID())
success = false
} else {
cli.Logf("Removed container %s (%s)", c.Name(), c.CID())
}
}
return success
}