Skip to content
This repository has been archived by the owner on Feb 17, 2024. It is now read-only.

timecraft: add get command #27

Merged
merged 9 commits into from
May 28, 2023
Merged

timecraft: add get command #27

merged 9 commits into from
May 28, 2023

Conversation

achille-roussel
Copy link
Contributor

@achille-roussel achille-roussel commented May 28, 2023

This PR adds a new subcommand named timecraft get which displays the content of the time machine registry.

I implemented a tagging mechanism for objects stored in the registry, which should translate well to using resource tags of object storage on AWS/GCP.

Here are a few examples:

$ ./timecraft get mod
MODULE ID     MODULE NAME  SIZE
a11c1643e362  (none)       6.82 MiB
$ ./timecraft get mod -o json
{
  "mediaType": "application/vnd.timecraft.module.v1+wasm",
  "digest": "sha256:a11c1643e362e9fe0f0a40b45f0f2212e4a725ad8e969ce9fd7ff074cfe7e0d8",
  "size": 7150231,
  "annotations": {
    "timecraft.object.created-at": "2023-05-28T19:50:41Z",
    "timecraft.object.resource-type": "module"
  }
}
$ ./timecraft get mod -o yaml
mediaType: application/vnd.timecraft.module.v1+wasm
digest: sha256:a11c1643e362e9fe0f0a40b45f0f2212e4a725ad8e969ce9fd7ff074cfe7e0d8
size: 7150231
annotations:
  timecraft.object.created-at: "2023-05-28T19:50:41Z"
  timecraft.object.resource-type: module

I copied the human package from https://github.com/segmentio/cli into internal/print/human and made a few adjustments to improve the formatting of byte sizes and time/durations.

Signed-off-by: Achille Roussel <[email protected]>
Signed-off-by: Achille Roussel <[email protected]>
internal/cmd/get.go Outdated Show resolved Hide resolved
internal/cmd/get.go Outdated Show resolved Hide resolved
internal/cmd/help.go Show resolved Hide resolved
internal/cmd/root.go Show resolved Hide resolved
internal/object/store.go Show resolved Hide resolved
internal/object/store.go Outdated Show resolved Hide resolved
internal/stream/stream.go Outdated Show resolved Hide resolved
internal/stream/stream.go Show resolved Hide resolved
achille-roussel and others added 3 commits May 28, 2023 15:58
Co-authored-by: Chris O'Hara <[email protected]>
Signed-off-by: Achille Roussel <[email protected]>
@achille-roussel
Copy link
Contributor Author

I addressed all your feedback, thanks for the thorough review @chriso !

@achille-roussel achille-roussel merged commit 8de3b88 into main May 28, 2023
3 checks passed
@achille-roussel achille-roussel deleted the timecraft-get branch May 28, 2023 23:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants