Esempio n. 1
0
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()
}
Esempio n. 2
0
func TaskPort(sous *core.Sous, args []string) {
	port0, err := ports.GetFreePort()
	if err != nil {
		cli.Fatalf("Unable to get free port: %s", err)
	}
	cli.Outf("%d", port0)
	cli.Success()
}
Esempio n. 3
0
func Dockerfile(sous *core.Sous, args []string) {
	targetName := "app"
	if len(args) != 0 {
		targetName = args[0]
	}
	target, context := sous.AssembleTargetContext(targetName)
	cli.Outf(sous.Dockerfile(target, context).Render())
	cli.Success()
}
Esempio n. 4
0
func Image(sous *core.Sous, args []string) {
	target := "app"
	if len(args) != 0 {
		target = args[0]
	}
	_, context := sous.AssembleTargetContext(target)
	if context.BuildNumber() == 0 {
		cli.Fatalf("no builds yet")
	}
	cli.Outf(context.DockerTag())
	cli.Success()
}
Esempio n. 5
0
func Detect(sous *core.Sous, args []string) {
	pack := core.DetectProjectType(sous.Packs)
	if pack == nil {
		fmt.Println("no sous-compatible project detected")
		os.Exit(1)
	}
	if fatal := core.CheckForProblems(pack); fatal {
		cli.Fatalf("Detected a %s project with fatal errors.", pack)
	}
	c := core.GetContext("app")
	desc := pack.AppDesc()
	cli.Outf("Detected a %s; which supports the following targets...", desc)
	for _, target := range pack.Targets() {
		if err := target.Check(); err != nil {
			cli.Outf("\t%s \t✘ %s", target, err)
			continue
		}
		cli.Outf("\t%s \t✔︎", target)
	}
	cli.Outf("Build Version: %s", c.BuildVersion)
	cli.Success()
}
Esempio n. 6
0
func Help(sous *core.Sous, args []string) {
	if len(args) != 0 {
		command := args[0]
		if c, ok := sous.Commands[command]; ok {
			if c.HelpFunc != nil {
				fmt.Println(c.HelpFunc())
				os.Exit(0)
			}
			cli.Fatalf("Command %s does not have any help yet.", command)
		}
		cli.Fatalf("There is no command called %s; try `sous help`\n", command)
	}
	cli.Outf(`Sous is your personal sous chef for engineering tasks.
It can help with building, configuring, and deploying
your code for OpenTable's Mesos Platform.

Commands:`)

	printCommands(sous)
	cli.Outf("")
	cli.Outf("Tip: for help with any command, use `sous help <COMMAND>`")
	cli.Success()
}
Esempio n. 7
0
func Config(sous *core.Sous, args []string) {
	if len(args) == 0 || len(args) > 2 {
		cli.Fatalf("usage: sous config <key> [<new-value>]")
	}
	if len(args) == 1 {
		if v, ok := config.Properties()[args[0]]; ok {
			cli.Outf(v)
			cli.Success()
		}
		cli.Fatalf("Key %s not found", args[0])
	}
	config.Set(args[0], args[1])
	cli.Logf("Successfully set %s to %s", args[0], args[1])
	cli.Success()
}
Esempio n. 8
0
func ParseState(sous *core.Sous, args []string) {
	stateDir := getStateDir(args)
	state, err := deploy.Parse(stateDir)
	if err != nil {
		cli.Fatalf("%s", err)
	}
	merged, err := state.Merge()
	if err != nil {
		cli.Fatalf("%s", err)
	}
	out, err := yaml.Marshal(merged)
	if err != nil {
		cli.Fatalf("%s", err)
	}
	cli.Outf(string(out))
	cli.Success()
}
Esempio n. 9
0
func TaskHost(sous *core.Sous, args []string) {
	cli.Outf("%s", core.DivineTaskHost())
	cli.Success()
}
Esempio n. 10
0
func Version(sous *core.Sous, args []string) {
	cli.Outf("Sous version %s %s/%s", sous.Version, sous.OS, sous.Arch)
	cli.Outf("Revision: %s", sous.Revision)
	cli.Success()
}