remove unnecessary field conversions

This commit is contained in:
David Eads 2017-08-23 10:52:22 -04:00
parent 9002dfcd0a
commit 9daf55e173
11 changed files with 2 additions and 191 deletions

View File

@ -17,8 +17,6 @@ limitations under the License.
package v1
import (
"fmt"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/kubernetes/pkg/api/v1"
)
@ -59,24 +57,6 @@ func addConversionFuncs(scheme *runtime.Scheme) error {
return err
}
// Add field label conversions for kinds having selectable nothing but ObjectMeta fields.
for _, kind := range []string{
"Service",
} {
err = scheme.AddFieldLabelConversionFunc("v1", kind,
func(label, value string) (string, string, error) {
switch label {
case "metadata.namespace",
"metadata.name":
return label, value, nil
default:
return "", "", fmt.Errorf("field label %q not supported for %q", label, kind)
}
})
if err != nil {
return err
}
}
if err := v1.AddFieldLabelConversionsForEvent(scheme); err != nil {
return nil
}

View File

@ -8,7 +8,6 @@ load(
go_library(
name = "go_default_library",
srcs = [
"conversion.go",
"defaults.go",
"doc.go",
"generated.pb.go",

View File

@ -1,36 +0,0 @@
/*
Copyright 2016 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1beta1
import (
"fmt"
"k8s.io/apimachinery/pkg/runtime"
)
func addConversionFuncs(scheme *runtime.Scheme) error {
return scheme.AddFieldLabelConversionFunc(SchemeGroupVersion.String(), "Cluster",
func(label, value string) (string, string, error) {
switch label {
case "metadata.name":
return label, value, nil
default:
return "", "", fmt.Errorf("field label not supported: %s", label)
}
},
)
}

View File

@ -40,7 +40,7 @@ func init() {
// We only register manually written functions here. The registration of the
// generated functions takes place in the generated files. The separation
// makes the code compile even when the generated files are missing.
localSchemeBuilder.Register(addKnownTypes, addDefaultingFuncs, addConversionFuncs)
localSchemeBuilder.Register(addKnownTypes, addDefaultingFuncs)
}
func addKnownTypes(scheme *runtime.Scheme) error {

View File

@ -154,32 +154,6 @@ func addConversionFuncs(scheme *runtime.Scheme) error {
return err
}
// Add field label conversions for kinds having selectable nothing but v1.ObjectMeta fields.
for _, k := range []string{
"Endpoints",
"ResourceQuota",
"PersistentVolumeClaim",
"Service",
"ServiceAccount",
"ConfigMap",
} {
kind := k // don't close over range variables
err = scheme.AddFieldLabelConversionFunc("v1", kind,
func(label, value string) (string, string, error) {
switch label {
case "metadata.namespace",
"metadata.name":
return label, value, nil
default:
return "", "", fmt.Errorf("field label %q not supported for %q", label, kind)
}
},
)
if err != nil {
return err
}
}
// Add field conversion funcs.
err = scheme.AddFieldLabelConversionFunc("v1", "Pod",
func(label, value string) (string, string, error) {
@ -236,19 +210,6 @@ func addConversionFuncs(scheme *runtime.Scheme) error {
if err != nil {
return err
}
err = scheme.AddFieldLabelConversionFunc("v1", "PersistentVolume",
func(label, value string) (string, string, error) {
switch label {
case "metadata.name":
return label, value, nil
default:
return "", "", fmt.Errorf("field label not supported: %s", label)
}
},
)
if err != nil {
return err
}
if err := AddFieldLabelConversionsForEvent(scheme); err != nil {
return err
}

View File

@ -70,18 +70,6 @@ func addConversionFuncs(scheme *runtime.Scheme) error {
if err != nil {
return err
}
err = scheme.AddFieldLabelConversionFunc("apps/v1beta1", "Deployment",
func(label, value string) (string, string, error) {
switch label {
case "metadata.name", "metadata.namespace":
return label, value, nil
default:
return "", "", fmt.Errorf("field label %q not supported for appsv1beta1.Deployment", label)
}
})
if err != nil {
return err
}
return nil
}

View File

@ -85,30 +85,6 @@ func addConversionFuncs(scheme *runtime.Scheme) error {
if err != nil {
return err
}
err = scheme.AddFieldLabelConversionFunc("apps/v1beta2", "Deployment",
func(label, value string) (string, string, error) {
switch label {
case "metadata.name", "metadata.namespace":
return label, value, nil
default:
return "", "", fmt.Errorf("field label %q not supported for appsv1beta2.Deployment", label)
}
})
if err != nil {
return err
}
err = scheme.AddFieldLabelConversionFunc("apps/v1beta2", "ReplicaSet",
func(label, value string) (string, string, error) {
switch label {
case "metadata.name", "metadata.namespace":
return label, value, nil
default:
return "", "", fmt.Errorf("field label %q not supported for appsv1beta2.ReplicaSet", label)
}
})
if err != nil {
return err
}
return nil
}

View File

@ -8,7 +8,6 @@ load(
go_library(
name = "go_default_library",
srcs = [
"conversion.go",
"defaults.go",
"doc.go",
"helpers.go",

View File

@ -1,38 +0,0 @@
/*
Copyright 2016 The Kubernetes Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v1beta1
import (
"fmt"
"k8s.io/apimachinery/pkg/runtime"
)
func addConversionFuncs(scheme *runtime.Scheme) error {
// Add non-generated conversion functions here. Currently there are none.
return scheme.AddFieldLabelConversionFunc(SchemeGroupVersion.String(), "CertificateSigningRequest",
func(label, value string) (string, string, error) {
switch label {
case "metadata.name":
return label, value, nil
default:
return "", "", fmt.Errorf("field label not supported: %s", label)
}
},
)
}

View File

@ -46,5 +46,5 @@ func init() {
// We only register manually written functions here. The registration of the
// generated functions takes place in the generated files. The separation
// makes the code compile even when the generated files are missing.
localSchemeBuilder.Register(addConversionFuncs, addDefaultingFuncs)
localSchemeBuilder.Register(addDefaultingFuncs)
}

View File

@ -65,24 +65,6 @@ func addConversionFuncs(scheme *runtime.Scheme) error {
return err
}
// Add field label conversions for kinds having selectable nothing but ObjectMeta fields.
for _, k := range []string{"DaemonSet", "Deployment", "Ingress"} {
kind := k // don't close over range variables
err = scheme.AddFieldLabelConversionFunc("extensions/v1beta1", kind,
func(label, value string) (string, string, error) {
switch label {
case "metadata.name", "metadata.namespace":
return label, value, nil
default:
return "", "", fmt.Errorf("field label %q not supported for %q", label, kind)
}
},
)
if err != nil {
return err
}
}
return nil
}