Merge pull request #64016 from stewart-yu/stewart-controller-manager-codeclean

Automatic merge from submit-queue (batch tested with PRs 57082, 64325, 64016, 64443, 64403). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.

should not ignore err when convert api version

**What this PR does / why we need it**:
should not ignore err when convert api version

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:
Fixes #

**Special notes for your reviewer**:

**Release note**:

```release-note
NONE
```
This commit is contained in:
Kubernetes Submit Queue
2018-05-30 18:49:17 -07:00
committed by GitHub
6 changed files with 36 additions and 17 deletions

View File

@@ -72,8 +72,11 @@ type CloudControllerManagerOptions struct {
}
// NewCloudControllerManagerOptions creates a new ExternalCMServer with a default config.
func NewCloudControllerManagerOptions() *CloudControllerManagerOptions {
componentConfig := NewDefaultComponentConfig(ports.InsecureCloudControllerManagerPort)
func NewCloudControllerManagerOptions() (*CloudControllerManagerOptions, error) {
componentConfig, err := NewDefaultComponentConfig(ports.InsecureCloudControllerManagerPort)
if err != nil {
return nil, err
}
s := CloudControllerManagerOptions{
CloudProvider: &cmoptions.CloudProviderOptions{},
@@ -101,11 +104,11 @@ func NewCloudControllerManagerOptions() *CloudControllerManagerOptions {
// TODO: enable HTTPS by default
s.SecureServing.BindPort = 0
return &s
return &s, nil
}
// NewDefaultComponentConfig returns cloud-controller manager configuration object.
func NewDefaultComponentConfig(insecurePort int32) componentconfig.CloudControllerManagerConfiguration {
func NewDefaultComponentConfig(insecurePort int32) (componentconfig.CloudControllerManagerConfiguration, error) {
scheme := runtime.NewScheme()
componentconfigv1alpha1.AddToScheme(scheme)
componentconfig.AddToScheme(scheme)
@@ -114,9 +117,11 @@ func NewDefaultComponentConfig(insecurePort int32) componentconfig.CloudControll
scheme.Default(&versioned)
internal := componentconfig.CloudControllerManagerConfiguration{}
scheme.Convert(&versioned, &internal, nil)
if err := scheme.Convert(&versioned, &internal, nil); err != nil {
return internal, err
}
internal.KubeCloudShared.Port = insecurePort
return internal
return internal, nil
}
// AddFlags adds flags for a specific ExternalCMServer to the specified FlagSet