// Validate the Spec.Versions Machine field:
// - It's possible to specify no versions at all in any of the objects. In this
// case, we populate the version fields with a default value as they are
// mandatory when persisting the Machine object.
// - If a version is specified, all machine objects must use the same version
// (and they can't be left empty)
Validate the Spec.Versions Machine field:
- It's possible to specify no versions at all in any of the objects. In this
case, we populate the version fields with a default value as they are
mandatory when persisting the Machine object.
- If a version is specified, all machine objects must use the same version
(and they can't be left empty)
// Validate the Spec . Versions Machine field : // - It ' s possible to specify no versions at all in any of the objects . In this // case we populate the version fields with a default value as they are // mandatory when persisting the Machine object . // - If a version is specified all machine objects must use the same version // ( and they can ' t be left empty )
func validateVersions(machines []*clusterv1.Machine) field.ErrorList {
	var errors field.ErrorList
	reference := machines[0].Spec.Versions.Kubelet
	for i, m := range machines {
		if m.Spec.Versions.Kubelet != reference {
			errors = append(errors, field.Invalid(
				machinePath(i, "spec", "versions", "kubelet"),
				m.Spec.Versions.Kubelet,
				fmt.Sprintf("inconsistent kubelet version, expected \"%s\"", reference)))
		}
		controlPlaneVersion := m.Spec.Versions.ControlPlane
		if IsMaster(m) && controlPlaneVersion != "" && controlPlaneVersion != reference {
			errors = append(errors, field.Invalid(
				machinePath(i, "spec", "versions", "controlPlane"),
				m.Spec.Versions.ControlPlane,
				fmt.Sprintf("inconsistent controlPlane version, expected \"%s\"", reference)))
		}
	}
	return errors
}
func validateVersions ( machines [ ] * clusterv1 . Machine ) field . ErrorList { var errors field . ErrorList reference := machines [ 0 ] . Spec . Versions . Kubelet for i , m := range machines { if m . Spec . Versions . Kubelet != reference { errors = append ( errors , field . Invalid ( machinePath ( i , " " , " " , " " ) , m . Spec . Versions . Kubelet , fmt . Sprintf ( " \" \" " , reference ) ) ) } controlPlaneVersion := m . Spec . Versions . ControlPlane if IsMaster ( m ) && controlPlaneVersion != " " && controlPlaneVersion != reference { errors = append ( errors , field . Invalid ( machinePath ( i , " " , " " , " " ) , m . Spec . Versions . ControlPlane , fmt . Sprintf ( " \" \" " , reference ) ) ) } } return errors }
Validate the Spec.Versions Machine field:
 It's possible to specify no versions at all in any of the objects.
Validate the Spec . Versions Machine field : It ' s possible to specify no versions at all in any of the objects .