MCPcopy Index your code
hub / github.com/coder/coder / templatesToRows

Function templatesToRows

cli/templates.go:96–114  ·  view source on GitHub ↗

templateToRows converts a list of templates to a list of templateTableRow for outputting.

(templates ...codersdk.Template)

Source from the content-addressed store, hash-verified

94// templateToRows converts a list of templates to a list of templateTableRow for
95// outputting.
96func templatesToRows(templates ...codersdk.Template) []templateTableRow {
97 rows := make([]templateTableRow, len(templates))
98 for i, template := range templates {
99 rows[i] = templateTableRow{
100 Template: template,
101 Name: template.Name,
102 CreatedAt: template.CreatedAt.Format("January 2, 2006"),
103 LastUpdated: template.UpdatedAt.Format("January 2, 2006"),
104 OrganizationID: template.OrganizationID,
105 OrganizationName: template.OrganizationName,
106 Provisioner: template.Provisioner,
107 ActiveVersionID: template.ActiveVersionID,
108 UsedBy: pretty.Sprint(cliui.DefaultStyles.Fuchsia, formatActiveDevelopers(template.ActiveUserCount)),
109 DefaultTTL: (time.Duration(template.DefaultTTLMillis) * time.Millisecond),
110 }
111 }
112
113 return rows
114}

Callers 1

templateListMethod · 0.85

Calls 3

formatActiveDevelopersFunction · 0.85
DurationMethod · 0.80
FormatMethod · 0.65

Tested by

no test coverage detected