mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-02 16:29:21 +00:00
Avoid closing over range variables
This commit is contained in:
parent
6f37347fce
commit
19a25e480f
@ -41,7 +41,7 @@ func addConversionFuncs(scheme *runtime.Scheme) error {
|
|||||||
case "metadata.name", "metadata.namespace", "status.successful":
|
case "metadata.name", "metadata.namespace", "status.successful":
|
||||||
return label, value, nil
|
return label, value, nil
|
||||||
default:
|
default:
|
||||||
return "", "", fmt.Errorf("field label not supported: %s", label)
|
return "", "", fmt.Errorf("field label %q not supported for Job", label)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -36,14 +36,15 @@ func addConversionFuncs(scheme *runtime.Scheme) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Add field label conversions for kinds having selectable nothing but ObjectMeta fields.
|
// 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,
|
err = scheme.AddFieldLabelConversionFunc("batch/v2alpha1", kind,
|
||||||
func(label, value string) (string, string, error) {
|
func(label, value string) (string, string, error) {
|
||||||
switch label {
|
switch label {
|
||||||
case "metadata.name", "metadata.namespace", "status.successful":
|
case "metadata.name", "metadata.namespace", "status.successful":
|
||||||
return label, value, nil
|
return label, value, nil
|
||||||
default:
|
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 {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user