From 4eb06577dc5256a721e710492e471f72436d684b Mon Sep 17 00:00:00 2001 From: Steve Azzopardi Date: Mon, 24 Feb 2020 20:50:39 +0100 Subject: [PATCH] Fix golint issues for `core/v1/validation` reference https://github.com/kubernetes/kubernetes/issues/68026 --- hack/.golint_failures | 1 - pkg/apis/core/v1/validation/validation.go | 9 ++++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/hack/.golint_failures b/hack/.golint_failures index 78cf0ddba45..00fb27756d0 100644 --- a/hack/.golint_failures +++ b/hack/.golint_failures @@ -27,7 +27,6 @@ pkg/apis/core/helper/qos pkg/apis/core/v1 pkg/apis/core/v1/helper pkg/apis/core/v1/helper/qos -pkg/apis/core/v1/validation pkg/apis/core/validation pkg/apis/discovery/v1alpha1 pkg/apis/discovery/v1beta1 diff --git a/pkg/apis/core/v1/validation/validation.go b/pkg/apis/core/v1/validation/validation.go index 02362233281..b0df5ba2c22 100644 --- a/pkg/apis/core/v1/validation/validation.go +++ b/pkg/apis/core/v1/validation/validation.go @@ -32,6 +32,9 @@ import ( const isNegativeErrorMsg string = `must be greater than or equal to 0` const isNotIntegerErrorMsg string = `must be an integer` +// ValidateResourceRequirements will check if any of the resource +// Limits/Requests are of a valid value. Any incorrect value will be added to +// the ErrorList. func ValidateResourceRequirements(requirements *v1.ResourceRequirements, fldPath *field.Path) field.ErrorList { allErrs := field.ErrorList{} limPath := fldPath.Child("limits") @@ -93,7 +96,7 @@ func ValidateResourceQuantityValue(resource string, value resource.Quantity, fld return allErrs } -// Validates that a Quantity is not negative +// ValidateNonnegativeQuantity checks that a Quantity is not negative. func ValidateNonnegativeQuantity(value resource.Quantity, fldPath *field.Path) field.ErrorList { allErrs := field.ErrorList{} if value.Cmp(resource.Quantity{}) < 0 { @@ -122,6 +125,8 @@ func validateResourceName(value string, fldPath *field.Path) field.ErrorList { return allErrs } +// ValidatePodLogOptions checks if options that are set are at the correct +// value. Any incorrect value will be returned to the ErrorList. func ValidatePodLogOptions(opts *v1.PodLogOptions) field.ErrorList { allErrs := field.ErrorList{} if opts.TailLines != nil && *opts.TailLines < 0 { @@ -141,6 +146,8 @@ func ValidatePodLogOptions(opts *v1.PodLogOptions) field.ErrorList { return allErrs } +// AccumulateUniqueHostPorts checks all the containers for duplicates ports. Any +// duplicate port will be returned in the ErrorList. func AccumulateUniqueHostPorts(containers []v1.Container, accumulator *sets.String, fldPath *field.Path) field.ErrorList { allErrs := field.ErrorList{}