From 715c6bcc4ae3d166375d363bfb863855b6a5f3ab Mon Sep 17 00:00:00 2001 From: Alex Dadgar Date: Wed, 10 May 2017 13:51:52 -0700 Subject: [PATCH] API defaults use structs default --- api/jobs.go | 12 +++++++----- nomad/structs/structs.go | 2 +- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/api/jobs.go b/api/jobs.go index 3bf7b2be2..8a8cb515e 100644 --- a/api/jobs.go +++ b/api/jobs.go @@ -332,24 +332,26 @@ func (u *UpdateStrategy) Canonicalize() { u.MaxParallel = helper.IntToPtr(0) } + d := structs.DefaultUpdateStrategy + if u.HealthCheck == nil { - u.HealthCheck = helper.StringToPtr(structs.UpdateStrategyHealthCheck_Checks) + u.HealthCheck = helper.StringToPtr(d.HealthCheck) } if u.HealthyDeadline == nil { - u.HealthyDeadline = helper.TimeToPtr(5 * time.Minute) + u.HealthyDeadline = helper.TimeToPtr(d.HealthyDeadline) } if u.MinHealthyTime == nil { - u.MinHealthyTime = helper.TimeToPtr(10 * time.Second) + u.MinHealthyTime = helper.TimeToPtr(d.MinHealthyTime) } if u.AutoRevert == nil { - u.AutoRevert = helper.BoolToPtr(false) + u.AutoRevert = helper.BoolToPtr(d.AutoRevert) } if u.Canary == nil { - u.Canary = helper.IntToPtr(0) + u.Canary = helper.IntToPtr(d.Canary) } } diff --git a/nomad/structs/structs.go b/nomad/structs/structs.go index fc1304e0a..50469f8ff 100644 --- a/nomad/structs/structs.go +++ b/nomad/structs/structs.go @@ -1667,7 +1667,7 @@ const ( var ( // DefaultUpdateStrategy provides a baseline that can be used to upgrade - // jobs with the old policy + // jobs with the old policy or for populating field defaults. DefaultUpdateStrategy = &UpdateStrategy{ MaxParallel: 0, HealthCheck: UpdateStrategyHealthCheck_Checks,