mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
chore: include organization name when fetching templates (#13751)
* chore: include organization name when fetching templates * chore: rename template_with_user to template_with_names
This commit is contained in:
+1
-1
@@ -13,7 +13,7 @@ import (
|
||||
func (r *RootCmd) templateList() *serpent.Command {
|
||||
orgContext := NewOrganizationContext()
|
||||
formatter := cliui.NewOutputFormatter(
|
||||
cliui.TableFormat([]templateTableRow{}, []string{"name", "last updated", "used by"}),
|
||||
cliui.TableFormat([]templateTableRow{}, []string{"name", "organization name", "last updated", "used by"}),
|
||||
cliui.JSONFormat(),
|
||||
)
|
||||
|
||||
|
||||
+19
-17
@@ -83,14 +83,15 @@ type templateTableRow struct {
|
||||
Template codersdk.Template
|
||||
|
||||
// Used by table format:
|
||||
Name string `json:"-" table:"name,default_sort"`
|
||||
CreatedAt string `json:"-" table:"created at"`
|
||||
LastUpdated string `json:"-" table:"last updated"`
|
||||
OrganizationID uuid.UUID `json:"-" table:"organization id"`
|
||||
Provisioner codersdk.ProvisionerType `json:"-" table:"provisioner"`
|
||||
ActiveVersionID uuid.UUID `json:"-" table:"active version id"`
|
||||
UsedBy string `json:"-" table:"used by"`
|
||||
DefaultTTL time.Duration `json:"-" table:"default ttl"`
|
||||
Name string `json:"-" table:"name,default_sort"`
|
||||
CreatedAt string `json:"-" table:"created at"`
|
||||
LastUpdated string `json:"-" table:"last updated"`
|
||||
OrganizationID uuid.UUID `json:"-" table:"organization id"`
|
||||
OrganizationName string `json:"-" table:"organization name"`
|
||||
Provisioner codersdk.ProvisionerType `json:"-" table:"provisioner"`
|
||||
ActiveVersionID uuid.UUID `json:"-" table:"active version id"`
|
||||
UsedBy string `json:"-" table:"used by"`
|
||||
DefaultTTL time.Duration `json:"-" table:"default ttl"`
|
||||
}
|
||||
|
||||
// templateToRows converts a list of templates to a list of templateTableRow for
|
||||
@@ -99,15 +100,16 @@ func templatesToRows(templates ...codersdk.Template) []templateTableRow {
|
||||
rows := make([]templateTableRow, len(templates))
|
||||
for i, template := range templates {
|
||||
rows[i] = templateTableRow{
|
||||
Template: template,
|
||||
Name: template.Name,
|
||||
CreatedAt: template.CreatedAt.Format("January 2, 2006"),
|
||||
LastUpdated: template.UpdatedAt.Format("January 2, 2006"),
|
||||
OrganizationID: template.OrganizationID,
|
||||
Provisioner: template.Provisioner,
|
||||
ActiveVersionID: template.ActiveVersionID,
|
||||
UsedBy: pretty.Sprint(cliui.DefaultStyles.Fuchsia, formatActiveDevelopers(template.ActiveUserCount)),
|
||||
DefaultTTL: (time.Duration(template.DefaultTTLMillis) * time.Millisecond),
|
||||
Template: template,
|
||||
Name: template.Name,
|
||||
CreatedAt: template.CreatedAt.Format("January 2, 2006"),
|
||||
LastUpdated: template.UpdatedAt.Format("January 2, 2006"),
|
||||
OrganizationID: template.OrganizationID,
|
||||
OrganizationName: template.OrganizationName,
|
||||
Provisioner: template.Provisioner,
|
||||
ActiveVersionID: template.ActiveVersionID,
|
||||
UsedBy: pretty.Sprint(cliui.DefaultStyles.Fuchsia, formatActiveDevelopers(template.ActiveUserCount)),
|
||||
DefaultTTL: (time.Duration(template.DefaultTTLMillis) * time.Millisecond),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -11,10 +11,10 @@ OPTIONS:
|
||||
-O, --org string, $CODER_ORGANIZATION
|
||||
Select which organization (uuid or name) to use.
|
||||
|
||||
-c, --column string-array (default: name,last updated,used by)
|
||||
-c, --column string-array (default: name,organization name,last updated,used by)
|
||||
Columns to display in table output. Available columns: name, created
|
||||
at, last updated, organization id, provisioner, active version id,
|
||||
used by, default ttl.
|
||||
at, last updated, organization id, organization name, provisioner,
|
||||
active version id, used by, default ttl.
|
||||
|
||||
-o, --output string (default: table)
|
||||
Output format. Available formats: table, json.
|
||||
|
||||
Reference in New Issue
Block a user