Skip to content

Commit

Permalink
fix: correct flag value type in delete, import, and write (#389)
Browse files Browse the repository at this point in the history
  • Loading branch information
ewanharris authored Sep 9, 2024
2 parents 34fa32f + 57338c3 commit 52c4302
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
4 changes: 2 additions & 2 deletions cmd/store/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@ var importCmd = &cobra.Command{
func init() {
importCmd.Flags().String("file", "", "File Name. The file should have the store")
importCmd.Flags().String("store-id", "", "Store ID")
importCmd.Flags().Int("max-tuples-per-write", tuple.MaxTuplesPerWrite, "Max tuples per write chunk.")
importCmd.Flags().Int("max-parallel-requests", tuple.MaxParallelRequests, "Max number of requests to issue to the server in parallel.") //nolint:lll
importCmd.Flags().Int32("max-tuples-per-write", tuple.MaxTuplesPerWrite, "Max tuples per write chunk.")
importCmd.Flags().Int32("max-parallel-requests", tuple.MaxParallelRequests, "Max number of requests to issue to the server in parallel.") //nolint:lll

if err := importCmd.MarkFlagRequired("file"); err != nil {
fmt.Printf("error setting flag as required - %v: %v\n", "cmd/models/write", err)
Expand Down
4 changes: 2 additions & 2 deletions cmd/tuple/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ var deleteCmd = &cobra.Command{
func init() {
deleteCmd.Flags().String("file", "", "Tuples file")
deleteCmd.Flags().String("model-id", "", "Model ID")
deleteCmd.Flags().Int("max-tuples-per-write", MaxTuplesPerWrite, "Max tuples per write chunk.")
deleteCmd.Flags().Int("max-parallel-requests", MaxParallelRequests, "Max number of requests to issue to the server in parallel.") //nolint:lll
deleteCmd.Flags().Int32("max-tuples-per-write", MaxTuplesPerWrite, "Max tuples per write chunk.")
deleteCmd.Flags().Int32("max-parallel-requests", MaxParallelRequests, "Max number of requests to issue to the server in parallel.") //nolint:lll
}

func ExactArgsOrFlag(n int, flag string) cobra.PositionalArgs {
Expand Down
14 changes: 8 additions & 6 deletions cmd/tuple/import.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ import (
"github.com/openfga/cli/internal/output"
)

// MaxTuplesPerWrite Limit the tuples in a single batch.
var MaxTuplesPerWrite = 1
const (
// MaxTuplesPerWrite Limit the tuples in a single batch.
MaxTuplesPerWrite = 1

// MaxParallelRequests Limit the parallel writes to the API.
var MaxParallelRequests = 10
// MaxParallelRequests Limit the parallel writes to the API.
MaxParallelRequests = 10
)

type failedWriteResponse struct {
TupleKey client.ClientTupleKey `json:"tuple_key"`
Expand Down Expand Up @@ -206,6 +208,6 @@ var importCmd = &cobra.Command{
func init() {
importCmd.Flags().String("model-id", "", "Model ID")
importCmd.Flags().String("file", "", "Tuples file")
importCmd.Flags().Int("max-tuples-per-write", MaxTuplesPerWrite, "Max tuples per write chunk.")
importCmd.Flags().Int("max-parallel-requests", MaxParallelRequests, "Max number of requests to issue to the server in parallel.") //nolint:lll
importCmd.Flags().Int32("max-tuples-per-write", MaxTuplesPerWrite, "Max tuples per write chunk.")
importCmd.Flags().Int32("max-parallel-requests", MaxParallelRequests, "Max number of requests to issue to the server in parallel.") //nolint:lll
}
4 changes: 2 additions & 2 deletions cmd/tuple/write.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,6 @@ func init() {
writeCmd.Flags().String("file", "", "Tuples file")
writeCmd.Flags().String("condition-name", "", "Condition Name")
writeCmd.Flags().String("condition-context", "", "Condition Context (as a JSON string)")
writeCmd.Flags().Int("max-tuples-per-write", MaxTuplesPerWrite, "Max tuples per write chunk.")
writeCmd.Flags().Int("max-parallel-requests", MaxParallelRequests, "Max number of requests to issue to the server in parallel.")
writeCmd.Flags().Int32("max-tuples-per-write", MaxTuplesPerWrite, "Max tuples per write chunk.")
writeCmd.Flags().Int32("max-parallel-requests", MaxParallelRequests, "Max number of requests to issue to the server in parallel.")
}

0 comments on commit 52c4302

Please sign in to comment.