Merge pull request #75932 from humblec/validation
Use better variable names in validation.go
This commit is contained in:
		| @@ -63,7 +63,7 @@ const isNotIntegerErrorMsg string = `must be an integer` | |||||||
| const isNotPositiveErrorMsg string = `must be greater than zero` | const isNotPositiveErrorMsg string = `must be greater than zero` | ||||||
|  |  | ||||||
| var pdPartitionErrorMsg string = validation.InclusiveRangeError(1, 255) | var pdPartitionErrorMsg string = validation.InclusiveRangeError(1, 255) | ||||||
| var fileModeErrorMsg string = "must be a number between 0 and 0777 (octal), both inclusive" | var fileModeErrorMsg = "must be a number between 0 and 0777 (octal), both inclusive" | ||||||
|  |  | ||||||
| // BannedOwners is a black list of object that are not allowed to be owners. | // BannedOwners is a black list of object that are not allowed to be owners. | ||||||
| var BannedOwners = apimachineryvalidation.BannedOwners | var BannedOwners = apimachineryvalidation.BannedOwners | ||||||
| @@ -1305,8 +1305,8 @@ func validateAzureDisk(azure *core.AzureDiskVolumeSource, fldPath *field.Path) f | |||||||
| 	var supportedCachingModes = sets.NewString(string(core.AzureDataDiskCachingNone), string(core.AzureDataDiskCachingReadOnly), string(core.AzureDataDiskCachingReadWrite)) | 	var supportedCachingModes = sets.NewString(string(core.AzureDataDiskCachingNone), string(core.AzureDataDiskCachingReadOnly), string(core.AzureDataDiskCachingReadWrite)) | ||||||
| 	var supportedDiskKinds = sets.NewString(string(core.AzureSharedBlobDisk), string(core.AzureDedicatedBlobDisk), string(core.AzureManagedDisk)) | 	var supportedDiskKinds = sets.NewString(string(core.AzureSharedBlobDisk), string(core.AzureDedicatedBlobDisk), string(core.AzureManagedDisk)) | ||||||
|  |  | ||||||
| 	diskUriSupportedManaged := []string{"/subscriptions/{sub-id}/resourcegroups/{group-name}/providers/microsoft.compute/disks/{disk-id}"} | 	diskURISupportedManaged := []string{"/subscriptions/{sub-id}/resourcegroups/{group-name}/providers/microsoft.compute/disks/{disk-id}"} | ||||||
| 	diskUriSupportedblob := []string{"https://{account-name}.blob.core.windows.net/{container-name}/{disk-name}.vhd"} | 	diskURISupportedblob := []string{"https://{account-name}.blob.core.windows.net/{container-name}/{disk-name}.vhd"} | ||||||
|  |  | ||||||
| 	allErrs := field.ErrorList{} | 	allErrs := field.ErrorList{} | ||||||
| 	if azure.DiskName == "" { | 	if azure.DiskName == "" { | ||||||
| @@ -1327,11 +1327,11 @@ func validateAzureDisk(azure *core.AzureDiskVolumeSource, fldPath *field.Path) f | |||||||
|  |  | ||||||
| 	// validate that DiskUri is the correct format | 	// validate that DiskUri is the correct format | ||||||
| 	if azure.Kind != nil && *azure.Kind == core.AzureManagedDisk && strings.Index(azure.DataDiskURI, "/subscriptions/") != 0 { | 	if azure.Kind != nil && *azure.Kind == core.AzureManagedDisk && strings.Index(azure.DataDiskURI, "/subscriptions/") != 0 { | ||||||
| 		allErrs = append(allErrs, field.NotSupported(fldPath.Child("diskURI"), azure.DataDiskURI, diskUriSupportedManaged)) | 		allErrs = append(allErrs, field.NotSupported(fldPath.Child("diskURI"), azure.DataDiskURI, diskURISupportedManaged)) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	if azure.Kind != nil && *azure.Kind != core.AzureManagedDisk && strings.Index(azure.DataDiskURI, "https://") != 0 { | 	if azure.Kind != nil && *azure.Kind != core.AzureManagedDisk && strings.Index(azure.DataDiskURI, "https://") != 0 { | ||||||
| 		allErrs = append(allErrs, field.NotSupported(fldPath.Child("diskURI"), azure.DataDiskURI, diskUriSupportedblob)) | 		allErrs = append(allErrs, field.NotSupported(fldPath.Child("diskURI"), azure.DataDiskURI, diskURISupportedblob)) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	return allErrs | 	return allErrs | ||||||
| @@ -4709,8 +4709,8 @@ func ValidateResourceRequirements(requirements *core.ResourceRequirements, fldPa | |||||||
| 	allErrs := field.ErrorList{} | 	allErrs := field.ErrorList{} | ||||||
| 	limPath := fldPath.Child("limits") | 	limPath := fldPath.Child("limits") | ||||||
| 	reqPath := fldPath.Child("requests") | 	reqPath := fldPath.Child("requests") | ||||||
| 	limContainsCpuOrMemory := false | 	limContainsCPUOrMemory := false | ||||||
| 	reqContainsCpuOrMemory := false | 	reqContainsCPUOrMemory := false | ||||||
| 	limContainsHugePages := false | 	limContainsHugePages := false | ||||||
| 	reqContainsHugePages := false | 	reqContainsHugePages := false | ||||||
| 	supportedQoSComputeResources := sets.NewString(string(core.ResourceCPU), string(core.ResourceMemory)) | 	supportedQoSComputeResources := sets.NewString(string(core.ResourceCPU), string(core.ResourceMemory)) | ||||||
| @@ -4728,7 +4728,7 @@ func ValidateResourceRequirements(requirements *core.ResourceRequirements, fldPa | |||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		if supportedQoSComputeResources.Has(string(resourceName)) { | 		if supportedQoSComputeResources.Has(string(resourceName)) { | ||||||
| 			limContainsCpuOrMemory = true | 			limContainsCPUOrMemory = true | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
| 	for resourceName, quantity := range requirements.Requests { | 	for resourceName, quantity := range requirements.Requests { | ||||||
| @@ -4754,11 +4754,11 @@ func ValidateResourceRequirements(requirements *core.ResourceRequirements, fldPa | |||||||
| 			reqContainsHugePages = true | 			reqContainsHugePages = true | ||||||
| 		} | 		} | ||||||
| 		if supportedQoSComputeResources.Has(string(resourceName)) { | 		if supportedQoSComputeResources.Has(string(resourceName)) { | ||||||
| 			reqContainsCpuOrMemory = true | 			reqContainsCPUOrMemory = true | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 	} | 	} | ||||||
| 	if !limContainsCpuOrMemory && !reqContainsCpuOrMemory && (reqContainsHugePages || limContainsHugePages) { | 	if !limContainsCPUOrMemory && !reqContainsCPUOrMemory && (reqContainsHugePages || limContainsHugePages) { | ||||||
| 		allErrs = append(allErrs, field.Forbidden(fldPath, fmt.Sprintf("HugePages require cpu or memory"))) | 		allErrs = append(allErrs, field.Forbidden(fldPath, fmt.Sprintf("HugePages require cpu or memory"))) | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Kubernetes Prow Robot
					Kubernetes Prow Robot