Skip to content

Commit 01ae05a

Browse files
fix an issue where status --all was stopping at the first profile with no schedule
1 parent 237a87f commit 01ae05a

File tree

1 file changed

+30
-9
lines changed

1 file changed

+30
-9
lines changed

commands.go

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -425,27 +425,48 @@ func removeSchedule(_ io.Writer, c *config.Config, flags commandLineFlags, args
425425
}
426426

427427
func statusSchedule(_ io.Writer, c *config.Config, flags commandLineFlags, args []string) error {
428+
if !containsString(args, "--all") {
429+
// simple case of displaying status for one profile
430+
scheduler, profile, schedules, err := getScheduleJobs(c, flags)
431+
if err != nil {
432+
return err
433+
}
434+
if len(schedules) == 0 {
435+
clog.Warningf("profile %s has no schedule", flags.name)
436+
return nil
437+
}
438+
return statusScheduleProfile(scheduler, profile, schedules, flags)
439+
}
440+
428441
for _, profileName := range selectProfiles(c, flags, args) {
429442
profileFlags := flagsForProfile(flags, profileName)
430-
431443
scheduler, profile, schedules, err := getScheduleJobs(c, profileFlags)
432-
if err == nil {
433-
err = requireScheduleJobs(schedules, profileFlags)
434-
}
435444
if err != nil {
436445
return err
437446
}
438-
439-
displayProfileDeprecationNotices(profile)
440-
441-
err = statusJobs(scheduler, profileName, convertSchedules(schedules))
447+
// it's all fine if this profile has no schedule
448+
if len(schedules) == 0 {
449+
continue
450+
}
451+
err = statusScheduleProfile(scheduler, profile, schedules, profileFlags)
442452
if err != nil {
443-
return retryElevated(err, flags)
453+
// display the error but keep going with the other profiles
454+
clog.Error(err)
444455
}
445456
}
446457
return nil
447458
}
448459

460+
func statusScheduleProfile(scheduler string, profile *config.Profile, schedules []*config.ScheduleConfig, flags commandLineFlags) error {
461+
displayProfileDeprecationNotices(profile)
462+
463+
err := statusJobs(scheduler, flags.name, convertSchedules(schedules))
464+
if err != nil {
465+
return retryElevated(err, flags)
466+
}
467+
return nil
468+
}
469+
449470
func getScheduleJobs(c *config.Config, flags commandLineFlags) (string, *config.Profile, []*config.ScheduleConfig, error) {
450471
global, err := c.GetGlobalSection()
451472
if err != nil {

0 commit comments

Comments
 (0)