Merge pull request #39681 from soltysh/batch_conversion

Automatic merge from submit-queue (batch tested with PRs 39681, 39321, 41018, 40883)

Avoid closing over range variables

Similar to #31053.

@justinsb since you authored the original one, ptal
pull/6/head
Kubernetes Submit Queue 2017-02-06 10:46:55 -08:00 committed by GitHub
commit d54ff64b3f
2 changed files with 4 additions and 3 deletions

View File

@ -41,7 +41,7 @@ func addConversionFuncs(scheme *runtime.Scheme) error {
case "metadata.name", "metadata.namespace", "status.successful":
return label, value, nil
default:
return "", "", fmt.Errorf("field label not supported: %s", label)
return "", "", fmt.Errorf("field label %q not supported for Job", label)
}
},
)

View File

@ -36,14 +36,15 @@ func addConversionFuncs(scheme *runtime.Scheme) error {
}
// Add field label conversions for kinds having selectable nothing but ObjectMeta fields.
for _, kind := range []string{"Job", "JobTemplate", "CronJob"} {
for _, k := range []string{"Job", "JobTemplate", "CronJob"} {
kind := k // don't close over range variables
err = scheme.AddFieldLabelConversionFunc("batch/v2alpha1", kind,
func(label, value string) (string, string, error) {
switch label {
case "metadata.name", "metadata.namespace", "status.successful":
return label, value, nil
default:
return "", "", fmt.Errorf("field label not supported: %s", label)
return "", "", fmt.Errorf("field label %q not supported for %q", label, kind)
}
})
if err != nil {