ockam icon indicating copy to clipboard operation
ockam copied to clipboard

feat(rust): `ockam node show` to use dynamic data from node

Open neil2468 opened this issue 2 years ago • 0 comments

Current Behavior

  • ockam node show intends to show the status and details of a node (e.g. a list of its services). At the moment this feature uses static text and assumes things about the node (see below code).
  • This code is also used by ockam node list and ockam node create.
  • Related to #3177.

https://github.com/build-trust/ockam/blob/d4dd3529e09139dbebebbf8ba59db114353e8330/implementations/rust/ockam/ockam_command/src/node/show.rs#L43-L79

Proposed Changes

  • Modify ockam node show to ask the node for details about itself and display those details.
  • Add a request/response get /node/service to allow the CLI to get a list of services from a node.
  • Add a basic test to ockam_command/tests/commands/bats to test the new feature in CI.

Queries

  1. Is the output formatting of ockam node show okay? Instead of a verbose tree, could we output some of the information in a tabular style like docker image ls?
> docker image ls
REPOSITORY                                     TAG       IMAGE ID       CREATED        SIZE
ghcr.io/build-trust/ockam-builder              latest    b10ae04c8b6f   2 weeks ago    4.62GB
ghcr.io/build-trust/ockam-builder              <none>    9cfba9ba6e22   2 months ago   4.58GB
ghcr.io/cross-rs/riscv64gc-unknown-linux-gnu   0.2.4     23b40ea6412a   3 months ago   1.03GB
hello-world                                    latest    46331d942d63   6 months ago   9.14kB
  1. In the output, should the Transport field Payload be renamed?

  2. The request/response get /node/service builds its response from ockam_api::nodes::service::NodeManager.registry. Is there a risk that this might leak private information from the registry to a user using the CLI?

  3. Are there other details about a node that should be added to this feature (e.g. TCP inlets and outlets)?

Example Output

> ockam node create n1
> ockam node create n2
> ockam secure-channel-listener create test --at /node/n1
> ockam tcp-listener create 127.0.0.1:7002 --at /node/n1
> ockam node list

Node:
  Name: n1
  Status: UP
  Route to node:
    Short: /node/n1
    Verbose: /dnsaddr/localhost/tcp/55754
  Identity: Pcf94e075af7c5885ab0eb84abb9a76223f7359f6c64bf753a136ae1b2bb3f02f
  Transports:
    Transport:
      Type: TCP
      Mode: Listening
      Payload: 127.0.0.1:55754
    Transport:
      Type: TCP
      Mode: Listening
      Payload: 127.0.0.1:7002
  Secure Channel Listeners:
    Listener:
      Address: /service/api
    Listener:
      Address: /service/test
  Services:
    Service:
      Type: vault
      Address: /service/vault_service
    Service:
      Type: identity
      Address: /service/identity_service
    Service:
      Type: authenticated
      Address: /service/authenticated
    Service:
      Type: uppercase
      Address: /service/uppercase
    Service:
      Type: echoer
      Address: /service/echo
    Service:
      Type: credentials
      Address: /service/credentials

Node:
  Name: n2
  Status: UP
  Route to node:
    Short: /node/n2
    Verbose: /dnsaddr/localhost/tcp/55761
  Identity: Pcf94e075af7c5885ab0eb84abb9a76223f7359f6c64bf753a136ae1b2bb3f02f
  Transports:
    Transport:
      Type: TCP
      Mode: Listening
      Payload: 127.0.0.1:55761
  Secure Channel Listeners:
    Listener:
      Address: /service/api
  Services:
    Service:
      Type: vault
      Address: /service/vault_service
    Service:
      Type: identity
      Address: /service/identity_service
    Service:
      Type: authenticated
      Address: /service/authenticated
    Service:
      Type: uppercase
      Address: /service/uppercase
    Service:
      Type: echoer
      Address: /service/echo
    Service:
      Type: credentials
      Address: /service/credentials

Checks

neil2468 avatar Sep 21 '22 17:09 neil2468