Change cron syntax to standard format (#2678)

* Change cron syntax to standard format
* Add standard cron example in showschedule command

Signed-off-by: Shubham Nazare <shubham4443@gmail.com>
This commit is contained in:
Shubham Nazare
2023-01-02 20:05:58 +05:30
committed by GitHub
parent fcf4fd2e63
commit 922cb34243
8 changed files with 20 additions and 17 deletions
+4 -3
View File
@@ -23,7 +23,7 @@ import (
"github.com/fission/fission/pkg/fission-cli/cmd"
"github.com/pkg/errors"
"github.com/robfig/cron"
"github.com/robfig/cron/v3"
uuid "github.com/satori/go.uuid"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
@@ -74,7 +74,7 @@ func (opts *CreateSubCommand) complete(input cli.Input) (err error) {
cronSpec := input.String(flagkey.TtCron)
if len(cronSpec) == 0 {
return errors.New("Need a cron spec like '0 30 * * * *', '@every 1h30m', or '@hourly'; use --cron")
return errors.New("Need a cron spec like '30 * * * *', '@every 1h30m', or '@hourly'; use --cron")
}
if input.Bool(flagkey.SpecSave) {
@@ -160,7 +160,8 @@ func (opts *CreateSubCommand) run(input cli.Input) error {
}
func getCronNextNActivationTime(cronSpec string, serverTime time.Time, round int) error {
sched, err := cron.Parse(cronSpec)
cronSpecParser := cron.NewParser(cron.SecondOptional | cron.Minute | cron.Hour | cron.Dom | cron.Month | cron.Dow | cron.Descriptor)
sched, err := cronSpecParser.Parse(cronSpec)
if err != nil {
return err
}
+1 -1
View File
@@ -42,7 +42,7 @@ func (opts *ShowSubCommand) run(flaginput cli.Input) error {
cronSpec := flaginput.String(flagkey.TtCron)
if len(cronSpec) == 0 {
return errors.New("need a cron spec like '0 30 * * * *', '@every 1h30m', or '@hourly'; use --cron")
return errors.New("need a cron spec like '0 30 * * * *', '*/2 * * * *', '@every 1h30m', or '@hourly'; use --cron")
}
t := util.GetServerInfo(flaginput, opts.Client()).ServerTime.CurrentTime.UTC()