Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding host support for json schemas in claims #645

Merged
merged 1 commit into from
Jul 24, 2023

Conversation

autodidaddict
Copy link
Member

This adds support for the config_schema field in capability provider claims. It is supposed by both the internal claims cache and the KV bucket, as well as extraction from the PAR file itself.

Querying claims from the lattice (asking the host):

wash ctl get claims -o json
[warn] `wash ctl get claims` has been deprecated in favor of `wash get claims` and will be removed in a future version.

{
  "claims": {
    "claims": [
      {
        "call_alias": "",
        "caps": "",
        "config_schema": "{\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"description\":\"wasmCloud HTTP Server Provider Link Definition configuration specfiication\",\"properties\":{\"address\":{\"default\":\"127.0.0.1:4000\",\"description\":\"An address and port combination on which to listen.\",\"type\":\"string\"},\"config_b64\":{\"description\":\"A base64 encoded version of the config_json property. See that property for schema\",\"type\":\"string\"},\"config_file\":{\"default\":\"\",\"description\":\"The path to a file containing JSON configuration. Use this sparingly as it affects portability\",\"type\":\"string\"},\"config_json\":{\"description\":\"Raw JSON configuration for the link definition\",\"properties\":{\"address\":{\"default\":\"127.0.0.1:4000\",\"description\":\"An address and port combination on which to listen.\",\"type\":\"string\"},\"cache_control\":{\"description\":\"Cache control header information\",\"type\":\"string\"},\"max_content_len\":{\"description\":\"Duration string\",\"type\":\"string\"},\"readonly_mode\":{\"description\":\"Enforce only read operations\",\"type\":\"boolean\"},\"timeout_ms\":{\"description\":\"Timeout in milliseconds for requests\",\"type\":\"integer\"},\"tls\":{\"properties\":{\"cert_file\":{\"description\":\"tbd\",\"type\":\"string\"},\"priv_key_file\":{\"description\":\"tbd\",\"type\":\"string\"}},\"type\":\"object\"}},\"type\":\"object\"},\"port\":{\"default\":\"\",\"description\":\"A port number on which to listen\",\"type\":\"string\"}},\"title\":\"HTTP Server Provider Configuration\",\"type\":\"object\",\"x-taplo-info\":{\"authors\":[\"wasmCloud Team\"]}}",
        "contract_id": "wasmcloud:httpserver",
        "iss": "ACM7TOENKEIO6Q6J66FX53AKXRHH6TH2WZ6K6SZQULNSWLDUIQHSRRSS",
        "name": "HTTP Server",
        "rev": "1689871835",
        "sub": "VDASU74EOUFQPSDCER7PCLFFQUZSHHB7AKZQM2DOJS77BLXSKXNT7CZ6",
        "tags": "",
        "version": "0.18.2"
      }
    ]
  },
  "success": true
}

note that the config_schema field, as managed by the hosts, is an escaped string and not managed as raw JSON.

Querying directly from the bucket:

nats kv get LATTICEDATA_default CLAIMS_VDASU74EOUFQPSDCER7PCLFFQUZSHHB7AKZQM2DOJS77BLXSKXNT7CZ6 --raw
{"call_alias":"","caps":"","config_schema":"{\"$schema\":\"https://json-schema.org/draft/2020-12/schema\",\"description\":\"wasmCloud HTTP Server Provider Link Definition configuration specfiication\",\"properties\":{\"address\":{\"default\":\"127.0.0.1:4000\",\"description\":\"An address and port combination on which to listen.\",\"type\":\"string\"},\"config_b64\":{\"description\":\"A base64 encoded version of the config_json property. See that property for schema\",\"type\":\"string\"},\"config_file\":{\"default\":\"\",\"description\":\"The path to a file containing JSON configuration. Use this sparingly as it affects portability\",\"type\":\"string\"},\"config_json\":{\"description\":\"Raw JSON configuration for the link definition\",\"properties\":{\"address\":{\"default\":\"127.0.0.1:4000\",\"description\":\"An address and port combination on which to listen.\",\"type\":\"string\"},\"cache_control\":{\"description\":\"Cache control header information\",\"type\":\"string\"},\"max_content_len\":{\"description\":\"Duration string\",\"type\":\"string\"},\"readonly_mode\":{\"description\":\"Enforce only read operations\",\"type\":\"boolean\"},\"timeout_ms\":{\"description\":\"Timeout in milliseconds for requests\",\"type\":\"integer\"},\"tls\":{\"properties\":{\"cert_file\":{\"description\":\"tbd\",\"type\":\"string\"},\"priv_key_file\":{\"description\":\"tbd\",\"type\":\"string\"}},\"type\":\"object\"}},\"type\":\"object\"},\"port\":{\"default\":\"\",\"description\":\"A port number on which to listen\",\"type\":\"string\"}},\"title\":\"HTTP Server Provider Configuration\",\"type\":\"object\",\"x-taplo-info\":{\"authors\":[\"wasmCloud Team\"]}}","contract_id":"wasmcloud:httpserver","iss":"ACM7TOENKEIO6Q6J66FX53AKXRHH6TH2WZ6K6SZQULNSWLDUIQHSRRSS","name":"HTTP Server","rev":"1689871835","sub":"VDASU74EOUFQPSDCER7PCLFFQUZSHHB7AKZQM2DOJS77BLXSKXNT7CZ6","tags":"","version":"0.18.2"}

Signed-off-by: Kevin Hoffman <autodidaddict@users.noreply.github.com>
@autodidaddict autodidaddict force-pushed the feat/par_json_schema branch from 78f5c7e to e2706e5 Compare July 24, 2023 13:32
@autodidaddict autodidaddict merged commit 1e9076a into main Jul 24, 2023
@autodidaddict autodidaddict deleted the feat/par_json_schema branch July 24, 2023 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants