Skip to content

Commit fe97fbb

Browse files
authored
Merge pull request kubernetes#85071 from hvaara/fix-golint-pkg-apis-batch-validation
Fix golint issues in pkg/apis/batch/validation
2 parents 896b77e + 896f84b commit fe97fbb

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

hack/.golint_failures

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ pkg/apis/autoscaling/v2beta2
2020
pkg/apis/batch/v1
2121
pkg/apis/batch/v1beta1
2222
pkg/apis/batch/v2alpha1
23-
pkg/apis/batch/validation
2423
pkg/apis/certificates
2524
pkg/apis/certificates/v1beta1
2625
pkg/apis/certificates/validation

pkg/apis/batch/validation/validation.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ import (
2929
apivalidation "k8s.io/kubernetes/pkg/apis/core/validation"
3030
)
3131

32-
// TODO: generalize for other controller objects that will follow the same pattern, such as ReplicaSet and DaemonSet, and
33-
// move to new location. Replace batch.Job with an interface.
34-
//
3532
// ValidateGeneratedSelector validates that the generated selector on a controller object match the controller object
3633
// metadata, and the labels on the pod template are as generated.
34+
//
35+
// TODO: generalize for other controller objects that will follow the same pattern, such as ReplicaSet and DaemonSet, and
36+
// move to new location. Replace batch.Job with an interface.
3737
func ValidateGeneratedSelector(obj *batch.Job) field.ErrorList {
3838
allErrs := field.ErrorList{}
3939
if obj.Spec.ManualSelector != nil && *obj.Spec.ManualSelector {
@@ -75,6 +75,7 @@ func ValidateGeneratedSelector(obj *batch.Job) field.ErrorList {
7575
return allErrs
7676
}
7777

78+
// ValidateJob validates a Job and returns an ErrorList with any errors.
7879
func ValidateJob(job *batch.Job) field.ErrorList {
7980
// Jobs and rcs have the same name validation
8081
allErrs := apivalidation.ValidateObjectMeta(&job.ObjectMeta, true, apivalidation.ValidateReplicationControllerName, field.NewPath("metadata"))
@@ -83,6 +84,7 @@ func ValidateJob(job *batch.Job) field.ErrorList {
8384
return allErrs
8485
}
8586

87+
// ValidateJobSpec validates a JobSpec and returns an ErrorList with any errors.
8688
func ValidateJobSpec(spec *batch.JobSpec, fldPath *field.Path) field.ErrorList {
8789
allErrs := validateJobSpec(spec, fldPath)
8890

@@ -130,6 +132,7 @@ func validateJobSpec(spec *batch.JobSpec, fldPath *field.Path) field.ErrorList {
130132
return allErrs
131133
}
132134

135+
// ValidateJobStatus validates a JobStatus and returns an ErrorList with any errors.
133136
func ValidateJobStatus(status *batch.JobStatus, fldPath *field.Path) field.ErrorList {
134137
allErrs := field.ErrorList{}
135138
allErrs = append(allErrs, apivalidation.ValidateNonnegativeField(int64(status.Active), fldPath.Child("active"))...)
@@ -138,18 +141,21 @@ func ValidateJobStatus(status *batch.JobStatus, fldPath *field.Path) field.Error
138141
return allErrs
139142
}
140143

144+
// ValidateJobUpdate validates an update to a Job and returns an ErrorList with any errors.
141145
func ValidateJobUpdate(job, oldJob *batch.Job) field.ErrorList {
142146
allErrs := apivalidation.ValidateObjectMetaUpdate(&job.ObjectMeta, &oldJob.ObjectMeta, field.NewPath("metadata"))
143147
allErrs = append(allErrs, ValidateJobSpecUpdate(job.Spec, oldJob.Spec, field.NewPath("spec"))...)
144148
return allErrs
145149
}
146150

151+
// ValidateJobUpdateStatus validates an update to the status of a Job and returns an ErrorList with any errors.
147152
func ValidateJobUpdateStatus(job, oldJob *batch.Job) field.ErrorList {
148153
allErrs := apivalidation.ValidateObjectMetaUpdate(&job.ObjectMeta, &oldJob.ObjectMeta, field.NewPath("metadata"))
149154
allErrs = append(allErrs, ValidateJobStatusUpdate(job.Status, oldJob.Status)...)
150155
return allErrs
151156
}
152157

158+
// ValidateJobSpecUpdate validates an update to a JobSpec and returns an ErrorList with any errors.
153159
func ValidateJobSpecUpdate(spec, oldSpec batch.JobSpec, fldPath *field.Path) field.ErrorList {
154160
allErrs := field.ErrorList{}
155161
allErrs = append(allErrs, ValidateJobSpec(&spec, fldPath)...)
@@ -159,12 +165,14 @@ func ValidateJobSpecUpdate(spec, oldSpec batch.JobSpec, fldPath *field.Path) fie
159165
return allErrs
160166
}
161167

168+
// ValidateJobStatusUpdate validates an update to a JobStatus and returns an ErrorList with any errors.
162169
func ValidateJobStatusUpdate(status, oldStatus batch.JobStatus) field.ErrorList {
163170
allErrs := field.ErrorList{}
164171
allErrs = append(allErrs, ValidateJobStatus(&status, field.NewPath("status"))...)
165172
return allErrs
166173
}
167174

175+
// ValidateCronJob validates a CronJob and returns an ErrorList with any errors.
168176
func ValidateCronJob(scheduledJob *batch.CronJob) field.ErrorList {
169177
// CronJobs and rcs have the same name validation
170178
allErrs := apivalidation.ValidateObjectMeta(&scheduledJob.ObjectMeta, true, apivalidation.ValidateReplicationControllerName, field.NewPath("metadata"))
@@ -179,6 +187,7 @@ func ValidateCronJob(scheduledJob *batch.CronJob) field.ErrorList {
179187
return allErrs
180188
}
181189

190+
// ValidateCronJobUpdate validates an update to a CronJob and returns an ErrorList with any errors.
182191
func ValidateCronJobUpdate(job, oldJob *batch.CronJob) field.ErrorList {
183192
allErrs := apivalidation.ValidateObjectMetaUpdate(&job.ObjectMeta, &oldJob.ObjectMeta, field.NewPath("metadata"))
184193
allErrs = append(allErrs, ValidateCronJobSpec(&job.Spec, field.NewPath("spec"))...)
@@ -187,6 +196,7 @@ func ValidateCronJobUpdate(job, oldJob *batch.CronJob) field.ErrorList {
187196
return allErrs
188197
}
189198

199+
// ValidateCronJobSpec validates a CronJobSpec and returns an ErrorList with any errors.
190200
func ValidateCronJobSpec(spec *batch.CronJobSpec, fldPath *field.Path) field.ErrorList {
191201
allErrs := field.ErrorList{}
192202

@@ -237,13 +247,15 @@ func validateScheduleFormat(schedule string, fldPath *field.Path) field.ErrorLis
237247
return allErrs
238248
}
239249

250+
// ValidateJobTemplate validates a JobTemplate and returns an ErrorList with any errors.
240251
func ValidateJobTemplate(job *batch.JobTemplate) field.ErrorList {
241252
// this method should be identical to ValidateJob
242253
allErrs := apivalidation.ValidateObjectMeta(&job.ObjectMeta, true, apivalidation.ValidateReplicationControllerName, field.NewPath("metadata"))
243254
allErrs = append(allErrs, ValidateJobTemplateSpec(&job.Template, field.NewPath("template"))...)
244255
return allErrs
245256
}
246257

258+
// ValidateJobTemplateSpec validates a JobTemplateSpec and returns an ErrorList with any errors.
247259
func ValidateJobTemplateSpec(spec *batch.JobTemplateSpec, fldPath *field.Path) field.ErrorList {
248260
allErrs := validateJobSpec(&spec.Spec, fldPath.Child("spec"))
249261

0 commit comments

Comments
 (0)