Code Monkey home page Code Monkey logo

spice2json's Introduction

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"
              }
            ]
          }
        }
      ]
    }
  ]
}

spice2json's People

Contributors

thewunder avatar alsbury avatar rutgersc avatar

Stargazers

Michael Tanczos avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

Forkers

rutgersc

spice2json's Issues

Binary is getting killed

First, thanks for the project!

I am trying to use published binary to run on my MacOS M3 I get an error:

cannot be opened because the developer cannot be verified.

OK, this seems to be workaroundable, and I try to fix it with:

$ sudo xattr -r -d com.apple.quarantine spice2json

The verification message disappears, but now I see just killed:

$ ./spice2json
[1]    43271 killed     ./spice2json

The file seems to be right:

$ file spice2json
spice2json: Mach-O 64-bit executable arm64

I am not a Golang dev, just trying to use the utility, so can't say anything... But maybe some external libs are not getting statically linked or something similar?...

Can't install directly from GitHub

Trying to install directly from the repo results in an error due to the module name not matching the repo

>go install github.com/alsbury/spice2json@latest
go: github.com/alsbury/spice2json@latest: version constraints conflict:
        github.com/alsbury/[email protected]: parsing go.mod:
        module declares its path as: spice2json
                but was required as: github.com/alsbury/spice2json

Obviously it can be installed by cloning the repo and running go install from the repo root but it would be nice if it could be installed directly.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.