-
Notifications
You must be signed in to change notification settings - Fork 36
breaking: Clean up deprecated functionality for v1 #562
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -123,12 +123,11 @@ zed permission check --explain document:firstdoc writer user:emilia | |
|
|
||
| relCmd := commands.RegisterRelationshipCmd(rootCmd) | ||
|
|
||
| commands.RegisterWatchCmd(rootCmd) | ||
| commands.RegisterWatchRelationshipCmd(relCmd) | ||
|
|
||
| schemaCmd := commands.RegisterSchemaCmd(rootCmd) | ||
| schemaCompileCmd := registerAdditionalSchemaCmds(schemaCmd) | ||
| registerPreviewCmd(rootCmd, schemaCompileCmd) | ||
|
Comment on lines
-130
to
-131
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We no longer pass out the |
||
| registerAdditionalSchemaCmds(schemaCmd) | ||
| registerPreviewCmd(rootCmd) | ||
|
|
||
| return rootCmd | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,19 +4,11 @@ import ( | |
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| func registerPreviewCmd(rootCmd *cobra.Command, schemaCompileCmd *cobra.Command) { | ||
| func registerPreviewCmd(rootCmd *cobra.Command) { | ||
| previewCmd := &cobra.Command{ | ||
| Use: "preview <subcommand>", | ||
| Short: "Experimental commands that have been made available for preview", | ||
| } | ||
|
|
||
| schemaCmd := &cobra.Command{ | ||
| Use: "schema <subcommand>", | ||
| Short: "Manage schema for a permissions system", | ||
| Deprecated: "please use `zed schema compile`", | ||
| } | ||
|
Comment on lines
-13
to
-17
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No longer any commands under this. |
||
|
|
||
| rootCmd.AddCommand(previewCmd) | ||
| previewCmd.AddCommand(schemaCmd) | ||
| schemaCmd.AddCommand(schemaCompileCmd) | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,7 +40,7 @@ func (rtc *realTermChecker) IsTerminal(fd int) bool { | |
| return term.IsTerminal(fd) | ||
| } | ||
|
|
||
| func registerAdditionalSchemaCmds(schemaCmd *cobra.Command) *cobra.Command { | ||
| func registerAdditionalSchemaCmds(schemaCmd *cobra.Command) { | ||
| schemaWriteCmd := &cobra.Command{ | ||
| Use: "write <file?>", | ||
| Args: commands.ValidationWrapper(cobra.MaximumNArgs(1)), | ||
|
|
@@ -82,9 +82,9 @@ func registerAdditionalSchemaCmds(schemaCmd *cobra.Command) *cobra.Command { | |
| Short: "Compile a schema that uses extended syntax into one that can be written to SpiceDB", | ||
| Example: ` | ||
| Write to stdout: | ||
| zed preview schema compile root.zed | ||
| zed schema compile root.zed | ||
| Write to an output file: | ||
| zed preview schema compile root.zed --out compiled.zed | ||
| zed schema compile root.zed --out compiled.zed | ||
| `, | ||
| ValidArgsFunction: commands.FileExtensionCompletions("zed"), | ||
| RunE: func(cmd *cobra.Command, args []string) error { | ||
|
|
@@ -104,8 +104,6 @@ func registerAdditionalSchemaCmds(schemaCmd *cobra.Command) *cobra.Command { | |
|
|
||
| schemaCmd.AddCommand(schemaCompileCmd) | ||
| schemaCompileCmd.Flags().String("out", "", "output filepath; omitting writes to stdout") | ||
|
|
||
| return schemaCompileCmd | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See note about no longer passing things out of this command. |
||
| } | ||
|
|
||
| func schemaDiffCmdFunc(_ *cobra.Command, args []string) error { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,14 +47,6 @@ func consistencyFromCmd(cmd *cobra.Command) (c *v1.Consistency, err error) { | |
| c = &v1.Consistency{Requirement: &v1.Consistency_AtLeastAsFresh{AtLeastAsFresh: &v1.ZedToken{Token: atLeast}}} | ||
| } | ||
|
|
||
| // Deprecated (hidden) flag. | ||
| if revision := cobrautil.MustGetStringExpanded(cmd, "revision"); revision != "" { | ||
|
Comment on lines
-50
to
-51
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is now covered by the consistency option; we want to get rid of the old way of doing things. |
||
| if c != nil { | ||
| return nil, ErrMultipleConsistencies | ||
| } | ||
| c = &v1.Consistency{Requirement: &v1.Consistency_AtLeastAsFresh{AtLeastAsFresh: &v1.ZedToken{Token: revision}}} | ||
| } | ||
|
|
||
| if exact := cobrautil.MustGetStringExpanded(cmd, "consistency-at-exactly"); exact != "" { | ||
| if c != nil { | ||
| return nil, ErrMultipleConsistencies | ||
|
|
@@ -76,10 +68,11 @@ func RegisterPermissionCmd(rootCmd *cobra.Command) *cobra.Command { | |
| } | ||
|
|
||
| checkBulkCmd := &cobra.Command{ | ||
| Use: "bulk <resource:id#permission@subject:id> <resource:id#permission@subject:id> ...", | ||
| Short: "Check permissions in bulk exist for resource-permission-subject triplets", | ||
| Args: ValidationWrapper(cobra.MinimumNArgs(1)), | ||
| RunE: checkBulkCmdFunc, | ||
| Use: "bulk <resource:id#permission@subject:id> <resource:id#permission@subject:id> ...", | ||
| Short: "Check permissions in bulk exist for resource-permission-subject triplets", | ||
| Args: ValidationWrapper(cobra.MinimumNArgs(1)), | ||
| RunE: checkBulkCmdFunc, | ||
| Aliases: []string{"check-bulk", "bulk-check"}, | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding aliases here. |
||
| } | ||
|
|
||
| checkCmd := &cobra.Command{ | ||
|
|
@@ -106,16 +99,6 @@ func RegisterPermissionCmd(rootCmd *cobra.Command) *cobra.Command { | |
| RunE: lookupResourcesCmdFunc, | ||
| } | ||
|
|
||
| lookupCmd := &cobra.Command{ | ||
| Use: "lookup <type> <permission> <subject:id>", | ||
|
Comment on lines
-109
to
-110
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No longer using a separate command for |
||
| Short: "Enumerates the resources of a given type for which a subject has permission", | ||
| Args: ValidationWrapper(cobra.ExactArgs(3)), | ||
| ValidArgsFunction: GetArgs(ResourceType, Permission, SubjectID), | ||
| RunE: lookupResourcesCmdFunc, | ||
| Deprecated: "prefer lookup-resources", | ||
| Hidden: true, | ||
| } | ||
|
|
||
| lookupSubjectsCmd := &cobra.Command{ | ||
| Use: "lookup-subjects <resource:id> <permission> <subject_type#optional_subject_relation>", | ||
| Short: "Enumerates the subjects of a given type for which the subject has permission on the resource", | ||
|
|
@@ -128,38 +111,24 @@ func RegisterPermissionCmd(rootCmd *cobra.Command) *cobra.Command { | |
|
|
||
| permissionCmd.AddCommand(checkCmd) | ||
| checkCmd.Flags().Bool("json", false, "output as JSON") | ||
| checkCmd.Flags().String("revision", "", "optional revision at which to check") | ||
| _ = checkCmd.Flags().MarkHidden("revision") | ||
| checkCmd.Flags().Bool("explain", false, "requests debug information from SpiceDB and prints out a trace of the requests") | ||
| checkCmd.Flags().Bool("schema", false, "requests debug information from SpiceDB and prints out the schema used") | ||
| checkCmd.Flags().Bool("error-on-no-permission", false, "if true, zed will return exit code 1 if subject does not have unconditional permission") | ||
| checkCmd.Flags().String("caveat-context", "", "the caveat context to send along with the check, in JSON form") | ||
| registerConsistencyFlags(checkCmd.Flags()) | ||
|
|
||
| permissionCmd.AddCommand(checkBulkCmd) | ||
| checkBulkCmd.Flags().String("revision", "", "optional revision at which to check") | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this one wasn't marked as hidden, can we actually remove it? i also see this readCmd.Flags().String("revision", "", "optional revision at which to check")
_ = readCmd.Flags().MarkHidden("revision")
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would argue yes, as long as we document it |
||
| checkBulkCmd.Flags().Bool("json", false, "output as JSON") | ||
| checkBulkCmd.Flags().Bool("explain", false, "requests debug information from SpiceDB and prints out a trace of the requests") | ||
| checkBulkCmd.Flags().Bool("schema", false, "requests debug information from SpiceDB and prints out the schema used") | ||
| registerConsistencyFlags(checkBulkCmd.Flags()) | ||
|
|
||
| permissionCmd.AddCommand(expandCmd) | ||
| expandCmd.Flags().Bool("json", false, "output as JSON") | ||
| expandCmd.Flags().String("revision", "", "optional revision at which to check") | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same deal here. |
||
| registerConsistencyFlags(expandCmd.Flags()) | ||
|
|
||
| // NOTE: `lookup` is an alias of `lookup-resources` (below) | ||
| // and must have the same list of flags in order for it to work. | ||
| permissionCmd.AddCommand(lookupCmd) | ||
| lookupCmd.Flags().Bool("json", false, "output as JSON") | ||
| lookupCmd.Flags().String("revision", "", "optional revision at which to check") | ||
| lookupCmd.Flags().String("caveat-context", "", "the caveat context to send along with the lookup, in JSON form") | ||
| lookupCmd.Flags().Uint32("page-limit", 0, "limit of relations returned per page") | ||
| registerConsistencyFlags(lookupCmd.Flags()) | ||
|
|
||
| permissionCmd.AddCommand(lookupResourcesCmd) | ||
| lookupResourcesCmd.Flags().Bool("json", false, "output as JSON") | ||
| lookupResourcesCmd.Flags().String("revision", "", "optional revision at which to check") | ||
| lookupResourcesCmd.Flags().String("caveat-context", "", "the caveat context to send along with the lookup, in JSON form") | ||
| lookupResourcesCmd.Flags().Uint32("page-limit", 0, "limit of relations returned per page") | ||
| lookupResourcesCmd.Flags().String("cursor", "", "resume pagination from a specific cursor token") | ||
|
|
@@ -168,7 +137,6 @@ func RegisterPermissionCmd(rootCmd *cobra.Command) *cobra.Command { | |
|
|
||
| permissionCmd.AddCommand(lookupSubjectsCmd) | ||
| lookupSubjectsCmd.Flags().Bool("json", false, "output as JSON") | ||
| lookupSubjectsCmd.Flags().String("revision", "", "optional revision at which to check") | ||
| lookupSubjectsCmd.Flags().String("caveat-context", "", "the caveat context to send along with the lookup, in JSON form") | ||
| registerConsistencyFlags(lookupSubjectsCmd.Flags()) | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -38,6 +38,7 @@ func RegisterRelationshipCmd(rootCmd *cobra.Command) *cobra.Command { | |
| Args: ValidationWrapper(StdinOrExactArgs(3)), | ||
| ValidArgsFunction: GetArgs(ResourceID, Permission, SubjectTypeWithOptionalRelation), | ||
| RunE: writeRelationshipCmdFunc(v1.RelationshipUpdate_OPERATION_CREATE, os.Stdin), | ||
| Aliases: []string{"write"}, | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Adding |
||
| Example: ` | ||
| zed relationship create document:budget view user:anne --expiration-time "2025-12-31T23:59:59Z" | ||
| zed relationship create document:budget view user:anne --caveat ip_address:'{"ip": "192.168.0.1"} | ||
|
|
@@ -104,8 +105,6 @@ func RegisterRelationshipCmd(rootCmd *cobra.Command) *cobra.Command { | |
|
|
||
| relationshipCmd.AddCommand(readCmd) | ||
| readCmd.Flags().Bool("json", false, "output as JSON") | ||
| readCmd.Flags().String("revision", "", "optional revision at which to check") | ||
| _ = readCmd.Flags().MarkHidden("revision") | ||
| readCmd.Flags().String("subject-filter", "", "optional subject filter") | ||
| readCmd.Flags().Uint32("page-limit", 100, "limit of relations returned per page") | ||
| registerConsistencyFlags(readCmd.Flags()) | ||
|
|
@@ -114,8 +113,6 @@ func RegisterRelationshipCmd(rootCmd *cobra.Command) *cobra.Command { | |
| bulkDeleteCmd.Flags().Bool("force", false, "force deletion of all elements in batches defined by <optional-limit>") | ||
| bulkDeleteCmd.Flags().String("subject-filter", "", "optional subject filter") | ||
| bulkDeleteCmd.Flags().Uint32("optional-limit", 1000, "the max amount of elements to delete. If you want to delete all in batches of size <optional-limit>, set --force to true") | ||
| bulkDeleteCmd.Flags().Bool("estimate-count", true, "estimate the count of relationships to be deleted") | ||
| _ = bulkDeleteCmd.Flags().MarkDeprecated("estimate-count", "no longer used, make use of --optional-limit instead") | ||
| return relationshipCmd | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is one of the aliases that we removed.