示例#1
0
// showTemplates prints the templates available in @region
func showTemplates(client *clcv2.CLIClient, region string) {
	capa, err := client.GetDeploymentCapabilities(region)
	if err != nil {
		exit.Fatalf("failed to query deployment capabilities of %s: %s", region, err)
	}

	table := tablewriter.NewWriter(os.Stdout)
	table.SetAutoFormatHeaders(false)
	table.SetAlignment(tablewriter.ALIGN_LEFT)
	table.SetAutoWrapText(false)

	/* Note: not displaying ReservedDrivePaths and DrivePathLength here, I don't understand their use. */
	/* Note: not listing Capabilities here, since the table gets too large for a single screen */
	table.SetHeader([]string{"Template Name", "Description", "OS", "Storage"})

	for _, tpl := range capa.Templates {
		table.Append([]string{tpl.Name, tpl.Description, tpl.OsType, fmt.Sprintf("%d GB", tpl.StorageSizeGB)})
	}
	table.Render()
}