mirror of https://github.com/k3s-io/k3s
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, ptalpull/6/head
commit
d54ff64b3f
|
@ -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)
|
||||
}
|
||||
},
|
||||
)
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue