mirror of
https://github.com/zalando-incubator/kube-metrics-adapter.git
synced 2025-05-10 23:49:47 +00:00
Merge pull request #334 from zalando-incubator/nil-fields
Switch Schedule optional fields to pointers
This commit is contained in:
@ -50,11 +50,11 @@ type Schedule struct {
|
||||
Type ScheduleType `json:"type"`
|
||||
// Defines the details of a Repeating schedule.
|
||||
// +optional
|
||||
Period SchedulePeriod `json:"period"`
|
||||
Period *SchedulePeriod `json:"period,omitempty"`
|
||||
// Defines the starting date of a OneTime schedule. It has to
|
||||
// be a RFC3339 formated date.
|
||||
// +optional
|
||||
Date ScheduleDate `json:"date"`
|
||||
Date *ScheduleDate `json:"date,omitempty"`
|
||||
// The duration in minutes that the configured value will be
|
||||
// returned for the defined schedule.
|
||||
DurationMinutes int `json:"durationMinutes"`
|
||||
|
@ -170,7 +170,16 @@ func (in *ScalingScheduleSpec) DeepCopy() *ScalingScheduleSpec {
|
||||
// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
|
||||
func (in *Schedule) DeepCopyInto(out *Schedule) {
|
||||
*out = *in
|
||||
in.Period.DeepCopyInto(&out.Period)
|
||||
if in.Period != nil {
|
||||
in, out := &in.Period, &out.Period
|
||||
*out = new(SchedulePeriod)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
if in.Date != nil {
|
||||
in, out := &in.Date, &out.Date
|
||||
*out = new(ScheduleDate)
|
||||
**out = **in
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -276,7 +276,7 @@ func calculateMetrics(schedules []v1.Schedule, now time.Time, objectReference cu
|
||||
}
|
||||
}
|
||||
case v1.OneTimeSchedule:
|
||||
scheduledTime, err := time.Parse(time.RFC3339, string(schedule.Date))
|
||||
scheduledTime, err := time.Parse(time.RFC3339, string(*schedule.Date))
|
||||
if err != nil {
|
||||
return nil, ErrInvalidScheduleDate
|
||||
}
|
||||
|
@ -670,23 +670,25 @@ func getSchedules(schedules []schedule) (result []v1.Schedule) {
|
||||
for _, schedule := range schedules {
|
||||
switch schedule.kind {
|
||||
case string(v1.OneTimeSchedule):
|
||||
date := v1.ScheduleDate(schedule.date)
|
||||
result = append(result,
|
||||
v1.Schedule{
|
||||
Type: v1.OneTimeSchedule,
|
||||
Date: v1.ScheduleDate(schedule.date),
|
||||
Date: &date,
|
||||
DurationMinutes: schedule.duration,
|
||||
Value: schedule.value,
|
||||
},
|
||||
)
|
||||
case string(v1.RepeatingSchedule):
|
||||
period := v1.SchedulePeriod{
|
||||
StartTime: schedule.startTime,
|
||||
Days: schedule.days,
|
||||
Timezone: schedule.timezone,
|
||||
}
|
||||
result = append(result,
|
||||
v1.Schedule{
|
||||
Type: v1.RepeatingSchedule,
|
||||
Period: v1.SchedulePeriod{
|
||||
StartTime: schedule.startTime,
|
||||
Days: schedule.days,
|
||||
Timezone: schedule.timezone,
|
||||
},
|
||||
Type: v1.RepeatingSchedule,
|
||||
Period: &period,
|
||||
DurationMinutes: schedule.duration,
|
||||
Value: schedule.value,
|
||||
},
|
||||
|
Reference in New Issue
Block a user