Skip to content

Commit d7011f1

Browse files
committed
Cleanup explicitly registered functions
1 parent 9acb04a commit d7011f1

File tree

41 files changed

+28
-459
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+28
-459
lines changed

pkg/apis/apps/v1/conversion.go

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -22,35 +22,10 @@ import (
2222

2323
appsv1 "k8s.io/api/apps/v1"
2424
"k8s.io/apimachinery/pkg/conversion"
25-
"k8s.io/apimachinery/pkg/runtime"
2625
"k8s.io/kubernetes/pkg/apis/apps"
2726
k8s_api_v1 "k8s.io/kubernetes/pkg/apis/core/v1"
2827
)
2928

30-
func addConversionFuncs(scheme *runtime.Scheme) error {
31-
// Add non-generated conversion functions to handle the *int32 -> int32
32-
// conversion. A pointer is useful in the versioned type so we can default
33-
// it, but a plain int32 is more convenient in the internal type. These
34-
// functions are the same as the autogenerated ones in every other way.
35-
err := scheme.AddConversionFuncs(
36-
Convert_v1_Deployment_To_apps_Deployment,
37-
Convert_apps_Deployment_To_v1_Deployment,
38-
Convert_apps_DaemonSet_To_v1_DaemonSet,
39-
Convert_v1_DaemonSet_To_apps_DaemonSet,
40-
Convert_apps_DaemonSetSpec_To_v1_DaemonSetSpec,
41-
Convert_v1_DaemonSetSpec_To_apps_DaemonSetSpec,
42-
// extensions
43-
// TODO: below conversions should be dropped in favor of auto-generated
44-
// ones, see https://github.com/kubernetes/kubernetes/issues/39865
45-
Convert_v1_DeploymentSpec_To_apps_DeploymentSpec,
46-
Convert_apps_DeploymentSpec_To_v1_DeploymentSpec,
47-
)
48-
if err != nil {
49-
return err
50-
}
51-
return nil
52-
}
53-
5429
func Convert_v1_DeploymentSpec_To_apps_DeploymentSpec(in *appsv1.DeploymentSpec, out *apps.DeploymentSpec, s conversion.Scope) error {
5530
if in.Replicas != nil {
5631
out.Replicas = *in.Replicas

pkg/apis/apps/v1/register.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,5 @@ func init() {
4141
// We only register manually written functions here. The registration of the
4242
// generated functions takes place in the generated files. The separation
4343
// makes the code compile even when the generated files are missing.
44-
localSchemeBuilder.Register(addDefaultingFuncs, addConversionFuncs)
44+
localSchemeBuilder.Register(addDefaultingFuncs)
4545
}

pkg/apis/apps/v1beta1/conversion.go

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -28,32 +28,16 @@ import (
2828
)
2929

3030
func addConversionFuncs(scheme *runtime.Scheme) error {
31-
// Add non-generated conversion functions to handle the *int32 -> int32
32-
// conversion. A pointer is useful in the versioned type so we can default
33-
// it, but a plain int32 is more convenient in the internal type. These
34-
// functions are the same as the autogenerated ones in every other way.
35-
err := scheme.AddConversionFuncs(
36-
// extensions
37-
// TODO: below conversions should be dropped in favor of auto-generated
38-
// ones, see https://github.com/kubernetes/kubernetes/issues/39865
39-
Convert_v1beta1_ScaleStatus_To_autoscaling_ScaleStatus,
40-
Convert_autoscaling_ScaleStatus_To_v1beta1_ScaleStatus,
41-
)
42-
if err != nil {
43-
return err
44-
}
45-
4631
// Add field label conversions for kinds having selectable nothing but ObjectMeta fields.
47-
err = scheme.AddFieldLabelConversionFunc(SchemeGroupVersion.WithKind("StatefulSet"),
32+
if err := scheme.AddFieldLabelConversionFunc(SchemeGroupVersion.WithKind("StatefulSet"),
4833
func(label, value string) (string, string, error) {
4934
switch label {
5035
case "metadata.name", "metadata.namespace", "status.successful":
5136
return label, value, nil
5237
default:
5338
return "", "", fmt.Errorf("field label not supported for appsv1beta1.StatefulSet: %s", label)
5439
}
55-
})
56-
if err != nil {
40+
}); err != nil {
5741
return err
5842
}
5943

pkg/apis/apps/v1beta2/conversion.go

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,40 +31,16 @@ import (
3131
)
3232

3333
func addConversionFuncs(scheme *runtime.Scheme) error {
34-
// Add non-generated conversion functions to handle the *int32 -> int32
35-
// conversion. A pointer is useful in the versioned type so we can default
36-
// it, but a plain int32 is more convenient in the internal type. These
37-
// functions are the same as the autogenerated ones in every other way.
38-
err := scheme.AddConversionFuncs(
39-
Convert_v1beta2_Deployment_To_apps_Deployment,
40-
Convert_apps_Deployment_To_v1beta2_Deployment,
41-
Convert_apps_DaemonSet_To_v1beta2_DaemonSet,
42-
Convert_v1beta2_DaemonSet_To_apps_DaemonSet,
43-
Convert_apps_DaemonSetSpec_To_v1beta2_DaemonSetSpec,
44-
Convert_v1beta2_DaemonSetSpec_To_apps_DaemonSetSpec,
45-
// extensions
46-
// TODO: below conversions should be dropped in favor of auto-generated
47-
// ones, see https://github.com/kubernetes/kubernetes/issues/39865
48-
Convert_v1beta2_ScaleStatus_To_autoscaling_ScaleStatus,
49-
Convert_autoscaling_ScaleStatus_To_v1beta2_ScaleStatus,
50-
Convert_v1beta2_DeploymentSpec_To_apps_DeploymentSpec,
51-
Convert_apps_DeploymentSpec_To_v1beta2_DeploymentSpec,
52-
)
53-
if err != nil {
54-
return err
55-
}
56-
5734
// Add field label conversions for kinds having selectable nothing but ObjectMeta fields.
58-
err = scheme.AddFieldLabelConversionFunc(SchemeGroupVersion.WithKind("StatefulSet"),
35+
if err := scheme.AddFieldLabelConversionFunc(SchemeGroupVersion.WithKind("StatefulSet"),
5936
func(label, value string) (string, string, error) {
6037
switch label {
6138
case "metadata.name", "metadata.namespace", "status.successful":
6239
return label, value, nil
6340
default:
6441
return "", "", fmt.Errorf("field label not supported for appsv1beta2.StatefulSet: %s", label)
6542
}
66-
})
67-
if err != nil {
43+
}); err != nil {
6844
return err
6945
}
7046

pkg/apis/authentication/v1/conversion.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,21 +19,15 @@ package v1
1919
import (
2020
v1 "k8s.io/api/authentication/v1"
2121
conversion "k8s.io/apimachinery/pkg/conversion"
22-
"k8s.io/apimachinery/pkg/runtime"
2322
authentication "k8s.io/kubernetes/pkg/apis/authentication"
2423
)
2524

26-
func addConversionFuncs(scheme *runtime.Scheme) error {
27-
// Add non-generated conversion functions
28-
return scheme.AddConversionFuncs()
29-
}
30-
31-
// Convert_v1_UserInfo_To_authentication_UserInfo is an autogenerated conversion function.
25+
// Convert_v1_UserInfo_To_authentication_UserInfo is defined outside the autogenerated file for use by other API packages
3226
func Convert_v1_UserInfo_To_authentication_UserInfo(in *v1.UserInfo, out *authentication.UserInfo, s conversion.Scope) error {
3327
return autoConvert_v1_UserInfo_To_authentication_UserInfo(in, out, s)
3428
}
3529

36-
// Convert_authentication_UserInfo_To_v1_UserInfo is an autogenerated conversion function.
30+
// Convert_authentication_UserInfo_To_v1_UserInfo is defined outside the autogenerated file for use by other API packages
3731
func Convert_authentication_UserInfo_To_v1_UserInfo(in *authentication.UserInfo, out *v1.UserInfo, s conversion.Scope) error {
3832
return autoConvert_authentication_UserInfo_To_v1_UserInfo(in, out, s)
3933
}

pkg/apis/authentication/v1/register.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,5 @@ func init() {
4141
// We only register manually written functions here. The registration of the
4242
// generated functions takes place in the generated files. The separation
4343
// makes the code compile even when the generated files are missing.
44-
localSchemeBuilder.Register(addDefaultingFuncs, addConversionFuncs)
44+
localSchemeBuilder.Register(addDefaultingFuncs)
4545
}

pkg/apis/authentication/v1beta1/conversion.go

Lines changed: 0 additions & 26 deletions
This file was deleted.

pkg/apis/authentication/v1beta1/register.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,5 @@ func init() {
4242
// We only register manually written functions here. The registration of the
4343
// generated functions takes place in the generated files. The separation
4444
// makes the code compile even when the generated files are missing.
45-
localSchemeBuilder.Register(addDefaultingFuncs, addConversionFuncs)
45+
localSchemeBuilder.Register(addDefaultingFuncs)
4646
}

pkg/apis/authorization/v1/conversion.go

Lines changed: 0 additions & 26 deletions
This file was deleted.

pkg/apis/authorization/v1/register.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,5 @@ func init() {
4141
// We only register manually written functions here. The registration of the
4242
// generated functions takes place in the generated files. The separation
4343
// makes the code compile even when the generated files are missing.
44-
localSchemeBuilder.Register(addDefaultingFuncs, addConversionFuncs)
44+
localSchemeBuilder.Register(addDefaultingFuncs)
4545
}

0 commit comments

Comments
 (0)