templateVersionsToRows converts a list of template versions to a list of rows for outputting.
(activeVersionID uuid.UUID, templateVersions ...codersdk.TemplateVersion)
| 154 | // templateVersionsToRows converts a list of template versions to a list of rows |
| 155 | // for outputting. |
| 156 | func 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 | |
| 185 | func (r *RootCmd) templateVersionsPromote() *serpent.Command { |
| 186 | var ( |
no test coverage detected