From 575c6c95c8cbb2f33f7a7eaea8f808ec8492678a Mon Sep 17 00:00:00 2001 From: Owen Nelson Date: Mon, 25 Sep 2023 16:57:13 -0700 Subject: [PATCH 1/3] add `--expunge` option to `event-type delete` --- cmd/event.go | 11 +++++++++-- go.mod | 2 +- go.sum | 4 ++++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/cmd/event.go b/cmd/event.go index 2e39aa4..3438ad9 100644 --- a/cmd/event.go +++ b/cmd/event.go @@ -152,15 +152,22 @@ Example Schema: // parse args eventID := args[0] - utils.Confirm(fmt.Sprintf("Are you sure you want to delete the the event with id: %s", eventID)) + utils.Confirm(fmt.Sprintf("Are you sure you want to delete the event with id: %s", eventID)) svixClient := getSvixClientOrExit() - err := svixClient.EventType.Delete(cmd.Context(), eventID) + options := &svix.EventTypeDeleteOptions{} + expunge, _ := cmd.Flags().GetBool("expunge") + if cmd.Flags().Changed("expunge") { + options.Expunge = &expunge + } + err := svixClient.EventType.DeleteWithOptions(cmd.Context(), eventID, options) printer.CheckErr(err) fmt.Printf("Event Type \"%s\" Deleted!\n", eventID) }, } + + delete.Flags().Bool("expunge", false, "permanently delete instead of archiving") etc.cmd.AddCommand(delete) return etc diff --git a/go.mod b/go.mod index f13d29c..1fbd449 100644 --- a/go.mod +++ b/go.mod @@ -14,6 +14,6 @@ require ( github.com/spf13/afero v1.6.0 // indirect github.com/spf13/cobra v1.3.0 github.com/spf13/viper v1.10.0 - github.com/svix/svix-webhooks v1.7.0 + github.com/svix/svix-webhooks v1.12.1-0.20230925234853-e39398a6349d github.com/tidwall/pretty v1.1.1 ) diff --git a/go.sum b/go.sum index 120384f..bf44fbe 100644 --- a/go.sum +++ b/go.sum @@ -362,6 +362,10 @@ github.com/svix/svix-webhooks v0.75.0 h1:GH8myVTh6EDlVIHbyEXqs6bA8a/zSBH3JmZKRdD github.com/svix/svix-webhooks v0.75.0/go.mod h1:vWwH7D6zMhF9pCLfgLlogcXGDmnGqIJeIT9AXorZTAQ= github.com/svix/svix-webhooks v1.7.0 h1:rfJ9yGc1h9odbdoNW8+dkO4ZdgajPYXvTdLqJsLBcIo= github.com/svix/svix-webhooks v1.7.0/go.mod h1:q3Z9c8NXqDRPZviI+zLMToAja+bjhTw929cMVhJirOI= +github.com/svix/svix-webhooks v1.12.1-0.20230925233234-3ab7663b4d56 h1:PQ68xHJkoZ8Y0O283S+QRg9X6vbUyWKvuQHauLaaC3U= +github.com/svix/svix-webhooks v1.12.1-0.20230925233234-3ab7663b4d56/go.mod h1:q3Z9c8NXqDRPZviI+zLMToAja+bjhTw929cMVhJirOI= +github.com/svix/svix-webhooks v1.12.1-0.20230925234853-e39398a6349d h1:0EDWjQWi6yyBwekvXhMxbmM7M/llfGeYCeiUQvVfe8g= +github.com/svix/svix-webhooks v1.12.1-0.20230925234853-e39398a6349d/go.mod h1:q3Z9c8NXqDRPZviI+zLMToAja+bjhTw929cMVhJirOI= github.com/tidwall/pretty v1.1.1 h1:nt6/Ot5LtZnJCWwEFlelOixPo0xhPFsuZlKyOL3Xfnc= github.com/tidwall/pretty v1.1.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= From 7beaf819bdffdd0179b0eef67d8b0a8f00204fa9 Mon Sep 17 00:00:00 2001 From: Owen Nelson Date: Tue, 26 Sep 2023 10:47:12 -0700 Subject: [PATCH 2/3] update endpoint version to be optional --- cmd/endpoint.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/cmd/endpoint.go b/cmd/endpoint.go index 3369711..f9d5456 100644 --- a/cmd/endpoint.go +++ b/cmd/endpoint.go @@ -105,10 +105,11 @@ Example Schema: printer.CheckErr(err) ep.Disabled = &disabledFlag } - versionFlag, err := cmd.Flags().GetInt32(versionFlagName) - printer.CheckErr(err) - ep.Version = versionFlag - + if cmd.Flags().Changed(versionFlagName) { + versionFlag, err := cmd.Flags().GetInt32(versionFlagName) + printer.CheckErr(err) + ep.Version.Set(&versionFlag) + } svixClient := getSvixClientOrExit() out, err := svixClient.Endpoint.Create(cmd.Context(), appID, &ep) printer.CheckErr(err) @@ -117,7 +118,7 @@ Example Schema: }, } create.Flags().String(urlFlagName, "", "") - create.Flags().Int32(versionFlagName, 1, "") + create.Flags().Int32(versionFlagName, 0, "") create.Flags().StringArray(filterTypesFlagName, []string{}, "") create.Flags().Int32(rateLimitFlagName, 0, "Rate Limit of the endpoint (optional)") create.Flags().Bool(disabledFlagName, false, "") @@ -189,7 +190,7 @@ Example Schema: if cmd.Flags().Changed(versionFlagName) { versionFlag, err := cmd.Flags().GetInt32(versionFlagName) printer.CheckErr(err) - ep.Version = versionFlag + ep.Version.Set(&versionFlag) } if cmd.Flags().Changed(filterTypesFlagName) { filterTypesFlag, err := cmd.Flags().GetStringArray(filterTypesFlagName) From c1d347bc9886236932ea3600db8806202254f085 Mon Sep 17 00:00:00 2001 From: Owen Nelson Date: Tue, 26 Sep 2023 18:14:21 -0700 Subject: [PATCH 3/3] bump Go lib to 7bc1d38200ec69b9673311f9bedf6663de095ca1 The current head of `main`: --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index 1fbd449..7db3ad3 100644 --- a/go.mod +++ b/go.mod @@ -14,6 +14,6 @@ require ( github.com/spf13/afero v1.6.0 // indirect github.com/spf13/cobra v1.3.0 github.com/spf13/viper v1.10.0 - github.com/svix/svix-webhooks v1.12.1-0.20230925234853-e39398a6349d + github.com/svix/svix-webhooks v1.12.1-0.20230926011735-7bc1d38200ec github.com/tidwall/pretty v1.1.1 ) diff --git a/go.sum b/go.sum index bf44fbe..9bfa23e 100644 --- a/go.sum +++ b/go.sum @@ -366,6 +366,8 @@ github.com/svix/svix-webhooks v1.12.1-0.20230925233234-3ab7663b4d56 h1:PQ68xHJko github.com/svix/svix-webhooks v1.12.1-0.20230925233234-3ab7663b4d56/go.mod h1:q3Z9c8NXqDRPZviI+zLMToAja+bjhTw929cMVhJirOI= github.com/svix/svix-webhooks v1.12.1-0.20230925234853-e39398a6349d h1:0EDWjQWi6yyBwekvXhMxbmM7M/llfGeYCeiUQvVfe8g= github.com/svix/svix-webhooks v1.12.1-0.20230925234853-e39398a6349d/go.mod h1:q3Z9c8NXqDRPZviI+zLMToAja+bjhTw929cMVhJirOI= +github.com/svix/svix-webhooks v1.12.1-0.20230926011735-7bc1d38200ec h1:q7YwrxoMXMHBhlrNqshcI+X+1zb5D8gNkNqsom3n+Dc= +github.com/svix/svix-webhooks v1.12.1-0.20230926011735-7bc1d38200ec/go.mod h1:q3Z9c8NXqDRPZviI+zLMToAja+bjhTw929cMVhJirOI= github.com/tidwall/pretty v1.1.1 h1:nt6/Ot5LtZnJCWwEFlelOixPo0xhPFsuZlKyOL3Xfnc= github.com/tidwall/pretty v1.1.1/go.mod h1:ITEVvHYasfjBbM0u2Pg8T2nJnzm8xPwvNhhsoaGGjNU= github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=