Skip to content

Commit a18303d

Browse files
authored
Merge pull request kubernetes#85042 from hvaara/fix-golint-pkg-apis-policy
Fix golint issues in pkg/apis/policy
2 parents 80b25a7 + 10c8508 commit a18303d

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

hack/.golint_failures

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ pkg/apis/extensions/v1beta1
3838
pkg/apis/flowcontrol/v1alpha1
3939
pkg/apis/networking/v1
4040
pkg/apis/node/v1alpha1
41-
pkg/apis/policy
4241
pkg/apis/policy/v1beta1
43-
pkg/apis/policy/validation
4442
pkg/apis/rbac
4543
pkg/apis/rbac/v1
4644
pkg/apis/rbac/v1alpha1

pkg/apis/policy/register.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ func Resource(resource string) schema.GroupResource {
3838
}
3939

4040
var (
41+
// SchemeBuilder is the scheme builder with scheme init functions to run for this API package
4142
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
42-
AddToScheme = SchemeBuilder.AddToScheme
43+
// AddToScheme is a global function that registers this API group & version to a scheme
44+
AddToScheme = SchemeBuilder.AddToScheme
4345
)
4446

4547
// Adds the list of known types to the given scheme.

pkg/apis/policy/types.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ var AllowAllCapabilities api.Capability = "*"
275275
// FSType gives strong typing to different file systems that are used by volumes.
276276
type FSType string
277277

278+
// Exported FSTypes.
278279
const (
279280
AzureFile FSType = "azureFile"
280281
Flocker FSType = "flocker"

pkg/apis/policy/validation/validation.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,16 @@ import (
3535
psputil "k8s.io/kubernetes/pkg/security/podsecuritypolicy/util"
3636
)
3737

38+
// ValidatePodDisruptionBudget validates a PodDisruptionBudget and returns an ErrorList
39+
// with any errors.
3840
func ValidatePodDisruptionBudget(pdb *policy.PodDisruptionBudget) field.ErrorList {
3941
allErrs := ValidatePodDisruptionBudgetSpec(pdb.Spec, field.NewPath("spec"))
4042
allErrs = append(allErrs, ValidatePodDisruptionBudgetStatus(pdb.Status, field.NewPath("status"))...)
4143
return allErrs
4244
}
4345

46+
// ValidatePodDisruptionBudgetSpec validates a PodDisruptionBudgetSpec and returns an ErrorList
47+
// with any errors.
4448
func ValidatePodDisruptionBudgetSpec(spec policy.PodDisruptionBudgetSpec, fldPath *field.Path) field.ErrorList {
4549
allErrs := field.ErrorList{}
4650

@@ -63,6 +67,8 @@ func ValidatePodDisruptionBudgetSpec(spec policy.PodDisruptionBudgetSpec, fldPat
6367
return allErrs
6468
}
6569

70+
// ValidatePodDisruptionBudgetStatus validates a PodDisruptionBudgetStatus and returns an ErrorList
71+
// with any errors.
6672
func ValidatePodDisruptionBudgetStatus(status policy.PodDisruptionBudgetStatus, fldPath *field.Path) field.ErrorList {
6773
allErrs := field.ErrorList{}
6874
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(status.PodDisruptionsAllowed), fldPath.Child("podDisruptionsAllowed"))...)
@@ -78,6 +84,8 @@ func ValidatePodDisruptionBudgetStatus(status policy.PodDisruptionBudgetStatus,
7884
// trailing dashes are allowed.
7985
var ValidatePodSecurityPolicyName = apimachineryvalidation.NameIsDNSSubdomain
8086

87+
// ValidatePodSecurityPolicy validates a PodSecurityPolicy and returns an ErrorList
88+
// with any errors.
8189
func ValidatePodSecurityPolicy(psp *policy.PodSecurityPolicy) field.ErrorList {
8290
allErrs := field.ErrorList{}
8391
allErrs = append(allErrs, apivalidation.ValidateObjectMeta(&psp.ObjectMeta, false, ValidatePodSecurityPolicyName, field.NewPath("metadata"))...)
@@ -86,6 +94,8 @@ func ValidatePodSecurityPolicy(psp *policy.PodSecurityPolicy) field.ErrorList {
8694
return allErrs
8795
}
8896

97+
// ValidatePodSecurityPolicySpec validates a PodSecurityPolicySpec and returns an ErrorList
98+
// with any errors.
8999
func ValidatePodSecurityPolicySpec(spec *policy.PodSecurityPolicySpec, fldPath *field.Path) field.ErrorList {
90100
allErrs := field.ErrorList{}
91101

@@ -114,6 +124,8 @@ func ValidatePodSecurityPolicySpec(spec *policy.PodSecurityPolicySpec, fldPath *
114124
return allErrs
115125
}
116126

127+
// ValidatePodSecurityPolicySpecificAnnotations validates annotations and returns an ErrorList
128+
// with any errors.
117129
func ValidatePodSecurityPolicySpecificAnnotations(annotations map[string]string, fldPath *field.Path) field.ErrorList {
118130
allErrs := field.ErrorList{}
119131

@@ -335,10 +347,13 @@ func validatePSPAllowedProcMountTypes(fldPath *field.Path, allowedProcMountTypes
335347
}
336348

337349
const sysctlPatternSegmentFmt string = "([a-z0-9][-_a-z0-9]*)?[a-z0-9*]"
350+
351+
// SysctlPatternFmt is a regex used for matching valid sysctl patterns.
338352
const SysctlPatternFmt string = "(" + apivalidation.SysctlSegmentFmt + "\\.)*" + sysctlPatternSegmentFmt
339353

340354
var sysctlPatternRegexp = regexp.MustCompile("^" + SysctlPatternFmt + "$")
341355

356+
// IsValidSysctlPattern checks if name is a valid sysctl pattern.
342357
func IsValidSysctlPattern(name string) bool {
343358
if len(name) > apivalidation.SysctlMaxLength {
344359
return false

0 commit comments

Comments
 (0)