diff --git a/internal/commands/relationship.go b/internal/commands/relationship.go index 69fd519..c6272f7 100644 --- a/internal/commands/relationship.go +++ b/internal/commands/relationship.go @@ -51,7 +51,7 @@ func RegisterRelationshipCmd(rootCmd *cobra.Command) *cobra.Command { relationshipCmd.AddCommand(bulkDeleteCmd) bulkDeleteCmd.Flags().Bool("force", false, "force deletion of all elements in batches defined by ") bulkDeleteCmd.Flags().String("subject-filter", "", "optional subject filter") - bulkDeleteCmd.Flags().Uint("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().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 @@ -133,12 +133,13 @@ func bulkDeleteRelationships(cmd *cobra.Command, args []string) error { }() allowPartialDeletions := cobrautil.MustGetBool(cmd, "force") - optionalLimit := cobrautil.MustGetUint(cmd, "optional-limit") + optionalLimit := cobrautil.MustGetUint32(cmd, "optional-limit") + var resp *v1.DeleteRelationshipsResponse for { delRequest := &v1.DeleteRelationshipsRequest{ RelationshipFilter: filter, - OptionalLimit: uint32(optionalLimit), + OptionalLimit: optionalLimit, OptionalAllowPartialDeletions: allowPartialDeletions, } log.Trace().Interface("request", delRequest).Msg("deleting relationships") diff --git a/internal/commands/relationship_test.go b/internal/commands/relationship_test.go index bdfe69a..dd3eff8 100644 --- a/internal/commands/relationship_test.go +++ b/internal/commands/relationship_test.go @@ -579,7 +579,7 @@ func TestBulkDeleteForcing(t *testing.T) { client.NewClient = zedtesting.ClientFromConn(conn) testCmd := zedtesting.CreateTestCobraCommandWithFlagValue(t, zedtesting.StringFlag{FlagName: "subject-filter"}, - zedtesting.UintFlag{FlagName: "optional-limit", FlagValue: 1}, + zedtesting.UintFlag32{FlagName: "optional-limit", FlagValue: 1}, zedtesting.BoolFlag{FlagName: "force", FlagValue: true}) c, err := client.NewClient(testCmd) require.NoError(t, err) @@ -629,7 +629,7 @@ func TestBulkDeleteManyForcing(t *testing.T) { client.NewClient = zedtesting.ClientFromConn(conn) testCmd := zedtesting.CreateTestCobraCommandWithFlagValue(t, zedtesting.StringFlag{FlagName: "subject-filter"}, - zedtesting.UintFlag{FlagName: "optional-limit", FlagValue: 1}, + zedtesting.UintFlag32{FlagName: "optional-limit", FlagValue: 1}, zedtesting.BoolFlag{FlagName: "force", FlagValue: true}) c, err := client.NewClient(testCmd) require.NoError(t, err) @@ -671,7 +671,7 @@ func TestBulkDeleteNotForcing(t *testing.T) { client.NewClient = zedtesting.ClientFromConn(conn) testCmd := zedtesting.CreateTestCobraCommandWithFlagValue(t, zedtesting.StringFlag{FlagName: "subject-filter"}, - zedtesting.UintFlag{FlagName: "optional-limit", FlagValue: 1}, + zedtesting.UintFlag32{FlagName: "optional-limit", FlagValue: 1}, zedtesting.BoolFlag{FlagName: "force", FlagValue: false}) c, err := client.NewClient(testCmd) require.NoError(t, err) diff --git a/internal/testing/test_helpers.go b/internal/testing/test_helpers.go index aa180c9..0370308 100644 --- a/internal/testing/test_helpers.go +++ b/internal/testing/test_helpers.go @@ -81,6 +81,11 @@ type UintFlag struct { FlagValue uint } +type UintFlag32 struct { + FlagName string + FlagValue uint32 +} + type DurationFlag struct { FlagName string FlagValue time.Duration @@ -100,6 +105,8 @@ func CreateTestCobraCommandWithFlagValue(t *testing.T, flagAndValues ...any) *co c.Flags().Int(f.FlagName, f.FlagValue, "") case UintFlag: c.Flags().Uint(f.FlagName, f.FlagValue, "") + case UintFlag32: + c.Flags().Uint32(f.FlagName, f.FlagValue, "") case DurationFlag: c.Flags().Duration(f.FlagName, f.FlagValue, "") default: