Beispiel #1
0
Datei: logs.go Projekt: Zyko0/cli
func dumpLogs(logsURL string, n int, filter string) error {
	res, err := scalingo.Logs(logsURL, n, filter)
	if err != nil {
		return errgo.Mask(err, errgo.Any)
	}
	defer res.Body.Close()

	if res.StatusCode == 404 {
		io.Error("There is not log for this application.")
		return nil
	}

	_, err = stdio.Copy(os.Stdout, res.Body)
	if err != nil {
		return errgo.Mask(err, errgo.Any)
	}

	return nil
}
Beispiel #2
0
func errorQuit(err error) {
	if errgo.Cause(err) == api.LoginAbortedErr {
		fmt.Printf("... %v\n", err)
		os.Exit(1)
	}

	if api.IsRequestFailedError(errgo.Cause(err)) {
		code := errgo.Cause(err).(*api.RequestFailedError).Code
		if code == 401 {
			session.DestroyToken()
		}
	}

	newReportError(err).Report()
	rollbar.Wait()
	io.Error("An error occured:")
	fmt.Println(io.Indent(err.Error(), 7))
	os.Exit(1)
}
Beispiel #3
0
func Remove(app, email string) error {
	collaborator, err := getFromEmail(app, email)
	if err != nil {
		if err == notFound {
			io.Error(email + " is not a collaborator of " + app + ".")
			return nil
		} else {
			return errgo.Mask(err, errgo.Any)
		}
	}

	err = scalingo.CollaboratorRemove(app, collaborator.ID)
	if err != nil {
		return errgo.Mask(err, errgo.Any)
	}

	io.Status(email, "has been removed from the collaborators of", app)
	return nil
}