saucelabs / saucectl

A command line interface for the Sauce Labs platform.
Apache License 2.0
42 stars 16 forks source link

feat: Add cli to list imagerunner containers #880

Closed tianfeng92 closed 9 months ago

tianfeng92 commented 9 months ago

Proposed changes

Add cli to list containers:

$ saucectl imagerunner list -o text
┌────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│ ID                                Image                                            Status     CreationTime               TerminationTime           │
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
│ 44d3a9a52d0c4df2ba56f5900d42805d  saucelabs/imagerunner-playwright-example:latest  Cancelled  2024-01-25T17:03:07-08:00  2024-01-25T17:03:18-08:00 │
│ b8b79cd4e2fe4c6b9bab2924fb56821e  saucelabs/imagerunner-playwright-example:latest  Succeeded  2024-01-25T16:23:47-08:00  2024-01-25T16:24:38-08:00 │
└────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

JSON output

{
  "content": [
    {
      "id": "44d3a9a52d0c4df2ba56f5900d42805d",
      "status": "Cancelled",
      "image": "saucelabs/imagerunner-playwright-example:latest",
      "creation_time": 1706230987,
      "termination_time": 1706230998
    },
    {
      "id": "14c42f8a5fa3402996139d5952e18f8f",
      "status": "Cancelled",
      "image": "saucelabs/imagerunner-playwright-example:latest",
      "creation_time": 1706230986,
      "termination_time": 1706230998
    }
  ]
}

It supports text and json output formats. But there's a difference due to the SO backend API's behavior: it provides CreationTime and TerminationTime as Unix timestamps.

The discrepancy between the formats is due to the SO backend API exclusively providing Unix timestamps. I'm open to suggestions for improving these output formats.


This description explains the reasoning behind the different timestamp formats in text and json outputs and invites feedback on this implementation.

Types of changes

Checklist

Further comments