Avoid closing over range variables

The consequence is only a misleading error message, but it is easy to
avoid.
This commit is contained in:
Justin Santa Barbara 2016-08-20 01:18:30 -04:00
parent c347f579a3
commit 3aa4f50aba
2 changed files with 4 additions and 2 deletions

View File

@ -164,7 +164,7 @@ func addConversionFuncs(scheme *runtime.Scheme) error {
}
// Add field label conversions for kinds having selectable nothing but ObjectMeta fields.
for _, kind := range []string{
for _, k := range []string{
"Endpoints",
"ResourceQuota",
"PersistentVolumeClaim",
@ -172,6 +172,7 @@ func addConversionFuncs(scheme *runtime.Scheme) error {
"ServiceAccount",
"ConfigMap",
} {
kind := k // don't close over range variables
err = scheme.AddFieldLabelConversionFunc("v1", kind,
func(label, value string) (string, string, error) {
switch label {

View File

@ -57,7 +57,8 @@ func addConversionFuncs(scheme *runtime.Scheme) error {
}
// Add field label conversions for kinds having selectable nothing but ObjectMeta fields.
for _, kind := range []string{"DaemonSet", "Deployment", "Ingress"} {
for _, k := range []string{"DaemonSet", "Deployment", "Ingress"} {
kind := k // don't close over range variables
err = api.Scheme.AddFieldLabelConversionFunc("extensions/v1beta1", kind,
func(label, value string) (string, string, error) {
switch label {