do some code clean for cloud-controller manager

pull/8/head
stewart-yu 2018-05-23 14:44:46 +08:00
parent 9c2e51f37c
commit be7f087ade
2 changed files with 11 additions and 7 deletions

View File

@ -45,6 +45,11 @@ import (
"github.com/spf13/pflag"
)
const (
// CloudControllerManagerUserAgent is the userAgent name when starting cloud-controller managers.
CloudControllerManagerUserAgent = "cloud-controller-manager"
)
// CloudControllerManagerOptions is the main context object for the controller manager.
type CloudControllerManagerOptions struct {
CloudProvider *cmoptions.CloudProviderOptions
@ -165,7 +170,7 @@ func (o *CloudControllerManagerOptions) ApplyTo(c *cloudcontrollerconfig.Config,
}
// sync back to component config
// TODO: find more elegant way than synching back the values.
// TODO: find more elegant way than syncing back the values.
c.ComponentConfig.KubeCloudShared.Port = int32(o.InsecureServing.BindPort)
c.ComponentConfig.KubeCloudShared.Address = o.InsecureServing.BindAddress.String()
@ -213,13 +218,13 @@ func (o *CloudControllerManagerOptions) Validate() error {
}
// Config return a cloud controller manager config objective
func (o CloudControllerManagerOptions) Config() (*cloudcontrollerconfig.Config, error) {
func (o *CloudControllerManagerOptions) Config() (*cloudcontrollerconfig.Config, error) {
if err := o.Validate(); err != nil {
return nil, err
}
c := &cloudcontrollerconfig.Config{}
if err := o.ApplyTo(c, "cloud-controller-manager"); err != nil {
if err := o.ApplyTo(c, CloudControllerManagerUserAgent); err != nil {
return nil, err
}
@ -230,5 +235,6 @@ func createRecorder(kubeClient kubernetes.Interface, userAgent string) record.Ev
eventBroadcaster := record.NewBroadcaster()
eventBroadcaster.StartLogging(glog.Infof)
eventBroadcaster.StartRecordingToSink(&v1core.EventSinkImpl{Interface: kubeClient.CoreV1().Events("")})
// TODO: remove dependence on the legacyscheme
return eventBroadcaster.NewRecorder(legacyscheme.Scheme, v1.EventSource{Component: userAgent})
}

View File

@ -111,7 +111,6 @@ func TestAddFlags(t *testing.T) {
"--contention-profiling=true",
"--controller-start-interval=2m",
"--http2-max-streams-per-connection=47",
"--min-resync-period=5m",
"--kube-api-burst=100",
"--kube-api-content-type=application/vnd.kubernetes.protobuf",
"--kube-api-qps=50.0",
@ -122,13 +121,12 @@ func TestAddFlags(t *testing.T) {
"--leader-elect-resource-lock=configmap",
"--leader-elect-retry-period=5s",
"--master=192.168.4.20",
"--min-resync-period=8h",
"--min-resync-period=100m",
"--node-status-update-frequency=10m",
"--port=10000",
"--profiling=false",
"--node-status-update-frequency=10m",
"--route-reconciliation-period=30s",
"--secure-port=10001",
"--min-resync-period=100m",
"--use-service-account-credentials=false",
}
f.Parse(args)