Skip to content

Commit c3d0157

Browse files
authored
Merge pull request kubernetes#81569 from obitech/fix_golint_pkg_apis_apps
Fix golint issues in pkg/apis/apps and pkg/apis/apps/validation
2 parents 09a4b7e + 905e751 commit c3d0157

File tree

4 files changed

+35
-3
lines changed

4 files changed

+35
-3
lines changed

hack/.golint_failures

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ pkg/apis/apps
1010
pkg/apis/apps/v1
1111
pkg/apis/apps/v1beta1
1212
pkg/apis/apps/v1beta2
13-
pkg/apis/apps/validation
1413
pkg/apis/auditregistration/v1alpha1
1514
pkg/apis/authentication/v1
1615
pkg/apis/authorization/v1

pkg/apis/apps/register.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,10 @@ import (
2323
)
2424

2525
var (
26+
// SchemeBuilder stores functions to add things to a scheme.
2627
SchemeBuilder = runtime.NewSchemeBuilder(addKnownTypes)
27-
AddToScheme = SchemeBuilder.AddToScheme
28+
// AddToScheme applies all stored functions t oa scheme.
29+
AddToScheme = SchemeBuilder.AddToScheme
2830
)
2931

3032
// GroupName is the group name use in this package

pkg/apis/apps/types.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ type StatefulSetStatus struct {
198198
Conditions []StatefulSetCondition
199199
}
200200

201+
// StatefulSetConditionType describes the condition types of StatefulSets.
201202
type StatefulSetConditionType string
202203

