Example #1
0
File: list.go Project: Zyko0/cli
func List() error {
	apps, err := scalingo.AppsList()
	if err != nil {
		return errgo.Mask(err, errgo.Any)
	}

	if len(apps) == 0 {
		fmt.Println(io.Indent("\nYou haven't created any app yet, create your first application using:\n→ scalingo create <app_name>\n", 2))
		return nil
	}

	t := tablewriter.NewWriter(os.Stdout)
	t.SetHeader([]string{"Name", "Role", "Owner"})

	for _, app := range apps {
		if app.Owner.Email == scalingo.CurrentUser.Email {
			t.Append([]string{app.Name, "owner", "-"})
		} else {
			t.Append([]string{app.Name, "collaborator", fmt.Sprintf("%s <%s>", app.Owner.Username, app.Owner.Email)})
		}
	}
	t.Render()

	return nil
}
Example #2
0
File: plans.go Project: yannski/cli
func Plans(addon string) error {
	plans, err := api.AddonProviderPlansList(addon)
	if err != nil {
		return errgo.Mask(err, errgo.Any)
	}

	t := tablewriter.NewWriter(os.Stdout)
	t.SetHeader([]string{"ID", "Name", "Description"})
	for _, plan := range plans {
		t.Append([]string{plan.Name, plan.DisplayName, plan.ShortDescription})
	}
	t.Render()
	return nil
}
Example #3
0
File: list.go Project: yannski/cli
func List() error {
	addonProviders, err := api.AddonProvidersList()
	if err != nil {
		return errgo.Mask(err, errgo.Any)
	}
	t := tablewriter.NewWriter(os.Stdout)
	t.SetHeader([]string{"ID", "Name"})

	for _, addon := range addonProviders {
		t.Append([]string{addon.ID, addon.Name})
	}

	t.Render()
	return nil
}
Example #4
0
File: list.go Project: yannski/cli
func List(app string) error {
	collaborators, err := api.CollaboratorsList(app)
	if err != nil {
		return errgo.Mask(err, errgo.Any)
	}

	t := tablewriter.NewWriter(os.Stdout)
	t.SetHeader([]string{"Email", "Username", "Status"})

	for _, collaborator := range collaborators {
		t.Append([]string{collaborator.Email, collaborator.Username, collaborator.Status})
	}
	t.Render()
	return nil
}
Example #5
0
File: list.go Project: Zyko0/cli
func List(app string) error {
	resources, err := scalingo.AddonsList(app)
	if err != nil {
		return errgo.Mask(err, errgo.Any)
	}

	t := tablewriter.NewWriter(os.Stdout)
	t.SetHeader([]string{"Addon", "ID", "Plan"})

	for _, resource := range resources {
		t.Append([]string{resource.AddonProvider.Name, resource.ResourceID, resource.Plan.Name})
	}
	t.Render()

	return nil

}
Example #6
0
File: list.go Project: Zyko0/cli
func List() error {
	keys, err := scalingo.KeysList()
	if err != nil {
		return errgo.Mask(err)
	}

	t := tablewriter.NewWriter(os.Stdout)
	t.SetColWidth(60)
	t.SetHeader([]string{"Name", "Content"})

	for _, k := range keys {
		t.Append([]string{k.Name, k.Content[0:20] + "..." + k.Content[len(k.Content)-30:]})
	}

	t.Render()
	return nil
}
Example #7
0
File: list.go Project: yannski/cli
func List(app string) error {
	domains, err := api.DomainsList(app)
	if err != nil {
		return errgo.Mask(err)
	}

	t := tablewriter.NewWriter(os.Stdout)
	t.SetHeader([]string{"Domain", "SSL"})

	for _, domain := range domains {
		if !domain.SSL {
			t.Append([]string{domain.Name, "-"})
		} else {
			t.Append([]string{domain.Name, fmt.Sprintf("Valid until %v", domain.Validity)})
		}
	}
	t.Render()
	return nil
}
Example #8
0
File: ps.go Project: yannski/cli
func Ps(app string) error {
	processes, err := api.AppsPs(app)
	if err != nil {
		return errgo.Mask(err)
	}

	t := tablewriter.NewWriter(os.Stdout)
	t.SetHeader([]string{"Name", "Amount", "Size", "Command"})

	for _, ct := range processes {
		amount := fmt.Sprintf("%d", ct.Amount)
		if ct.Command != "" {
			t.Append([]string{ct.Name, amount, ct.Size, "`" + ct.Command + "`"})
		} else {
			t.Append([]string{ct.Name, amount, ct.Size, "-"})
		}
	}

	t.Render()
	return nil
}