diff --git a/internal/cmd/cmd.go b/internal/cmd/cmd.go index 795e6362..d8ebb6a2 100644 --- a/internal/cmd/cmd.go +++ b/internal/cmd/cmd.go @@ -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) + registerAdditionalSchemaCmds(schemaCmd) + registerPreviewCmd(rootCmd) return rootCmd } diff --git a/internal/cmd/preview.go b/internal/cmd/preview.go index cbe32311..2e1dbd1b 100644 --- a/internal/cmd/preview.go +++ b/internal/cmd/preview.go @@ -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 ", Short: "Experimental commands that have been made available for preview", } - schemaCmd := &cobra.Command{ - Use: "schema ", - Short: "Manage schema for a permissions system", - Deprecated: "please use `zed schema compile`", - } - rootCmd.AddCommand(previewCmd) - previewCmd.AddCommand(schemaCmd) - schemaCmd.AddCommand(schemaCompileCmd) } diff --git a/internal/cmd/schema.go b/internal/cmd/schema.go index b4fe60b0..12246e24 100644 --- a/internal/cmd/schema.go +++ b/internal/cmd/schema.go @@ -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 ", 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 } func schemaDiffCmdFunc(_ *cobra.Command, args []string) error { diff --git a/internal/commands/permission.go b/internal/commands/permission.go index 884f3e39..0e8ba5d3 100644 --- a/internal/commands/permission.go +++ b/internal/commands/permission.go @@ -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 != "" { - 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 ...", - Short: "Check permissions in bulk exist for resource-permission-subject triplets", - Args: ValidationWrapper(cobra.MinimumNArgs(1)), - RunE: checkBulkCmdFunc, + Use: "bulk ...", + Short: "Check permissions in bulk exist for resource-permission-subject triplets", + Args: ValidationWrapper(cobra.MinimumNArgs(1)), + RunE: checkBulkCmdFunc, + Aliases: []string{"check-bulk", "bulk-check"}, } checkCmd := &cobra.Command{ @@ -106,16 +99,6 @@ func RegisterPermissionCmd(rootCmd *cobra.Command) *cobra.Command { RunE: lookupResourcesCmdFunc, } - lookupCmd := &cobra.Command{ - Use: "lookup ", - 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 ", Short: "Enumerates the subjects of a given type for which the subject has permission on the resource", @@ -128,8 +111,6 @@ 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") @@ -137,7 +118,6 @@ func RegisterPermissionCmd(rootCmd *cobra.Command) *cobra.Command { registerConsistencyFlags(checkCmd.Flags()) permissionCmd.AddCommand(checkBulkCmd) - checkBulkCmd.Flags().String("revision", "", "optional revision at which to check") 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") @@ -145,21 +125,10 @@ func RegisterPermissionCmd(rootCmd *cobra.Command) *cobra.Command { permissionCmd.AddCommand(expandCmd) expandCmd.Flags().Bool("json", false, "output as JSON") - expandCmd.Flags().String("revision", "", "optional revision at which to check") 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()) diff --git a/internal/commands/relationship.go b/internal/commands/relationship.go index ec7ace87..9f912cf9 100644 --- a/internal/commands/relationship.go +++ b/internal/commands/relationship.go @@ -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"}, 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 ") 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 , 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 } diff --git a/internal/commands/watch.go b/internal/commands/watch.go index ea5697f6..054dfb87 100644 --- a/internal/commands/watch.go +++ b/internal/commands/watch.go @@ -27,22 +27,6 @@ var ( watchRelationshipFilters []string ) -func RegisterWatchCmd(rootCmd *cobra.Command) *cobra.Command { - watchCmd := &cobra.Command{ - Use: "watch [object_types, ...] [revision]", - Short: "Watches the stream of relationship updates and schema updates from the server", - Args: ValidationWrapper(cobra.RangeArgs(0, 2)), - RunE: watchCmdFunc, - Deprecated: "please use `zed relationships watch` instead", - } - - rootCmd.AddCommand(watchCmd) - watchCmd.Flags().StringSliceVar(&watchObjectTypes, "object_types", nil, "optional object types to watch updates for") - watchCmd.Flags().StringVar(&watchRevision, "revision", "", "optional revision at which to start watching") - watchCmd.Flags().BoolVar(&watchTimestamps, "timestamp", false, "shows timestamp of incoming update events") - return watchCmd -} - func RegisterWatchRelationshipCmd(parentCmd *cobra.Command) *cobra.Command { watchRelationshipsCmd := &cobra.Command{ Use: "watch [object_types, ...] [revision]",