// We restrict the Kubernetes versions to a tested subset. This test needs to be
// run after validateVersions. It's also a global test as opposed to a
// per-machine test to not repeat the validation errors many times if the
// specified versions don't match the ranges.
We restrict the Kubernetes versions to a tested subset. This test needs to be
run after validateVersions. It's also a global test as opposed to a
per-machine test to not repeat the validation errors many times if the
specified versions don't match the ranges.
// We restrict the Kubernetes versions to a tested subset . This test needs to be // run after validateVersions . It ' s also a global test as opposed to a // per - machine test to not repeat the validation errors many times if the // specified versions don ' t match the ranges .
func validateKubernetesVersion(machines []*clusterv1.Machine) field.ErrorList {
	s := machines[0].Spec.Versions.Kubelet
	if s == "" {
		return field.ErrorList{}
	}
	version, err := semver.ParseTolerant(s)
	if err != nil {
		return field.ErrorList{
			field.Invalid(
				machinePath(0, "spec", "versions", "kubelet"),
				machines[0].Spec.Versions.Kubelet,
				"version isn't a semver version"),
		}
	}
	ranges := []string{
		kubernetes.DefaultVersionsRange,
	}
	for i := range ranges {
		r := semver.MustParseRange(ranges[i])
		if !r(version) {
			return field.ErrorList{
				field.Invalid(
					machinePath(0, "spec", "versions", "kubelet"),
					machines[0].Spec.Versions.Kubelet,
					fmt.Sprintf("version doesn't match range: %s", ranges[i])),
			}
		}
	}
	return field.ErrorList{}
}
func validateKubernetesVersion ( machines [ ] * clusterv1 . Machine ) field . ErrorList { s := machines [ 0 ] . Spec . Versions . Kubelet if s == " " { return field . ErrorList { } } version , err := semver . ParseTolerant ( s ) if err != nil { return field . ErrorList { field . Invalid ( machinePath ( 0 , " " , " " , " " ) , machines [ 0 ] . Spec . Versions . Kubelet , " " ) , } } ranges := [ ] string { kubernetes . DefaultVersionsRange , } for i := range ranges { r := semver . MustParseRange ( ranges [ i ] ) if ! r ( version ) { return field . ErrorList { field . Invalid ( machinePath ( 0 , " " , " " , " " ) , machines [ 0 ] . Spec . Versions . Kubelet , fmt . Sprintf ( " " , ranges [ i ] ) ) , } } } return field . ErrorList { } }
We restrict the Kubernetes versions to a tested subset.
We restrict the Kubernetes versions to a tested subset .