in pkg/clusters/versions.go [124:158]
func isUpgrade(desired, current string, valid []string, allowInPlace bool) error {
if len(valid) == 0 {
// Should not happen, but protects from out-of-bounds error.
return fmt.Errorf("list of valid versions is empty: %v", valid)
}
var (
desiredIndex = -1
currentIndex = -1
)
for i, v := range valid {
if v == desired {
desiredIndex = i
}
if v == current {
currentIndex = i
}
}
if desiredIndex == -1 {
return fmt.Errorf("desired version %s was not found; valid versions: %v", desired, valid)
}
if currentIndex == -1 {
// The defalt version is no longer a valid version.
// This can happen to node pools with auto-upgrade disabled.
return nil
}
if allowInPlace && currentIndex == desiredIndex {
return nil
}
if currentIndex <= desiredIndex {
return fmt.Errorf("desired version %s must be newer than current version %s; valid versions: %v", desired, current, valid)
}
return nil
}