203204
// TODO: Add valid condition types for Statefulsets.
@@ -262,6 +263,7 @@ type ControllerRevisionList struct {
262263

263264
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
264265

266+
// Deployment provides declarative updates for Pods and ReplicaSets.
265267
type Deployment struct {
266268
metav1.TypeMeta
267269
// +optional
@@ -276,6 +278,7 @@ type Deployment struct {
276278
Status DeploymentStatus
277279
}
278280

281+
// DeploymentSpec specifies the state of a Deployment.
279282
type DeploymentSpec struct {
280283
// Number of desired pods. This is a pointer to distinguish between explicit
281284
// zero and not specified. Defaults to 1.
@@ -342,6 +345,7 @@ type DeploymentRollback struct {
342345
RollbackTo RollbackConfig
343346
}
344347

348+
// RollbackConfig specifies the state of a revision to roll back to.
345349
// DEPRECATED.
346350
type RollbackConfig struct {
347351
// The revision to rollback to. If set to 0, rollback to the last revision.
@@ -356,6 +360,8 @@ const (
356360
DefaultDeploymentUniqueLabelKey string = "pod-template-hash"
357361
)
358362

363+
// DeploymentStrategy stores information about the strategy and rolling-update
364+
// behavior of a deployment.
359365
type DeploymentStrategy struct {
360366
// Type of deployment. Can be "Recreate" or "RollingUpdate". Default is RollingUpdate.
361367
// +optional
@@ -370,6 +376,7 @@ type DeploymentStrategy struct {
370376
RollingUpdate *RollingUpdateDeployment
371377
}
372378

379+
// DeploymentStrategyType defines strategies with a deployment.
373380
type DeploymentStrategyType string
374381

375382
const (
@@ -409,6 +416,7 @@ type RollingUpdateDeployment struct {
409416
MaxSurge intstr.IntOrString
410417
}
411418

419+
// DeploymentStatus holds information about the observed status of a deployment.
412420
type DeploymentStatus struct {
413421
// The generation observed by the deployment controller.
414422
// +optional
@@ -446,6 +454,7 @@ type DeploymentStatus struct {
446454
CollisionCount *int32
447455
}
448456

457+
// DeploymentConditionType defines conditions of a deployment.
449458
type DeploymentConditionType string
450459

451460
// These are valid conditions of a deployment.
@@ -481,6 +490,7 @@ type DeploymentCondition struct {
481490

482491
// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object
483492

493+
// DeploymentList defines multiple deployments.
484494
type DeploymentList struct {
485495
metav1.TypeMeta
486496
// +optional
@@ -490,6 +500,7 @@ type DeploymentList struct {
490500
Items []Deployment
491501
}
492502

503+
// DaemonSetUpdateStrategy defines a strategy to update a daemon set.
493504
type DaemonSetUpdateStrategy struct {
494505
// Type of daemon set update. Can be "RollingUpdate" or "OnDelete".
495506
// Default is OnDelete.
@@ -505,6 +516,8 @@ type DaemonSetUpdateStrategy struct {
505516
RollingUpdate *RollingUpdateDaemonSet
506517
}
507518

519+
// DaemonSetUpdateStrategyType is a strategy according to which a daemon set
520+
// gets updated.
508521
type DaemonSetUpdateStrategyType string
509522

510523
const (
@@ -623,6 +636,7 @@ type DaemonSetStatus struct {
623636
Conditions []DaemonSetCondition
624637
}
625638

639+
// DaemonSetConditionType defines a daemon set condition.
626640
type DaemonSetConditionType string
627641

628642
// TODO: Add valid condition types of a DaemonSet.
@@ -768,6 +782,7 @@ type ReplicaSetStatus struct {
768782
Conditions []ReplicaSetCondition
769783
}
770784

785+
// ReplicaSetConditionType is a condition of a replica set.
771786
type ReplicaSetConditionType string
772787

773788
// These are valid conditions of a replica set.

pkg/apis/apps/validation/validation.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ func ValidateDaemonSetUpdate(ds, oldDS *apps.DaemonSet) field.ErrorList {
255255
return allErrs
256256
}
257257

258+
// ValidateDaemonSetSpecUpdate tests if an update to a DaemonSetSpec is valid.
258259
func ValidateDaemonSetSpecUpdate(newSpec, oldSpec *apps.DaemonSetSpec, fldPath *field.Path) field.ErrorList {
259260
allErrs := field.ErrorList{}
260261

@@ -291,7 +292,7 @@ func validateDaemonSetStatus(status *apps.DaemonSetStatus, fldPath *field.Path)
291292
return allErrs
292293
}
293294

294-
// ValidateDaemonSetStatusUpdate validates tests if required fields in the DaemonSet Status section
295+
// ValidateDaemonSetStatusUpdate tests if required fields in the DaemonSet Status section
295296
func ValidateDaemonSetStatusUpdate(ds, oldDS *apps.DaemonSet) field.ErrorList {
296297
allErrs := apivalidation.ValidateObjectMetaUpdate(&ds.ObjectMeta, &oldDS.ObjectMeta, field.NewPath("metadata"))
297298
allErrs = append(allErrs, validateDaemonSetStatus(&ds.Status, field.NewPath("status"))...)
@@ -340,6 +341,7 @@ func ValidateDaemonSetSpec(spec *apps.DaemonSetSpec, fldPath *field.Path) field.
340341
return allErrs
341342
}
342343

344+
// ValidateRollingUpdateDaemonSet validates a given RollingUpdateDaemonSet.
343345
func ValidateRollingUpdateDaemonSet(rollingUpdate *apps.RollingUpdateDaemonSet, fldPath *field.Path) field.ErrorList {
344346
allErrs := field.ErrorList{}
345347
allErrs = append(allErrs, ValidatePositiveIntOrPercent(rollingUpdate.MaxUnavailable, fldPath.Child("maxUnavailable"))...)
@@ -352,6 +354,7 @@ func ValidateRollingUpdateDaemonSet(rollingUpdate *apps.RollingUpdateDaemonSet,
352354
return allErrs
353355
}
354356

357+
// ValidateDaemonSetUpdateStrategy validates a given DaemonSetUpdateStrategy.
355358
func ValidateDaemonSetUpdateStrategy(strategy *apps.DaemonSetUpdateStrategy, fldPath *field.Path) field.ErrorList {
356359
allErrs := field.ErrorList{}
357360
switch strategy.Type {
@@ -378,6 +381,8 @@ var ValidateDaemonSetName = apimachineryvalidation.NameIsDNSSubdomain
378381
// ValidateDeploymentName validates that the given name can be used as a deployment name.
379382
var ValidateDeploymentName = apimachineryvalidation.NameIsDNSSubdomain
380383

384+
// ValidatePositiveIntOrPercent tests if a given value is a valid int or
385+
// percentage.
381386
func ValidatePositiveIntOrPercent(intOrPercent intstr.IntOrString, fldPath *field.Path) field.ErrorList {
382387
allErrs := field.ErrorList{}
383388
switch intOrPercent.Type {
@@ -412,6 +417,8 @@ func getIntOrPercentValue(intOrStringValue intstr.IntOrString) int {
412417
return intOrStringValue.IntValue()
413418
}
414419

420+
// IsNotMoreThan100Percent tests is a value can be represented as a percentage
421+
// and if this value is not more than 100%.
415422
func IsNotMoreThan100Percent(intOrStringValue intstr.IntOrString, fldPath *field.Path) field.ErrorList {
416423
allErrs := field.ErrorList{}
417424
value, isPercent := getPercentValue(intOrStringValue)
@@ -422,6 +429,7 @@ func IsNotMoreThan100Percent(intOrStringValue intstr.IntOrString, fldPath *field
422429
return allErrs
423430
}
424431

432+
// ValidateRollingUpdateDeployment validates a given RollingUpdateDeployment.
425433
func ValidateRollingUpdateDeployment(rollingUpdate *apps.RollingUpdateDeployment, fldPath *field.Path) field.ErrorList {
426434
allErrs := field.ErrorList{}
427435
allErrs = append(allErrs, ValidatePositiveIntOrPercent(rollingUpdate.MaxUnavailable, fldPath.Child("maxUnavailable"))...)
@@ -435,6 +443,7 @@ func ValidateRollingUpdateDeployment(rollingUpdate *apps.RollingUpdateDeployment
435443
return allErrs
436444
}
437445

446+
// ValidateDeploymentStrategy validates given DeploymentStrategy.
438447
func ValidateDeploymentStrategy(strategy *apps.DeploymentStrategy, fldPath *field.Path) field.ErrorList {
439448
allErrs := field.ErrorList{}
440449
switch strategy.Type {
@@ -456,6 +465,7 @@ func ValidateDeploymentStrategy(strategy *apps.DeploymentStrategy, fldPath *fiel
456465
return allErrs
457466
}
458467

468+
// ValidateRollback validates given RollbackConfig.
459469
func ValidateRollback(rollback *apps.RollbackConfig, fldPath *field.Path) field.ErrorList {
460470
allErrs := field.ErrorList{}
461471
v := rollback.Revision
@@ -530,12 +540,15 @@ func ValidateDeploymentStatus(status *apps.DeploymentStatus, fldPath *field.Path
530540
return allErrs
531541
}
532542

543+
// ValidateDeploymentUpdate tests if an update to a Deployment is valid.
533544
func ValidateDeploymentUpdate(update, old *apps.Deployment) field.ErrorList {
534545
allErrs := apivalidation.ValidateObjectMetaUpdate(&update.ObjectMeta, &old.ObjectMeta, field.NewPath("metadata"))
535546
allErrs = append(allErrs, ValidateDeploymentSpec(&update.Spec, field.NewPath("spec"))...)
536547
return allErrs
537548
}
538549

550+
// ValidateDeploymentStatusUpdate tests if a an update to a Deployment status
551+
// is valid.
539552
func ValidateDeploymentStatusUpdate(update, old *apps.Deployment) field.ErrorList {
540553
allErrs := apivalidation.ValidateObjectMetaUpdate(&update.ObjectMeta, &old.ObjectMeta, field.NewPath("metadata"))
541554
fldPath := field.NewPath("status")
@@ -550,12 +563,14 @@ func ValidateDeploymentStatusUpdate(update, old *apps.Deployment) field.ErrorLis
550563
return allErrs
551564
}
552565

566+
// ValidateDeployment validates a given Deployment.
553567
func ValidateDeployment(obj *apps.Deployment) field.ErrorList {
554568
allErrs := apivalidation.ValidateObjectMeta(&obj.ObjectMeta, true, ValidateDeploymentName, field.NewPath("metadata"))
555569
allErrs = append(allErrs, ValidateDeploymentSpec(&obj.Spec, field.NewPath("spec"))...)
556570
return allErrs
557571
}
558572

573+
// ValidateDeploymentRollback validates a given DeploymentRollback.
559574
func ValidateDeploymentRollback(obj *apps.DeploymentRollback) field.ErrorList {
560575
allErrs := apivalidation.ValidateAnnotations(obj.UpdatedAnnotations, field.NewPath("updatedAnnotations"))
561576
if len(obj.Name) == 0 {
@@ -594,6 +609,7 @@ func ValidateReplicaSetStatusUpdate(rs, oldRs *apps.ReplicaSet) field.ErrorList
594609
return allErrs
595610
}
596611

612+
// ValidateReplicaSetStatus validates a given ReplicaSetStatus.
597613
func ValidateReplicaSetStatus(status apps.ReplicaSetStatus, fldPath *field.Path) field.ErrorList {
598614
allErrs := field.ErrorList{}
599615
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(status.Replicas), fldPath.Child("replicas"))...)

0 commit comments

Comments
 (0)