jobs update stanza canonicalize and default AutoPromote

This commit is contained in:
Lang Martin
2019-07-11 17:01:32 -04:00
parent e70542f15d
commit eb7d87e1d9

View File

@@ -383,7 +383,6 @@ type UpdateStrategy struct {
// DefaultUpdateStrategy provides a baseline that can be used to upgrade
// jobs with the old policy or for populating field defaults.
func DefaultUpdateStrategy() *UpdateStrategy {
// boolPtr fields are omitted to avoid masking an unconfigured nil
return &UpdateStrategy{
Stagger: timeToPtr(30 * time.Second),
MaxParallel: intToPtr(1),
@@ -393,6 +392,7 @@ func DefaultUpdateStrategy() *UpdateStrategy {
ProgressDeadline: timeToPtr(10 * time.Minute),
AutoRevert: boolToPtr(false),
Canary: intToPtr(0),
AutoPromote: boolToPtr(false),
}
}
@@ -487,8 +487,6 @@ func (u *UpdateStrategy) Merge(o *UpdateStrategy) {
func (u *UpdateStrategy) Canonicalize() {
d := DefaultUpdateStrategy()
// boolPtr fields are omitted to avoid masking an unconfigured nil
if u.MaxParallel == nil {
u.MaxParallel = d.MaxParallel
}
@@ -520,6 +518,10 @@ func (u *UpdateStrategy) Canonicalize() {
if u.Canary == nil {
u.Canary = d.Canary
}
if u.AutoPromote == nil {
u.AutoPromote = d.AutoPromote
}
}
// Empty returns whether the UpdateStrategy is empty or has user defined values.
@@ -556,6 +558,10 @@ func (u *UpdateStrategy) Empty() bool {
return false
}
if u.AutoPromote != nil && *u.AutoPromote {
return false
}
if u.Canary != nil && *u.Canary != 0 {
return false
}