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

Function templateVersionsToRows

cli/templateversions.go:156–183  ·  view source on GitHub ↗

templateVersionsToRows converts a list of template versions to a list of rows for outputting.

(activeVersionID uuid.UUID, templateVersions ...codersdk.TemplateVersion)

Source from the content-addressed store, hash-verified

154// templateVersionsToRows converts a list of template versions to a list of rows
155// for outputting.
156func templateVersionsToRows(activeVersionID uuid.UUID, templateVersions ...codersdk.TemplateVersion) []templateVersionRow {
157 rows := make([]templateVersionRow, len(templateVersions))
158 for i, templateVersion := range templateVersions {
159 activeStatus := ""
160 if templateVersion.ID == activeVersionID {
161 activeStatus = cliui.Keyword("Active")
162 }
163
164 archivedStatus := ""
165 if templateVersion.Archived {
166 archivedStatus = pretty.Sprint(cliui.DefaultStyles.Warn, "Archived")
167 }
168
169 rows[i] = templateVersionRow{
170 TemplateVersion: templateVersion,
171 ActiveJSON: templateVersion.ID == activeVersionID,
172 ID: templateVersion.ID.String(),
173 Name: templateVersion.Name,
174 CreatedAt: templateVersion.CreatedAt,
175 CreatedBy: templateVersion.CreatedBy.Username,
176 Status: strings.Title(string(templateVersion.Job.Status)),
177 Active: activeStatus,
178 Archived: archivedStatus,
179 }
180 }
181
182 return rows
183}
184
185func (r *RootCmd) templateVersionsPromote() *serpent.Command {
186 var (

Callers 1

templateVersionsListMethod · 0.85

Calls 2

KeywordFunction · 0.92
StringMethod · 0.45

Tested by

no test coverage detected