You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Adding an age column to the cli, closeshetznercloud#417
As an SRE, I deploy a lot of hcloud resources automatically via the hcloud API and use the cli to validate those changes.
I am deploying using immutable VMs rather than phoenix deployments (instead of updating existing VMs, I re-create them with the newest config)
Since I am using the API in automation to create hcloud resources, my hcloud resources include Ids in their name, making it a mess sometimes to figure out which is the newest VM.
To know which VM got deployed when, I often find myself using the hcloud-cli like this:
```bash
$ hcloud server list -s name -o 'columns=name,status,created,ipv4,ipv6'
NAME STATUS CREATED IPV4 IPV6
cedi-dev-control-plane-xxxxx running Sun Nov 13 13:43:05 CET 2022 XXX.XXX.XXX.XXX 2a01:4f8:xxxx:xxxx::/64
cedi-dev-control-plane-xxxxx running Sun Nov 13 13:51:46 CET 2022 XXX.XXX.XXX.XXX 2a01:4f8:xxxx:xxxx::/64
cedi-dev-control-plane-xxxxx running Sun Nov 13 13:40:22 CET 2022 XXX.XXX.XXX.XXX 2a01:4f8:xxxx:xxxx::/64
cedi-dev-worker-cxp31-xxxxx running Wed Nov 9 17:15:32 CET 2022 XXX.XXX.XXX.XXX 2a01:4f8:xxxx:xxxx::/64
cedi-dev-worker-cxp31-xxxxx running Wed Nov 9 17:26:36 CET 2022 XXX.XXX.XXX.XXX 2a01:4f8:xxxx:xxxx::/64
cedi-dev-worker-cxp31-xxxxx running Wed Nov 9 16:46:55 CET 2022 XXX.XXX.XXX.XXX 2a01:4f8:xxxx:xxxx::/64
cedi-dev-worker-cxp31-xxxxx running Sun Nov 13 14:02:41 CET 2022 XXX.XXX.XXX.XXX 2a01:4f8:xxxx:xxxx::/64
```
However, I noticed the `created` column contains the "raw" create DateTime string which is good for computers to read, but bad for humans.
Using the hcloud dashboard in my browser, I can see the created timestamp as a Duration since `time.Now()`:
<img width="215" alt="Screenshot 2022-11-13 at 14 17 18" src="https://user-images.githubusercontent.com/1952599/201523632-35a91d6d-4039-4469-a308-6c2355f70652.png">
With this commit I add a "age" column to the output of hcloud cli:
```bash
$ hcloud server list
ID NAME STATUS IPV4 IPV6 PRIVATE NET DATACENTER AGE
25550867 cedi-dev-control-plane-xxxxx running xxx.xxx.xx.xxx 2a01:4f8:xxxx:xxxx::/64 10.0.0.x (cedi-dev) fsn1-dcxx 2d
25551100 cedi-dev-control-plane-xxxxx running xx.xx.xxx.xx 2a01:4f8:xxx:xxxx::/64 10.0.0.x (cedi-dev) fsn1-dcxx 2d
25551348 cedi-dev-worker-cxp31-xxxxx running xx.xx.xx.xxx 2a01:4f8:xxxx:xxxx::/64 10.0.0.x (cedi-dev) fsn1-dcxx 2d
25586128 cedi-dev-worker-cxp31-xxxxx running xx.xx.xxx.xx 2a01:4f8:xxxx:xxxx::/64 10.0.0.x (cedi-dev) fsn1-dcxx 1d
25586289 cedi-dev-control-plane-xxxxx running xxx.xx.xx.xx 2a01:4f8:xxxx:xxxx::/64 10.0.0.x (cedi-dev) fsn1-dcxx 1d
25588261 cedi-dev-worker-cxp31-xxxxx running xxx.xx.xxx.xxx 2a01:4f8:xxx:xxxx::/64 10.0.0.x (cedi-dev) fsn1-dcxx 23h
```
I also added the "age" column to the "default_columns" in most commands
0 commit comments