Ejemplo n.º 1
0
func equinoxUpdate() error {
	var opts equinox.Options
	if err := opts.SetPublicKeyPEM(publicKey); err != nil {
		return err
	}

	// check for the update
	resp, err := equinox.Check(appID, opts)
	switch {
	case err == equinox.NotAvailableErr:
		fmt.Println("No update available, already at the latest version!")
		return nil
	case err != nil:
		fmt.Println("Update failed:", err)
		return err
	}

	// fetch the update and apply it
	err = resp.Apply()
	if err != nil {
		return err
	}

	fmt.Printf("Updated to new version: %s!\n", resp.ReleaseVersion)
	return nil
}
Ejemplo n.º 2
0
func checkCLIVersion() error {
	title := "Convox CLI version"
	startCheck(title)

	client, err := updateClient()
	if err != nil {
		return stdcli.Error(err)
	}

	opts := equinox.Options{
		CurrentVersion: Version,
		Channel:        "stable",
		HTTPClient:     client,
	}
	if err := opts.SetPublicKeyPEM(publicKey); err != nil {
		return stdcli.Error(err)
	}

	// check for update
	_, err = equinox.Check("app_i8m2L26DxKL", opts)
	if err == nil && Version != "dev" {
		diagnose(Diagnosis{
			Kind:        "warning",
			Title:       title,
			Description: "<warning>Your Convox CLI is out of date, run `convox update`</warning>",
		})
	} else {
		diagnose(Diagnosis{
			Title: title,
			Kind:  "success",
		})
	}
	return nil
}
Ejemplo n.º 3
0
func cmdUpdate(c *cli.Context) error {
	client, err := updateClient()
	if err != nil {
		return stdcli.ExitError(err)
	}

	stdcli.Spinner.Prefix = "Updating convox/proxy: "
	stdcli.Spinner.Start()

	if err := updateProxy(); err != nil {
		fmt.Printf("\x08\x08FAILED\n")
	} else {
		fmt.Printf("\x08\x08OK\n")
	}

	stdcli.Spinner.Stop()

	stdcli.Spinner.Prefix = "Updating convox: "
	stdcli.Spinner.Start()

	opts := equinox.Options{
		CurrentVersion: Version,
		Channel:        "stable",
		HTTPClient:     client,
	}
	if err := opts.SetPublicKeyPEM(publicKey); err != nil {
		return stdcli.ExitError(err)
	}

	// check for update
	r, err := equinox.Check("app_i8m2L26DxKL", opts)
	switch {
	case err == equinox.NotAvailableErr:
		fmt.Println("\x08\x08Already up to date")
		return nil
	case err != nil:
		return stdcli.ExitError(err)
	}

	// apply update
	err = r.Apply()
	if err != nil {
		return stdcli.ExitError(err)
	}

	fmt.Printf("\x08\x08OK, %s\n", r.ReleaseVersion)
	stdcli.Spinner.Stop()

	return nil
}
Ejemplo n.º 4
0
func cmdUpdate(c *cli.Context) {
	client, err := updateClient()
	if err != nil {
		stdcli.Error(err)
	}

	stdcli.Spinner.Prefix = "Updating: "
	stdcli.Spinner.Start()

	opts := equinox.Options{
		CurrentVersion: Version,
		Channel:        "stable",
		HTTPClient:     client,
	}
	if err := opts.SetPublicKeyPEM(publicKey); err != nil {
		stdcli.Error(err)
		return
	}

	// check for update
	r, err := equinox.Check("app_i8m2L26DxKL", opts)
	switch {
	case err == equinox.NotAvailableErr:
		fmt.Println("\x08\x08Already up to date")
		return
	case err != nil:
		stdcli.Error(err)
		return
	}

	// apply update
	err = r.Apply()
	if err != nil {
		stdcli.Error(err)
		return
	}

	stdcli.Spinner.Stop()
	fmt.Printf("\x08\x08OK, %s\n", r.ReleaseVersion)
}
Ejemplo n.º 5
0
func equinoxUpdate(channel string, skipConfirm bool) error {
	var opts equinox.Options
	if err := opts.SetPublicKeyPEM(publicKey); err != nil {
		return err
	}
	opts.Channel = channel

	// check for the update
	resp, err := equinox.Check(appID, opts)
	switch {
	case err == equinox.NotAvailableErr:
		fmt.Println("No update available, already at the latest version!")
		return nil
	case err != nil:
		fmt.Println("Update failed:", err)
		return err
	}

	fmt.Println("New version available!")
	fmt.Println("Version:", resp.ReleaseVersion)
	fmt.Println("Name:", resp.ReleaseTitle)
	fmt.Println("Details:", resp.ReleaseDescription)

	if !skipConfirm {
		fmt.Printf("Would you like to update [y/n]? ")
		if !askForConfirmation() {
			return nil
		}
	}
	//fmt.Printf("New version available: %s downloading ... \n", resp.ReleaseVersion)
	// fetch the update and apply it
	err = resp.Apply()
	if err != nil {
		return err
	}

	fmt.Printf("Updated to new version: %s!\n", resp.ReleaseVersion)
	return nil
}