mirror of
https://github.com/zalando-incubator/kube-metrics-adapter.git
synced 2024-12-22 11:06:04 +00:00
Merge pull request #506 from zalando-incubator/fix-null-pointer
Fix nil pointer dereference
This commit is contained in:
commit
c50d9ccd18
@ -331,7 +331,7 @@ func calculateMetrics(spec v1.ScalingScheduleSpec, defaultScalingWindow time.Dur
|
||||
}
|
||||
|
||||
// If no end time was provided, set it to equal the start time
|
||||
if (string(*schedule.EndDate)) == "" {
|
||||
if schedule.EndDate == nil || string(*schedule.EndDate) == "" {
|
||||
scheduledEndTime = scheduledTime
|
||||
} else {
|
||||
scheduledEndTime, err = time.Parse(time.RFC3339, string(*schedule.EndDate))
|
||||
|
@ -249,6 +249,19 @@ func TestScalingScheduleCollector(t *testing.T) {
|
||||
},
|
||||
err: ErrInvalidScheduleDate,
|
||||
},
|
||||
{
|
||||
msg: "Return error for one time config end date not in RFC3339 format",
|
||||
schedules: []schedule{
|
||||
{
|
||||
date: nowTime.Add(-time.Minute * 20).Format(time.RFC3339),
|
||||
endDate: nowTime.Add(1 * time.Hour).Format(time.RFC822),
|
||||
kind: "OneTime",
|
||||
duration: 15,
|
||||
value: 100,
|
||||
},
|
||||
},
|
||||
err: ErrInvalidScheduleDate,
|
||||
},
|
||||
{
|
||||
msg: "Return the right value for two one time config",
|
||||
schedules: []schedule{
|
||||
|
Loading…
x
Reference in New Issue
Block a user