Skip to content

Commit 668dbaa

Browse files
refactor: slightly change func signatures
1 parent 693aafe commit 668dbaa

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

coderd/prebuilds/preset_snapshot.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,16 +88,16 @@ func (ra *ReconciliationActions) IsNoop() bool {
8888

8989
// MatchesCron checks if the given time matches the cron expression
9090
// Assumes the time is already in the correct timezone
91-
func MatchesCron(cronExpression string, now time.Time) (bool, error) {
91+
func MatchesCron(cronExpression string, at time.Time) (bool, error) {
9292
sched, err := cron.Weekly(cronExpression)
9393
if err != nil {
9494
return false, xerrors.Errorf("failed to parse cron expression: %w", err)
9595
}
9696

97-
return sched.IsWithinRange(now), nil
97+
return sched.IsWithinRange(at), nil
9898
}
9999

100-
func (p PresetSnapshot) CalculateDesiredInstances(now time.Time) (int32, error) {
100+
func (p PresetSnapshot) CalculateDesiredInstances(at time.Time) (int32, error) {
101101
if !p.Preset.AutoscalingEnabled {
102102
return p.Preset.DesiredInstances.Int32, nil
103103
}
@@ -107,11 +107,11 @@ func (p PresetSnapshot) CalculateDesiredInstances(now time.Time) (int32, error)
107107
return 0, xerrors.Errorf("can't parse location %v: %w", p.Preset.AutoscalingTimezone, err)
108108
}
109109

110-
now = now.In(loc)
110+
at = at.In(loc)
111111

112112
// Check each schedule
113113
for _, schedule := range p.PrebuildSchedules {
114-
matches, err := MatchesCron(schedule.CronExpression, now)
114+
matches, err := MatchesCron(schedule.CronExpression, at)
115115
if err != nil {
116116
return 0, xerrors.Errorf("failed to match cron expression: %w", err)
117117
}

0 commit comments

Comments
 (0)