Skip to content

Commit

Permalink
Merge pull request #45 from fopina/temp/mixed_hash
Browse files Browse the repository at this point in the history
temporarily allow H and ~ for hash schedule (to migrate jobs)
  • Loading branch information
fopina authored Sep 16, 2024
2 parents 5e02981 + 70139a8 commit 5411167
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions dkron/job.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ func (j *Job) nameHash() int {
func (j *Job) scheduleHash() string {
spec := j.Schedule

if !strings.Contains(spec, HashSymbol) {
if !strings.Contains(spec, HashSymbol) && !strings.Contains(spec, "H") {
return spec
}

Expand All @@ -339,7 +339,7 @@ func (j *Job) scheduleHash() string {
continue
}

if strings.Contains(part, HashSymbol) {
if strings.Contains(part, HashSymbol) || strings.Contains(part, "H") {
// mods taken in accordance with https://dkron.io/docs/usage/cron-spec/#cron-expression-format
partHash := hash
switch partIndex {
Expand All @@ -355,6 +355,7 @@ func (j *Job) scheduleHash() string {
partHash %= 60
}
parts[index] = strings.ReplaceAll(part, HashSymbol, strconv.Itoa(partHash))
parts[index] = strings.ReplaceAll(part, "H", strconv.Itoa(partHash))
}

partIndex++
Expand Down

0 comments on commit 5411167

Please sign in to comment.