Skip to content

Commit

Permalink
Drop cursor from flags
Browse files Browse the repository at this point in the history
  • Loading branch information
0michalsokolowski0 committed Aug 29, 2024
1 parent 0003539 commit 90e78ad
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 24 deletions.
5 changes: 0 additions & 5 deletions internal/cmd/stack/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,11 +163,6 @@ var flagLimit = &cli.UintFlag{
Usage: "[Optional] Limit the number of items to return",
}

var flagCursor = &cli.StringFlag{
Name: "cursor",
Usage: "[Optional] Cursor indicates the point after which to return results, allowing for fetching the next set of results in a paginated query.",
}

var flagSearch = &cli.StringFlag{
Name: "search",
Usage: "[Optional] Search performs a full-text search on fields: \"name\", \"slug\" and \"label\".",
Expand Down
1 change: 0 additions & 1 deletion internal/cmd/stack/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ func searchAllStacks(ctx context.Context, input structs.SearchInput) ([]stack, e

pageInput := structs.SearchInput{
First: graphql.NewInt(50),
After: input.After,
FullTextSearch: input.FullTextSearch,
}
for {
Expand Down
18 changes: 1 addition & 17 deletions internal/cmd/stack/paging.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (
type paging struct {
Limit *uint
Search *string
Cursor *string
}

func newPaging(cliCtx *cli.Context) (paging, error) {
Expand All @@ -33,41 +32,26 @@ func newPaging(cliCtx *cli.Context) (paging, error) {
search = internal.ToPtr(cliCtx.String(flagSearch.Name))
}

var cursor *string
if cliCtx.IsSet(flagCursor.Name) {
if cliCtx.String(flagCursor.Name) == "" {
return paging{}, fmt.Errorf("cursor must be non-empty")
}

cursor = internal.ToPtr(cliCtx.String(flagCursor.Name))
}

return paging{
Limit: limit,
Search: search,
Cursor: cursor,
}, nil
}

func (p paging) toSearchInput() structs.SearchInput {
var after, fullTextSearch *graphql.String
var fullTextSearch *graphql.String

if p.Search != nil {
fullTextSearch = graphql.NewString(graphql.String(*p.Search))
}

if p.Cursor != nil {
after = graphql.NewString(graphql.String(*p.Cursor))
}

var first *graphql.Int
if p.Limit != nil {
first = graphql.NewInt(graphql.Int(*p.Limit))

Check failure on line 50 in internal/cmd/stack/paging.go

View workflow job for this annotation

GitHub Actions / Lint the code

G115: integer overflow conversion uint -> int32 (gosec)
}

return structs.SearchInput{
First: first,
After: after,
FullTextSearch: fullTextSearch,
}
}
1 change: 0 additions & 1 deletion internal/cmd/stack/stack.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ func Command() *cli.Command {
cmd.FlagOutputFormat,
cmd.FlagNoColor,
flagLimit,
flagCursor,
flagSearch,
},
Action: listStacks(),
Expand Down

0 comments on commit 90e78ad

Please sign in to comment.