INNER CODE UNIT · Go
ComputeUpgradeSteps
kubesphere/kubekey · builtin/core/upgrade_path.go:99
func ComputeUpgradeSteps(currentMinor, targetMinor int, requestedTarget string, path KubeUpgradePath) ([]string, error) {
if targetMinor < currentMinor {
return nil, fmt.Errorf("downgrade from v1.%d to v1.%d is not supported", currentMinor, targetMinor)
}
if targetMinor == currentMinor {
// Patch-only upgrade: go straight to the requested version.
return []string{requestedTarget}, nil
}
steps := make([]string, 0, targetMinor-currentMinor)
for m := currentMinor + 1; m < targetMinor; m++ {
patch, ok := path[m]
if !ok {
return nil, fmt.Errorf("kube_upgrade_path has no entry for minor v1.%d; cannot auto-step", m)
}
steps = append(steps, patch)
}
steps = append(steps, requestedTarget)
return steps, nil