Skip to content
This repository was archived by the owner on Dec 28, 2024. It is now read-only.

Commit ed3dbf6

Browse files
authored
Merge pull request #100 from svix/onelson/expunge-event-type
add `--expunge` option to `event-type delete`
2 parents c12580f + c1d347b commit ed3dbf6

File tree

4 files changed

+23
-9
lines changed

4 files changed

+23
-9
lines changed

cmd/endpoint.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,11 @@ Example Schema:
105105
printer.CheckErr(err)
106106
ep.Disabled = &disabledFlag
107107
}
108-
versionFlag, err := cmd.Flags().GetInt32(versionFlagName)
109-
printer.CheckErr(err)
110-
ep.Version = versionFlag
111-
108+
if cmd.Flags().Changed(versionFlagName) {
109+
versionFlag, err := cmd.Flags().GetInt32(versionFlagName)
110+
printer.CheckErr(err)
111+
ep.Version.Set(&versionFlag)
112+
}
112113
svixClient := getSvixClientOrExit()
113114
out, err := svixClient.Endpoint.Create(cmd.Context(), appID, &ep)
114115
printer.CheckErr(err)
@@ -117,7 +118,7 @@ Example Schema:
117118
},
118119
}
119120
create.Flags().String(urlFlagName, "", "")
120-
create.Flags().Int32(versionFlagName, 1, "")
121+
create.Flags().Int32(versionFlagName, 0, "")
121122
create.Flags().StringArray(filterTypesFlagName, []string{}, "")
122123
create.Flags().Int32(rateLimitFlagName, 0, "Rate Limit of the endpoint (optional)")
123124
create.Flags().Bool(disabledFlagName, false, "")
@@ -189,7 +190,7 @@ Example Schema:
189190
if cmd.Flags().Changed(versionFlagName) {
190191
versionFlag, err := cmd.Flags().GetInt32(versionFlagName)
191192
printer.CheckErr(err)
192-
ep.Version = versionFlag
193+
ep.Version.Set(&versionFlag)
193194
}
194195
if cmd.Flags().Changed(filterTypesFlagName) {
195196
filterTypesFlag, err := cmd.Flags().GetStringArray(filterTypesFlagName)

cmd/event.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,15 +152,22 @@ Example Schema:
152152
// parse args
153153
eventID := args[0]
154154

155-
utils.Confirm(fmt.Sprintf("Are you sure you want to delete the the event with id: %s", eventID))
155+
utils.Confirm(fmt.Sprintf("Are you sure you want to delete the event with id: %s", eventID))
156156

157157
svixClient := getSvixClientOrExit()
158-
err := svixClient.EventType.Delete(cmd.Context(), eventID)
158+
options := &svix.EventTypeDeleteOptions{}
159+
expunge, _ := cmd.Flags().GetBool("expunge")
160+
if cmd.Flags().Changed("expunge") {
161+
options.Expunge = &expunge
162+
}
163+
err := svixClient.EventType.DeleteWithOptions(cmd.Context(), eventID, options)
159164
printer.CheckErr(err)
160165

161166
fmt.Printf("Event Type \"%s\" Deleted!\n", eventID)
162167
},
163168
}
169+
170+
delete.Flags().Bool("expunge", false, "permanently delete instead of archiving")
164171
etc.cmd.AddCommand(delete)
165172

166173
return etc

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ require (
1414
github.com/spf13/afero v1.6.0 // indirect
1515
github.com/spf13/cobra v1.3.0
1616
github.com/spf13/viper v1.10.0
17-
github.com/svix/svix-webhooks v1.7.0
17+
github.com/svix/svix-webhooks v1.12.1-0.20230926011735-7bc1d38200ec
1818
github.com/tidwall/pretty v1.1.1
1919
)

go.sum

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,12 @@ github.com/svix/svix-webhooks v0.75.0 h1:GH8myVTh6EDlVIHbyEXqs6bA8a/zSBH3JmZKRdD
362362
github.com/svix/svix-webhooks v0.75.0/go.mod h1:vWwH7D6zMhF9pCLfgLlogcXGDmnGqIJeIT9AXorZTAQ=
363363
github.com/svix/svix-webhooks v1.7.0 h1:rfJ9yGc1h9odbdoNW8+dkO4ZdgajPYXvTdLqJsLBcIo=
364364
github.com/svix/svix-webhooks v1.7.0/go.mod h1:q3Z9c8NXqDRPZviI+zLMToAja+bjhTw929cMVhJirOI=
365+
github.com/svix/svix-webhooks v1.12.1-0.20230925233234-3ab7663b4d56 h1:PQ68xHJkoZ8Y0O283S+QRg9X6vbUyWKvuQHauLaaC3U=
366+
github.com/svix/svix-webhooks v1.12.1-0.20230925233234-3ab7663b4d56/go.mod h1:q3Z9c8NXqDRPZviI+zLMToAja+bjhTw929cMVhJirOI=
367+
github.com/svix/svix-webhooks v1.12.1-0.20230925234853-e39398a6349d h1:0EDWjQWi6yyBwekvXhMxbmM7M/llfGeYCeiUQvVfe8g=
368+
github.com/svix/svix-webhooks v1.12.1-0.20230925234853-e39398a6349d/go.mod h1:q3Z9c8NXqDRPZviI+zLMToAja+bjhTw929cMVhJirOI=
369+
github.com/svix/svix-webhooks v1.12.1-0.20230926011735-7bc1d38200ec h1:q7YwrxoMXMHBhlrNqshcI+X+1zb5D8gNkNqsom3n+Dc=
370+
github.com/svix/svix-webhooks v1.12.1-0.20230926011735-7bc1d38200ec/go.mod h1:q3Z9c8NXqDRPZviI+zLMToAja+bjhTw929cMVhJirOI=
365371
github.com/tidwall/pretty v1.1.1 h1:nt6/Ot5LtZnJCWwEFlelOixPo0xhPFsuZlKyOL3Xfnc=
366372
github.com/tidwall/pretty v1.1.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU=
367373
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=

0 commit comments

Comments
 (0)