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

timecraft: add describe command #30

Merged
merged 4 commits into from
May 29, 2023
Merged

timecraft: add describe command #30

merged 4 commits into from
May 29, 2023

Conversation

achille-roussel
Copy link
Contributor

This PR adds a new describe sub-command to timecraft, the intent being to provide detailed information about specific resources listed out by get.

Here are a few examples:

$ ./timecraft describe ps eb6b60d1-4636-4f1f-85ad-375a3c063283
ID: eb6b60d1-4636-4f1f-85ad-375a3c063283
Start Time: 1h ago, Mon, 29 May 2023 14:24:22 PDT
Runtime: timecraft (devel)
Modules:
  714c48844052: (none) (6.82 MiB)
Args:
  http.wasm
  /Users/achilleroussel/wasm/http.wasm
Env:
  LANG=en_US.UTF-8
  PWD=/Users/achilleroussel/go/src/github.com/stealthrocket/timecraft
  ...
Log:
  segment 0: 1.72 KiB, created 1h ago (Mon, 29 May 2023 14:24:24 PDT)
$ ./timecraft describe ps eb6b60d1-4636-4f1f-85ad-375a3c063283 -o json
{
  "descriptor": {
    "mediaType": "application/vnd.timecraft.process.v1+json",
    "digest": "sha256:fc36c9197d6c6840b7ef98d85615b1f75d1a4c2aca9495322b3a66b3927df0d2",
    "size": 396,
    "annotations": {
      "timecraft.object.media-type": "application/vnd.timecraft.process.v1+json"
    }
  },
  "data": {
    "id": "eb6b60d1-4636-4f1f-85ad-375a3c063283",
    "startTime": "2023-05-29T14:24:22.699595-07:00",
    "config": {
      "mediaType": "application/vnd.timecraft.config.v1+json",
      "digest": "sha256:6d80ee83e97eb2f72b1167872041f9c496a043865d1214b1be2b2d67873f9fc2",
      "size": 2964,
      "annotations": {
        "timecraft.object.media-type": "application/vnd.timecraft.config.v1+json"
      }
    }
  }
}
$ ./timecraft describe ps eb6b60d1-4636-4f1f-85ad-375a3c063283 -o yaml
descriptor:
  mediaType: application/vnd.timecraft.process.v1+json
  digest: sha256:fc36c9197d6c6840b7ef98d85615b1f75d1a4c2aca9495322b3a66b3927df0d2
  size: 396
  annotations:
    timecraft.object.media-type: application/vnd.timecraft.process.v1+json
data:
  id: eb6b60d1-4636-4f1f-85ad-375a3c063283
  startTime: 2023-05-29T14:24:22.699595-07:00
  config:
    mediaType: application/vnd.timecraft.config.v1+json
    digest: sha256:6d80ee83e97eb2f72b1167872041f9c496a043865d1214b1be2b2d67873f9fc2
    size: 2964
    annotations:
      timecraft.object.media-type: application/vnd.timecraft.config.v1+json

Signed-off-by: Achille Roussel <[email protected]>
Comment on lines -13 to -14
ctx, _ := signal.NotifyContext(context.Background(), syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM)
os.Exit(cmd.Root(ctx, os.Args[1:]...))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I moved this to the run command which is the only case where we need to perform graceful shutdowns. It helps interrupt CLI commands with Ctrl+C.

Comment on lines -185 to -188
{
Name: "timecraft.object.created-at",
Value: time.Now().UTC().Format(time.RFC3339),
},
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this because it causes the hash to change for every object.

@achille-roussel achille-roussel merged commit 787a667 into main May 29, 2023
3 checks passed
@achille-roussel achille-roussel deleted the describe branch May 29, 2023 23:04
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