Esempio n. 1
0
File: apps.go Progetto: convox/rack
func cmdAppParamsSet(c *cli.Context) error {
	_, app, err := stdcli.DirApp(c, ".")
	if err != nil {
		return stdcli.Error(err)
	}

	params := map[string]string{}

	for _, arg := range c.Args() {
		parts := strings.SplitN(arg, "=", 2)

		if len(parts) != 2 {
			return stdcli.Error(fmt.Errorf("invalid argument: %s", arg))
		}

		params[parts[0]] = parts[1]
	}

	stdcli.Startf("Updating parameters")

	err = rackClient(c).SetParameters(app, params)
	if err != nil {
		return stdcli.Error(err)
	}

	stdcli.OK()

	return nil
}
Esempio n. 2
0
File: apps.go Progetto: convox/rack
func cmdAppCreate(c *cli.Context) error {
	_, app, err := stdcli.DirApp(c, ".")
	if err != nil {
		return stdcli.Error(err)
	}

	if len(c.Args()) > 0 {
		app = c.Args()[0]
	}

	if app == "" {
		return stdcli.Error(fmt.Errorf("must specify an app name"))
	}

	stdcli.Startf("Creating app <app>%s</app>", app)

	_, err = rackClient(c).CreateApp(app)
	if err != nil {
		return stdcli.Error(err)
	}

	stdcli.Wait("CREATING")

	if c.Bool("wait") {
		stdcli.Startf("Waiting for <app>%s</app>", app)

		if err := waitForAppRunning(c, app); err != nil {
			stdcli.Error(err)
		}

		stdcli.OK()
	}

	return nil
}
Esempio n. 3
0
File: rack.go Progetto: convox/rack
func cmdRackUpdate(c *cli.Context) error {
	vs, err := version.All()
	if err != nil {
		return stdcli.Error(err)
	}

	target, err := vs.Latest()
	if err != nil {
		return stdcli.Error(err)
	}

	if len(c.Args()) > 0 {
		t, err := vs.Find(c.Args()[0])
		if err != nil {
			return stdcli.Error(err)
		}
		target = t
	}

	system, err := rackClient(c).GetSystem()
	if err != nil {
		return stdcli.Error(err)
	}

	nv, err := vs.Next(system.Version)
	if err != nil && strings.HasSuffix(err.Error(), "is latest") {
		nv = target.Version
	} else if err != nil {
		return stdcli.Error(err)
	}

	next, err := vs.Find(nv)
	if err != nil {
		return stdcli.Error(err)
	}

	// stop at a required release if necessary
	if next.Version < target.Version {
		stdcli.Writef("WARNING: Required update found.\nPlease run `convox rack update` again once this update completes.\n")
		target = next
	}

	stdcli.Startf("Updating to <release>%s</release>", target.Version)

	_, err = rackClient(c).UpdateSystem(target.Version)
	if err != nil {
		return stdcli.Error(err)
	}

	stdcli.Wait("UPDATING")

	if c.Bool("wait") {
		stdcli.Startf("Waiting for completion")

		// give the rack a few seconds to start updating
		time.Sleep(5 * time.Second)

		if err := waitForRackRunning(c); err != nil {
			return stdcli.Error(err)
		}

		stdcli.OK()
	}

	return nil
}