func RequireDaemon() { if c := cmd.ExitCode("docker", "ps"); c != 0 { cli.Logf("`docker ps` exited with code %d", c) if dockermachine.Installed() { vms := dockermachine.RunningVMs() if len(vms) != 0 { cli.Fatalf(`Tip: eval "$(docker-machine env %s)"`, vms[0]) } vms = dockermachine.VMs() switch len(vms) { case 0: cli.Logf("Tip: you should create a machine using docker-machine") case 1: start := "" if cmd.Stdout("docker-machine", "status", vms[0]) != "Running" { start = fmt.Sprintf("docker-machine start %s && ", vms[0]) } cli.Logf(`Tip: %seval "$(docker-machine env %s)"`, start, vms[0]) default: cli.Logf("Tip: start one of your docker machines (%s)", strings.Join(vms, ", ")) } } cli.Fatal() } }
func (s *Sous) AssembleTargetContext(targetName string) (Target, *Context) { packs := s.Packs p := DetectProjectType(packs) if p == nil { cli.Fatalf("no buildable project detected") } pack := CompiledPack{Pack: p} target, ok := pack.GetTarget(targetName) if !ok { cli.Fatalf("The %s build pack does not support %s", pack, targetName) } if fatal := CheckForProblems(pack.Pack); fatal { cli.Fatal() } context := GetContext(targetName) err := target.Check() if err != nil { cli.Fatalf("unable to %s %s project: %s", targetName, pack, err) } // If the pack specifies a version, check it matches the tagged version packAppVersion := strings.Split(pack.AppVersion(), "+")[0] if packAppVersion != "" { pv := version.Version(packAppVersion) gv := version.Version(context.BuildVersion.MajorMinorPatch) if !pv.Version.LimitedEqual(gv.Version) { cli.Warn("using latest git tagged version %s; your code reports version %s, which is ignored", gv, pv) } } return target, context }
func Update(sous *core.Sous, args []string) { key := "last-update-check" if err := config.Update(); err != nil { cli.Fatal() } config.Set(key, time.Now().Format(time.RFC3339)) cli.Success() }
func Clean(sous *core.Sous, args []string) { _, context := sous.AssembleTargetContext("app") cleanContainersSucceeded := cleanContainers(sous, context) cleanImagesSucceeded := cleanImages(sous, context) if cleanContainersSucceeded && cleanImagesSucceeded { cli.Success() } cli.Fatal() }