Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for schedule list query parameter #627

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions temporalcli/commands.gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -1100,6 +1100,7 @@ type TemporalScheduleListCommand struct {
Command cobra.Command
Long bool
ReallyLong bool
Query string
}

func NewTemporalScheduleListCommand(cctx *CommandContext, parent *TemporalScheduleCommand) *TemporalScheduleListCommand {
Expand All @@ -1116,6 +1117,7 @@ func NewTemporalScheduleListCommand(cctx *CommandContext, parent *TemporalSchedu
s.Command.Args = cobra.NoArgs
s.Command.Flags().BoolVarP(&s.Long, "long", "l", false, "Include detailed information.")
s.Command.Flags().BoolVar(&s.ReallyLong, "really-long", false, "Include even more detailed information that's not really usable in table form.")
s.Command.Flags().StringVarP(&s.Query, "query", "q", "", "Filter results using a SQL-like query.")
s.Command.Run = func(c *cobra.Command, args []string) {
if err := s.run(cctx, args); err != nil {
cctx.Options.Fail(err)
Expand Down
1 change: 1 addition & 0 deletions temporalcli/commands.schedule.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ func (c *TemporalScheduleListCommand) run(cctx *CommandContext, args []string) e
res, err := cl.WorkflowService().ListSchedules(cctx, &workflowservice.ListSchedulesRequest{
Namespace: c.Parent.Namespace,
NextPageToken: token,
Query: c.Query,
})
if err != nil {
return err
Expand Down
78 changes: 77 additions & 1 deletion temporalcli/commands.schedule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,20 @@ func (s *SharedServerSuite) TestSchedule_CreateDescribe_SearchAttributes_Memo()
}

func (s *SharedServerSuite) TestSchedule_List() {
schedId, _, res := s.createSchedule("--interval", "10d")

res := s.Execute(
"operator", "search-attribute", "create",
"--address", s.Address(),
"--name", "TestSchedule_List",
"--type", "keyword",
)
s.NoError(res.Err)

schedId, _, res := s.createSchedule(
"--interval",
"10d",
"--schedule-search-attribute", `TestSchedule_List="here"`,
)
s.NoError(res.Err)

// table
Expand Down Expand Up @@ -249,6 +262,69 @@ func (s *SharedServerSuite) TestSchedule_List() {
ok = ok || j.ScheduleId == schedId
}
s.True(ok, "schedule not found in jsonl result")

// JSON query (match)

res = s.Execute(
"schedule", "list",
"--address", s.Address(),
"--query", "TestSchedule_List = 'here'",
"-o", "json",
)
s.NoError(res.Err)
s.NoError(json.Unmarshal(res.Stdout.Bytes(), &j))
ok = false
for _, entry := range j {
ok = ok || entry.ScheduleId == schedId
}
s.True(ok, "schedule not found in json result")

// query (match)

res = s.Execute(
"schedule", "list",
"--address", s.Address(),
"--query", "TestSchedule_List = 'here'",
)
s.NoError(res.Err)
out = res.Stdout.String()
s.ContainsOnSameLine(out, schedId, "DevWorkflow", "false")

// JSON query (no matches)

res = s.Execute(
"schedule", "list",
"--address", s.Address(),
"--query", "TestSchedule_List = 'notHere'",
"-o", "json",
)
s.NoError(res.Err)
s.NoError(json.Unmarshal(res.Stdout.Bytes(), &j))
ok = false
for _, entry := range j {
ok = ok || entry.ScheduleId == schedId
}
s.False(ok, "schedule found in json result, but should not be found")

// query (no matches)

res = s.Execute(
"schedule", "list",
"--address", s.Address(),
"--query", "TestSchedule_List = 'notHere'",
)
s.NoError(res.Err)
out = res.Stdout.String()
s.NotContainsf(out, schedId, "schedule found, but should not be found")

// query (invalid query field)

res = s.Execute(
"schedule", "list",
"--address", s.Address(),
"--query", "unknownField = 'notHere'",
)
s.Error(res.Err)
}

func (s *SharedServerSuite) TestSchedule_Toggle() {
Expand Down
1 change: 1 addition & 0 deletions temporalcli/commandsmd/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,7 @@ The `temporal schedule list` command lists all Schedules in a namespace.

* `--long`, `-l` (bool) - Include detailed information.
* `--really-long` (bool) - Include even more detailed information that's not really usable in table form.
* `--query`, `-q` (string) - Filter results using a SQL-like query.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's say what query language we're actually using / link to the language reference. You may want to wait on #561 to merge and then use the same text from that PR.


### temporal schedule toggle: Pauses or unpauses a Schedule.

Expand Down
Loading