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

add url import subcommand #61

Merged
merged 2 commits into from
Nov 8, 2021
Merged

add url import subcommand #61

merged 2 commits into from
Nov 8, 2021

Conversation

ecordell
Copy link
Contributor

@ecordell ecordell commented Oct 28, 2021

Adds a zed import <url> command to import schema and relationships to a spicedb instance.

It can read directly from a file or url if it contains the devtools export format

It also has hard-coded support for importing from the authzed playground, gists, and pastebin.

Examples:

# from a gist
$ zed import https://gist.github.com/ecordell/8e3b613a677e3c844742cf24421c08b6

# from a playground link
$ zed import https://play.authzed.com/s/iksdFvCtvnkR/schema

# from pastebin
$ zed import https://pastebin.com/8qU45rVK

# from a devtools instance
$ zed import https://localhost:8443/download

# from a local file
$ zed import file:///Users/evan/Downloads/authzed-x7izWU8_2Gw3.yaml

# only schema 
$ zed import --relationships=false file:///Users/evan/Downloads/authzed-x7izWU8_2Gw3.yaml

# only relationships 
$ zed import --schema=false file:///Users/evan/Downloads/authzed-x7izWU8_2Gw3.yaml

# trace to see what relationships are written
$ zed import --log-level=trace file:///Users/evan/Downloads/authzed-x7izWU8_2Gw3.yaml

Note that the playground import relies on urls of the form https://play.authzed.com/s/iksdFvCtvnkR/download returning the full developer api download output

Fixes #24

@ecordell ecordell force-pushed the import-url branch 2 times, most recently from b83a28d to 32ac53d Compare October 29, 2021 14:07
@ecordell ecordell marked this pull request as ready for review October 29, 2021 14:14
func registerImportCmd(rootCmd *cobra.Command) {
rootCmd.AddCommand(importCmd)
importCmd.Flags().Bool("schema", true, "import schema")
importCmd.Flags().Bool("relationships", true, "import relationships")
Copy link
Member

Choose a reason for hiding this comment

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

Should probably have json mode to match the other commands

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's not really output for this command aside from the log messages (which already detect if it's a tty and switch to json if not)

cmd/zed/import.go Outdated Show resolved Hide resolved
internal/decode/decoder.go Show resolved Hide resolved
Copy link
Member

@josephschorr josephschorr left a comment

Choose a reason for hiding this comment

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

LGTM

@ecordell ecordell marked this pull request as draft October 29, 2021 20:27
@jzelinskie jzelinskie added area/CLI Affects the command line priority/2 medium This needs to be done labels Nov 5, 2021
@ecordell ecordell marked this pull request as ready for review November 8, 2021 19:53
Copy link
Member

@josephschorr josephschorr left a comment

Choose a reason for hiding this comment

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

LGTM

@ecordell ecordell merged commit 33741e2 into authzed:main Nov 8, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Nov 8, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/CLI Affects the command line priority/2 medium This needs to be done
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support writing schemas with a playground URL
3 participants