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

Add tctl schedule commands #221

Merged
merged 3 commits into from
Jun 14, 2022
Merged
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
Prev Previous commit
review comments, remove/tweak aliases, etc
dnr committed Jun 9, 2022
commit 1ff0bb6dbbea66a442b51ccd0ebe02fd4c7906f8
2 changes: 1 addition & 1 deletion cli/commands.go
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ var tctlCommands = []*cli.Command{
},
{
Name: "schedule",
Aliases: []string{"sch"},
Aliases: []string{"s"},
Usage: "Operations on schedules",
Subcommands: newScheduleCommands(),
},
4 changes: 0 additions & 4 deletions cli/flags.go
Original file line number Diff line number Diff line change
@@ -233,11 +233,9 @@ var (
FlagScheduleID = "schedule-id"
FlagScheduleIDAlias = []string{"sid"}
FlagOverlapPolicy = "overlap-policy"
FlagOverlapPolicyAlias = []string{"op"}
FlagCalendar = "calendar"
FlagCalendarAlias = []string{"cal"}
FlagInterval = "interval"
FlagIntervalAlias = []string{"int"}
FlagStartTime = "start-time"
FlagEndTime = "end-time"
FlagJitter = "jitter"
@@ -249,9 +247,7 @@ var (
FlagCatchupWindow = "catchup-window"
FlagPauseOnFailure = "pause-on-failure"
FlagPause = "pause"
FlagPauseAlias = []string{"p"}
FlagUnpause = "unpause"
FlagUnpauseAlias = []string{"u"}

FlagProtoType = "type"
FlagHexData = "hex-data"
30 changes: 12 additions & 18 deletions cli/schedule.go
Original file line number Diff line number Diff line change
@@ -35,13 +35,12 @@ func newScheduleCommands() []*cli.Command {
sid := &cli.StringFlag{
Name: FlagScheduleID,
Aliases: FlagScheduleIDAlias,
Usage: "Schedule id",
Usage: "Schedule Id",
Required: true,
}
overlap := &cli.StringFlag{
Name: FlagOverlapPolicy,
Aliases: FlagOverlapPolicyAlias,
Usage: "Overlap policy: Skip, BufferOne, BufferAll, CancelOther, TerminateOther, AllowAll",
Name: FlagOverlapPolicy,
Usage: "Overlap policy: Skip, BufferOne, BufferAll, CancelOther, TerminateOther, AllowAll",
}

scheduleSpecFlags := []cli.Flag{
@@ -51,9 +50,8 @@ func newScheduleCommands() []*cli.Command {
Usage: `Calendar specification in JSON, e.g. {"dayOfWeek":"Fri","hour":"17","minute":"5"}`,
Copy link
Contributor

Choose a reason for hiding this comment

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

do we have docs for this? if yes we can add a link right here for details

Copy link
Member Author

Choose a reason for hiding this comment

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

docs aren't written yet. it's coming up soon on my list of stuff to do. we can add a link later.

also, commas won't work in this field until we fix the cli issue I mentioned

},
&cli.StringSliceFlag{
Name: FlagInterval,
Aliases: FlagIntervalAlias,
Usage: "Interval duration, e.g. 90m, or 90m/13m to include phase offset",
Name: FlagInterval,
Usage: "Interval duration, e.g. 90m, or 90m/13m to include phase offset",
},
&cli.StringFlag{
Name: FlagStartTime,
@@ -147,7 +145,6 @@ func newScheduleCommands() []*cli.Command {
},
{
Name: "update",
Aliases: []string{"up"},
Usage: "Updates a schedule with a new definition (full replacement, not patch)",
Description: "Takes a schedule specification plus all the same args as starting a workflow",
Flags: createFlags,
@@ -159,14 +156,12 @@ func newScheduleCommands() []*cli.Command {
Flags: []cli.Flag{
sid,
&cli.BoolFlag{
Name: FlagPause,
Aliases: FlagPauseAlias,
Usage: "Pauses the schedule",
Name: FlagPause,
Usage: "Pauses the schedule",
},
&cli.BoolFlag{
Name: FlagUnpause,
Aliases: FlagUnpauseAlias,
Usage: "Unpauses the schedule",
Name: FlagUnpause,
Usage: "Unpauses the schedule",
},
&cli.StringFlag{
Name: FlagReason,
@@ -219,17 +214,16 @@ func newScheduleCommands() []*cli.Command {
Action: DescribeSchedule,
},
{
Name: "delete",
Aliases: []string{"rm"},
Usage: "Deletes a schedule",
Name: "delete",
Usage: "Deletes a schedule",
Flags: []cli.Flag{
sid,
},
Action: DeleteSchedule,
},
{
Name: "list",
Aliases: []string{"ls"},
Aliases: []string{"l"},
Usage: "Lists schedules",
Flags: append([]cli.Flag{}, flags.FlagsForPaginationAndRendering...),
Action: ListSchedules,
2 changes: 1 addition & 1 deletion cli/schedule_commands.go
Original file line number Diff line number Diff line change
@@ -264,7 +264,7 @@ func CreateSchedule(c *cli.Context) error {

_, err = frontendClient.CreateSchedule(ctx, req)
if err != nil {
return fmt.Errorf("failed to create schedule.\n%s", err)
return fmt.Errorf("unable to create schedule: %s", err)
}

fmt.Println(color.Green(c, "Schedule created"))