(record updateRecord)
| 278 | } |
| 279 | |
| 280 | func updateBundle(record updateRecord) outputBundle { |
| 281 | rows := []keyValue{ |
| 282 | {Label: updateStatusValue, Value: stringOrDash(record.Status)}, |
| 283 | {Label: "Install Method", Value: stringOrDash(record.InstallMethod)}, |
| 284 | {Label: updateManagedValue, Value: fmt.Sprintf("%t", record.Managed)}, |
| 285 | {Label: "Current Version", Value: stringOrDash(record.CurrentVersion)}, |
| 286 | {Label: "Latest Version", Value: stringOrDash(record.LatestVersion)}, |
| 287 | {Label: "Release", Value: stringOrDash(record.ReleaseURL)}, |
| 288 | {Label: updateMessageValue, Value: stringOrDash(record.Message)}, |
| 289 | {Label: "Daemon Restarted", Value: fmt.Sprintf("%t", record.DaemonRestarted)}, |
| 290 | } |
| 291 | if record.Recommendation != "" { |
| 292 | rows = append(rows, keyValue{Label: "Recommendation", Value: record.Recommendation}) |
| 293 | } |
| 294 | |
| 295 | return outputBundle{ |
| 296 | jsonValue: record, |
| 297 | human: func() (string, error) { |
| 298 | return renderHumanSection("Update", rows), nil |
| 299 | }, |
| 300 | toon: func() (string, error) { |
| 301 | order := []string{ |
| 302 | updateStatusKey, |
| 303 | "install_method", |
| 304 | updateManagedKey, |
| 305 | updateCurrentVersionKey, |
| 306 | updateLatestVersionKey, |
| 307 | "release_url", |
| 308 | "daemon_restarted", |
| 309 | updateMessageKey, |
| 310 | } |
| 311 | values := []string{ |
| 312 | record.Status, |
| 313 | record.InstallMethod, |
| 314 | fmt.Sprintf("%t", record.Managed), |
| 315 | record.CurrentVersion, |
| 316 | record.LatestVersion, |
| 317 | record.ReleaseURL, |
| 318 | fmt.Sprintf("%t", record.DaemonRestarted), |
| 319 | record.Message, |
| 320 | } |
| 321 | if record.Recommendation != "" { |
| 322 | order = append(order, "recommendation") |
| 323 | values = append(values, record.Recommendation) |
| 324 | } |
| 325 | return renderToonObject( |
| 326 | updateUpdateKey, |
| 327 | order, |
| 328 | values, |
| 329 | ), nil |
| 330 | }, |
| 331 | } |
| 332 | } |
| 333 | |
| 334 | func writeUpdateFailure(cmd *cobra.Command, record updateRecord, cause error) error { |
| 335 | if writeErr := writeCommandOutput(cmd, updateBundle(record)); writeErr != nil { |
no test coverage detected