Пример #1
0
func (c *Cron) setSchedule(args haiconf.CommandArgs) error {
	_, present := args["Schedule"]
	if !present {
		return haiconf.NewArgError("Schedule must be provided", args)
	}

	schedule, err := utils.ToStringMap(args["Schedule"].(map[string]interface{}))
	if err != nil {
		return err
	}

	predefined, err := c.checkPredefined(schedule)
	if err != nil {
		return err
	}

	if len(predefined) > 0 {
		c.Schedule = PREDEFINED_SCHEDULES[predefined]
		return nil
	}

	nonPredefined, err := c.checkNonPredefined(schedule)
	if err != nil {
		return err
	}
	c.Schedule = nonPredefined

	return nil
}
Пример #2
0
func (c *Cron) setEnv(args haiconf.CommandArgs) error {
	_, present := args["Env"]
	if present {
		env, err := utils.ToStringMap(args["Env"].(map[string]interface{}))
		if err != nil {
			return err
		}

		c.Env = env
	}

	return nil
}