Skip to content

Commit 21dcab7

Browse files
tstirrat15miparnisari
authored andcommitted
feat(breaking): Clean up deprecated functionality for v1
1 parent 7b71383 commit 21dcab7

8 files changed

Lines changed: 58 additions & 128 deletions

File tree

docs/zed.md

Lines changed: 48 additions & 52 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

internal/cmd/cmd.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,11 @@ zed permission check --explain document:firstdoc writer user:emilia
123123

124124
relCmd := commands.RegisterRelationshipCmd(rootCmd)
125125

126-
commands.RegisterWatchCmd(rootCmd)
127126
commands.RegisterWatchRelationshipCmd(relCmd)
128127

129128
schemaCmd := commands.RegisterSchemaCmd(rootCmd)
130-
schemaCompileCmd := registerAdditionalSchemaCmds(schemaCmd)
131-
registerPreviewCmd(rootCmd, schemaCompileCmd)
129+
registerAdditionalSchemaCmds(schemaCmd)
130+
registerPreviewCmd(rootCmd)
132131

133132
return rootCmd
134133
}

internal/cmd/preview.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,11 @@ import (
44
"github.com/spf13/cobra"
55
)
66

7-
func registerPreviewCmd(rootCmd *cobra.Command, schemaCompileCmd *cobra.Command) {
7+
func registerPreviewCmd(rootCmd *cobra.Command) {
88
previewCmd := &cobra.Command{
99
Use: "preview <subcommand>",
1010
Short: "Experimental commands that have been made available for preview",
1111
}
1212

13-
schemaCmd := &cobra.Command{
14-
Use: "schema <subcommand>",
15-
Short: "Manage schema for a permissions system",
16-
Deprecated: "please use `zed schema compile`",
17-
}
18-
1913
rootCmd.AddCommand(previewCmd)
20-
previewCmd.AddCommand(schemaCmd)
21-
schemaCmd.AddCommand(schemaCompileCmd)
2214
}

internal/cmd/schema.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ func (rtc *realTermChecker) IsTerminal(fd int) bool {
3838
return term.IsTerminal(fd)
3939
}
4040

41-
func registerAdditionalSchemaCmds(schemaCmd *cobra.Command) *cobra.Command {
41+
func registerAdditionalSchemaCmds(schemaCmd *cobra.Command) {
4242
schemaWriteCmd := &cobra.Command{
4343
Use: "write <file?>",
4444
Args: commands.ValidationWrapper(cobra.MaximumNArgs(1)),
@@ -105,8 +105,6 @@ func registerAdditionalSchemaCmds(schemaCmd *cobra.Command) *cobra.Command {
105105

106106
schemaCmd.AddCommand(schemaCompileCmd)
107107
schemaCompileCmd.Flags().String("out", "", "output filepath; omitting writes to stdout")
108-
109-
return schemaCompileCmd
110108
}
111109

112110
func schemaDiffCmdFunc(_ *cobra.Command, args []string) error {

internal/commands/permission.go

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,6 @@ func consistencyFromCmd(cmd *cobra.Command) (c *v1.Consistency, err error) {
4747
c = &v1.Consistency{Requirement: &v1.Consistency_AtLeastAsFresh{AtLeastAsFresh: &v1.ZedToken{Token: atLeast}}}
4848
}
4949

50-
// Deprecated (hidden) flag.
51-
if revision := cobrautil.MustGetStringExpanded(cmd, "revision"); revision != "" {
52-
if c != nil {
53-
return nil, ErrMultipleConsistencies
54-
}
55-
c = &v1.Consistency{Requirement: &v1.Consistency_AtLeastAsFresh{AtLeastAsFresh: &v1.ZedToken{Token: revision}}}
56-
}
57-
5850
if exact := cobrautil.MustGetStringExpanded(cmd, "consistency-at-exactly"); exact != "" {
5951
if c != nil {
6052
return nil, ErrMultipleConsistencies
@@ -76,10 +68,11 @@ func RegisterPermissionCmd(rootCmd *cobra.Command) *cobra.Command {
7668
}
7769

7870
checkBulkCmd := &cobra.Command{
79-
Use: "bulk <resource:id#permission@subject:id> <resource:id#permission@subject:id> ...",
80-
Short: "Check permissions in bulk exist for resource-permission-subject triplets",
81-
Args: ValidationWrapper(cobra.MinimumNArgs(1)),
82-
RunE: checkBulkCmdFunc,
71+
Use: "bulk <resource:id#permission@subject:id> <resource:id#permission@subject:id> ...",
72+
Short: "Check permissions in bulk exist for resource-permission-subject triplets",
73+
Args: ValidationWrapper(cobra.MinimumNArgs(1)),
74+
RunE: checkBulkCmdFunc,
75+
Aliases: []string{"check-bulk", "bulk-check"},
8376
}
8477

8578
checkCmd := &cobra.Command{
@@ -106,16 +99,6 @@ func RegisterPermissionCmd(rootCmd *cobra.Command) *cobra.Command {
10699
RunE: lookupResourcesCmdFunc,
107100
}
108101

109-
lookupCmd := &cobra.Command{
110-
Use: "lookup <type> <permission> <subject:id>",
111-
Short: "Enumerates the resources of a given type for which a subject has permission",
112-
Args: ValidationWrapper(cobra.ExactArgs(3)),
113-
ValidArgsFunction: GetArgs(ResourceType, Permission, SubjectID),
114-
RunE: lookupResourcesCmdFunc,
115-
Deprecated: "prefer lookup-resources",
116-
Hidden: true,
117-
}
118-
119102
lookupSubjectsCmd := &cobra.Command{
120103
Use: "lookup-subjects <resource:id> <permission> <subject_type#optional_subject_relation>",
121104
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 {
128111

129112
permissionCmd.AddCommand(checkCmd)
130113
checkCmd.Flags().Bool("json", false, "output as JSON")
131-
checkCmd.Flags().String("revision", "", "optional revision at which to check")
132-
_ = checkCmd.Flags().MarkHidden("revision")
133114
checkCmd.Flags().Bool("explain", false, "requests debug information from SpiceDB and prints out a trace of the requests")
134115
checkCmd.Flags().Bool("schema", false, "requests debug information from SpiceDB and prints out the schema used")
135116
checkCmd.Flags().Bool("error-on-no-permission", false, "if true, zed will return exit code 1 if subject does not have unconditional permission")
136117
checkCmd.Flags().String("caveat-context", "", "the caveat context to send along with the check, in JSON form")
137118
registerConsistencyFlags(checkCmd.Flags())
138119

139120
permissionCmd.AddCommand(checkBulkCmd)
140-
checkBulkCmd.Flags().String("revision", "", "optional revision at which to check")
141121
checkBulkCmd.Flags().Bool("json", false, "output as JSON")
142122
checkBulkCmd.Flags().Bool("explain", false, "requests debug information from SpiceDB and prints out a trace of the requests")
143123
checkBulkCmd.Flags().Bool("schema", false, "requests debug information from SpiceDB and prints out the schema used")
144124
registerConsistencyFlags(checkBulkCmd.Flags())
145125

146126
permissionCmd.AddCommand(expandCmd)
147127
expandCmd.Flags().Bool("json", false, "output as JSON")
148-
expandCmd.Flags().String("revision", "", "optional revision at which to check")
149128
registerConsistencyFlags(expandCmd.Flags())
150129

151-
// NOTE: `lookup` is an alias of `lookup-resources` (below)
152-
// and must have the same list of flags in order for it to work.
153-
permissionCmd.AddCommand(lookupCmd)
154-
lookupCmd.Flags().Bool("json", false, "output as JSON")
155-
lookupCmd.Flags().String("revision", "", "optional revision at which to check")
156-
lookupCmd.Flags().String("caveat-context", "", "the caveat context to send along with the lookup, in JSON form")
157-
lookupCmd.Flags().Uint32("page-limit", 0, "limit of relations returned per page")
158-
registerConsistencyFlags(lookupCmd.Flags())
159-
160130
permissionCmd.AddCommand(lookupResourcesCmd)
161131
lookupResourcesCmd.Flags().Bool("json", false, "output as JSON")
162-
lookupResourcesCmd.Flags().String("revision", "", "optional revision at which to check")
163132
lookupResourcesCmd.Flags().String("caveat-context", "", "the caveat context to send along with the lookup, in JSON form")
164133
lookupResourcesCmd.Flags().Uint32("page-limit", 0, "limit of relations returned per page")
165134
lookupResourcesCmd.Flags().String("cursor", "", "resume pagination from a specific cursor token")
@@ -168,7 +137,6 @@ func RegisterPermissionCmd(rootCmd *cobra.Command) *cobra.Command {
168137

169138
permissionCmd.AddCommand(lookupSubjectsCmd)
170139
lookupSubjectsCmd.Flags().Bool("json", false, "output as JSON")
171-
lookupSubjectsCmd.Flags().String("revision", "", "optional revision at which to check")
172140
lookupSubjectsCmd.Flags().String("caveat-context", "", "the caveat context to send along with the lookup, in JSON form")
173141
registerConsistencyFlags(lookupSubjectsCmd.Flags())
174142

internal/commands/permission_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ func TestCheckErrorWithDebugInformation(t *testing.T) {
6666
}()
6767

6868
cmd := &cobra.Command{}
69-
cmd.Flags().String("revision", "", "optional revision at which to check")
70-
_ = cmd.Flags().MarkHidden("revision")
7169
cmd.Flags().Bool("explain", false, "requests debug information from SpiceDB and prints out a trace of the requests")
7270
cmd.Flags().Bool("schema", false, "requests debug information from SpiceDB and prints out the schema used")
7371
cmd.Flags().Bool("error-on-no-permission", false, "if true, zed will return exit code 1 if subject does not have unconditional permission")
@@ -91,8 +89,6 @@ func TestCheckErrorWithInvalidDebugInformation(t *testing.T) {
9189
}()
9290

9391
cmd := &cobra.Command{}
94-
cmd.Flags().String("revision", "", "optional revision at which to check")
95-
_ = cmd.Flags().MarkHidden("revision")
9692
cmd.Flags().Bool("explain", false, "requests debug information from SpiceDB and prints out a trace of the requests")
9793
cmd.Flags().Bool("schema", false, "requests debug information from SpiceDB and prints out the schema used")
9894
cmd.Flags().Bool("error-on-no-permission", false, "if true, zed will return exit code 1 if subject does not have unconditional permission")

internal/commands/relationship.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ func RegisterRelationshipCmd(rootCmd *cobra.Command) *cobra.Command {
3838
Args: ValidationWrapper(StdinOrExactArgs(3)),
3939
ValidArgsFunction: GetArgs(ResourceID, Permission, SubjectTypeWithOptionalRelation),
4040
RunE: writeRelationshipCmdFunc(v1.RelationshipUpdate_OPERATION_CREATE, os.Stdin),
41+
Aliases: []string{"write"},
4142
Example: `
4243
zed relationship create document:budget view user:anne --expiration-time "2025-12-31T23:59:59Z"
4344
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 {
104105

105106
relationshipCmd.AddCommand(readCmd)
106107
readCmd.Flags().Bool("json", false, "output as JSON")
107-
readCmd.Flags().String("revision", "", "optional revision at which to check")
108-
_ = readCmd.Flags().MarkHidden("revision")
109108
readCmd.Flags().String("subject-filter", "", "optional subject filter")
110109
readCmd.Flags().Uint32("page-limit", 100, "limit of relations returned per page")
111110
registerConsistencyFlags(readCmd.Flags())
@@ -114,8 +113,6 @@ func RegisterRelationshipCmd(rootCmd *cobra.Command) *cobra.Command {
114113
bulkDeleteCmd.Flags().Bool("force", false, "force deletion of all elements in batches defined by <optional-limit>")
115114
bulkDeleteCmd.Flags().String("subject-filter", "", "optional subject filter")
116115
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")
117-
bulkDeleteCmd.Flags().Bool("estimate-count", true, "estimate the count of relationships to be deleted")
118-
_ = bulkDeleteCmd.Flags().MarkDeprecated("estimate-count", "no longer used, make use of --optional-limit instead")
119116
return relationshipCmd
120117
}
121118

internal/commands/watch.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,6 @@ var (
2727
watchRelationshipFilters []string
2828
)
2929

30-
func RegisterWatchCmd(rootCmd *cobra.Command) *cobra.Command {
31-
watchCmd := &cobra.Command{
32-
Use: "watch [object_types, ...] [revision]",
33-
Short: "Watches the stream of relationship updates and schema updates from the server",
34-
Args: ValidationWrapper(cobra.RangeArgs(0, 2)),
35-
RunE: watchCmdFunc,
36-
Deprecated: "please use `zed relationship watch` instead",
37-
}
38-
39-
rootCmd.AddCommand(watchCmd)
40-
watchCmd.Flags().StringSliceVar(&watchObjectTypes, "object_types", nil, "optional object types to watch updates for")
41-
watchCmd.Flags().StringVar(&watchRevision, "revision", "", "optional revision at which to start watching")
42-
watchCmd.Flags().BoolVar(&watchTimestamps, "timestamp", false, "shows timestamp of incoming update events")
43-
return watchCmd
44-
}
45-
4630
func RegisterWatchRelationshipCmd(parentCmd *cobra.Command) *cobra.Command {
4731
watchRelationshipsCmd := &cobra.Command{
4832
Use: "watch [object_types, ...] [revision]",

0 commit comments

Comments
 (0)