spice2json

command module
v0.3.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 18, 2024 License: MIT Imports: 19 Imported by: 0

README

spice2json

Utility to generate a simplified JSON representation of a SpiceDB Schema in order to power code generation in other languages.

Build Binary

Build for mac

GOARCH=arm64 go build -ldflags="-s -w"

Build for intel

GOARCH=amd64 go build -ldflags="-s -w"

Compress using upx for a smaller build

upx --brute spice2json

Command Usage

Read from file, output is to stdout unless an output file is given as the second argument.

spice2json [-n namespace] input.zaml [output.json]

Read from stdin

spice2json -s < schema.zaml

Read from spicedb rest client

spice2json -h -k MyPreSharedKey http://localhost:8443

Read from spicedb grpc client

spice2json -g -k MyPreSharedKey [-insecure] localhost:50051

Example

This is a simple example of SpiceDB Schema DSL as input

/** 
 * represents a user of the system 
 */
definition user {}

definition platform {
	relation administrator: user

	permission super_admin = administrator

	permission create_tenant = super_admin + administrator
}

JSON output from above example

{
  "definitions": [
    {
      "name": "user",
      "comment": "represents a user of the system"
    },
    {
      "name": "platform",
      "relations": [
        {
          "name": "administrator",
          "types": [
            {
              "type": "user"
            }
          ]
        }
      ],
      "permissions": [
        {
          "name": "super_admin",
          "userSet": {
            "operation": "union",
            "children": [
              {
                "relation": "administrator"
              }
            ]
          }
        },
        {
          "name": "create_tenant",
          "userSet": {
            "operation": "union",
            "children": [
              {
                "relation": "super_admin"
              },
              {
                "relation": "administrator"
              }
            ]
          }
        }
      ]
    }
  ]
}

Documentation

The Go Gopher

There is no documentation for this package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL