From 2b938b985c8210a117e258c5856db1371091b2ee Mon Sep 17 00:00:00 2001 From: xiangpengzhao Date: Wed, 18 Oct 2017 15:46:46 +0800 Subject: [PATCH] Use const GroupName instead of hard-code. --- cmd/kube-proxy/app/server_others.go | 2 +- cmd/kube-proxy/app/server_test.go | 10 +++++----- cmd/kube-proxy/app/server_windows.go | 2 +- pkg/proxy/apis/proxyconfig/register.go | 2 +- pkg/proxy/apis/proxyconfig/scheme/scheme.go | 4 ++-- pkg/proxy/apis/proxyconfig/v1alpha1/register.go | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cmd/kube-proxy/app/server_others.go b/cmd/kube-proxy/app/server_others.go index 60710f8c6c..db004f76f9 100644 --- a/cmd/kube-proxy/app/server_others.go +++ b/cmd/kube-proxy/app/server_others.go @@ -58,7 +58,7 @@ func NewProxyServer(config *proxyconfigapi.KubeProxyConfiguration, cleanupAndExi return nil, errors.New("config is required") } - if c, err := configz.New("proxyconfig"); err == nil { + if c, err := configz.New(proxyconfigapi.GroupName); err == nil { c.Set(config) } else { return nil, fmt.Errorf("unable to register configz: %s", err) diff --git a/cmd/kube-proxy/app/server_test.go b/cmd/kube-proxy/app/server_test.go index 16a292a999..b23356e703 100644 --- a/cmd/kube-proxy/app/server_test.go +++ b/cmd/kube-proxy/app/server_test.go @@ -149,7 +149,7 @@ func TestNewOptionsFailures(t *testing.T) { simulatedErrorTest := func(target string) { var addToScheme *func(s *k8sRuntime.Scheme) error - if target == "proxyconfig" { + if target == proxyconfig.GroupName { addToScheme = &proxyconfig.AddToScheme } else { addToScheme = &v1alpha1.AddToScheme @@ -165,7 +165,7 @@ func TestNewOptionsFailures(t *testing.T) { } // Simulate errors in calls to AddToScheme() - faultTargets := []string{"proxyconfig", "v1alpha1"} + faultTargets := []string{proxyconfig.GroupName, "v1alpha1"} for _, target := range faultTargets { simulatedErrorTest(target) } @@ -197,7 +197,7 @@ func TestProxyServerWithCleanupAndExit(t *testing.T) { assert.True(t, proxyserver.CleanupAndExit, "false CleanupAndExit, addr: %s", addr) // Clean up config for next test case - configz.Delete("proxyconfig") + configz.Delete(proxyconfig.GroupName) } } @@ -262,7 +262,7 @@ func TestGetConntrackMax(t *testing.T) { // TestLoadConfig tests proper operation of loadConfig() func TestLoadConfig(t *testing.T) { - yamlTemplate := `apiVersion: proxyconfig/v1alpha1 + yamlTemplate := `apiVersion: kubeproxy.k8s.io/v1alpha1 bindAddress: %s clientConnection: acceptContentTypes: "abc" @@ -447,7 +447,7 @@ func TestLoadConfigFailures(t *testing.T) { expErr: "mapping values are not allowed in this context", }, } - version := "apiVersion: proxyconfig/v1alpha1" + version := "apiVersion: kubeproxy.k8s.io/v1alpha1" for _, tc := range testCases { options, _ := NewOptions() config := fmt.Sprintf("%s\n%s", version, tc.config) diff --git a/cmd/kube-proxy/app/server_windows.go b/cmd/kube-proxy/app/server_windows.go index cc7871693f..9bfc33c29c 100644 --- a/cmd/kube-proxy/app/server_windows.go +++ b/cmd/kube-proxy/app/server_windows.go @@ -51,7 +51,7 @@ func NewProxyServer(config *proxyconfigapi.KubeProxyConfiguration, cleanupAndExi return nil, errors.New("config is required") } - if c, err := configz.New("proxyconfig"); err == nil { + if c, err := configz.New(proxyconfigapi.GroupName); err == nil { c.Set(config) } else { return nil, fmt.Errorf("unable to register configz: %s", err) diff --git a/pkg/proxy/apis/proxyconfig/register.go b/pkg/proxy/apis/proxyconfig/register.go index 23bf4a7ac7..153e830347 100644 --- a/pkg/proxy/apis/proxyconfig/register.go +++ b/pkg/proxy/apis/proxyconfig/register.go @@ -27,7 +27,7 @@ var ( ) // GroupName is the group name use in this package -const GroupName = "proxyconfig" +const GroupName = "kubeproxy.k8s.io" // SchemeGroupVersion is group version used to register these objects var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: runtime.APIVersionInternal} diff --git a/pkg/proxy/apis/proxyconfig/scheme/scheme.go b/pkg/proxy/apis/proxyconfig/scheme/scheme.go index e6d2ae89e7..cdf3cfd7b8 100644 --- a/pkg/proxy/apis/proxyconfig/scheme/scheme.go +++ b/pkg/proxy/apis/proxyconfig/scheme/scheme.go @@ -23,10 +23,10 @@ import ( "k8s.io/kubernetes/pkg/proxy/apis/proxyconfig/v1alpha1" ) -// Utility functions for the Kube-proxy's proxyconfig API group +// Utility functions for the Kube-proxy's "kubeproxy.k8s.io" API group // NewSchemeAndCodecs is a utility funciton that returns a Scheme and CodecFactory -// that understand the types in the proxyconfig API group. +// that understand the types in the "kubeproxy.k8s.io" API group. func NewSchemeAndCodecs() (*runtime.Scheme, *serializer.CodecFactory, error) { scheme := runtime.NewScheme() if err := proxyconfig.AddToScheme(scheme); err != nil { diff --git a/pkg/proxy/apis/proxyconfig/v1alpha1/register.go b/pkg/proxy/apis/proxyconfig/v1alpha1/register.go index 813f2cc606..1493309836 100644 --- a/pkg/proxy/apis/proxyconfig/v1alpha1/register.go +++ b/pkg/proxy/apis/proxyconfig/v1alpha1/register.go @@ -22,7 +22,7 @@ import ( ) // GroupName is the group name use in this package -const GroupName = "proxyconfig" +const GroupName = "kubeproxy.k8s.io" // SchemeGroupVersion is group version used to register these objects var SchemeGroupVersion = schema.GroupVersion{Group: GroupName, Version: "v1alpha1"}