mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-04 15:05:20 +00:00
should not ignore err when convert controllermanagerconfiguration api
This commit is contained in:
@@ -70,7 +70,11 @@ const (
|
||||
|
||||
// NewControllerManagerCommand creates a *cobra.Command object with default parameters
|
||||
func NewControllerManagerCommand() *cobra.Command {
|
||||
s := options.NewKubeControllerManagerOptions()
|
||||
s, err := options.NewKubeControllerManagerOptions()
|
||||
if err != nil {
|
||||
glog.Fatalf("unable to initialize command options: %v", err)
|
||||
}
|
||||
|
||||
cmd := &cobra.Command{
|
||||
Use: "kube-controller-manager",
|
||||
Long: `The Kubernetes controller manager is a daemon that embeds
|
||||
|
||||
@@ -90,8 +90,12 @@ type KubeControllerManagerOptions struct {
|
||||
}
|
||||
|
||||
// NewKubeControllerManagerOptions creates a new KubeControllerManagerOptions with a default config.
|
||||
func NewKubeControllerManagerOptions() *KubeControllerManagerOptions {
|
||||
componentConfig := NewDefaultComponentConfig(ports.InsecureKubeControllerManagerPort)
|
||||
func NewKubeControllerManagerOptions() (*KubeControllerManagerOptions, error) {
|
||||
componentConfig, err := NewDefaultComponentConfig(ports.InsecureKubeControllerManagerPort)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
s := KubeControllerManagerOptions{
|
||||
CloudProvider: &cmoptions.CloudProviderOptions{},
|
||||
Debugging: &cmoptions.DebuggingOptions{},
|
||||
@@ -193,11 +197,11 @@ func NewKubeControllerManagerOptions() *KubeControllerManagerOptions {
|
||||
|
||||
s.GarbageCollectorController.GCIgnoredResources = gcIgnoredResources
|
||||
|
||||
return &s
|
||||
return &s, nil
|
||||
}
|
||||
|
||||
// NewDefaultComponentConfig returns kube-controller manager configuration object.
|
||||
func NewDefaultComponentConfig(insecurePort int32) componentconfig.KubeControllerManagerConfiguration {
|
||||
func NewDefaultComponentConfig(insecurePort int32) (componentconfig.KubeControllerManagerConfiguration, error) {
|
||||
scheme := runtime.NewScheme()
|
||||
componentconfigv1alpha1.AddToScheme(scheme)
|
||||
componentconfig.AddToScheme(scheme)
|
||||
@@ -206,9 +210,11 @@ func NewDefaultComponentConfig(insecurePort int32) componentconfig.KubeControlle
|
||||
scheme.Default(&versioned)
|
||||
|
||||
internal := componentconfig.KubeControllerManagerConfiguration{}
|
||||
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 KubeControllerManagerOptions to the specified FlagSet
|
||||
|
||||
@@ -34,7 +34,7 @@ import (
|
||||
|
||||
func TestAddFlags(t *testing.T) {
|
||||
f := pflag.NewFlagSet("addflagstest", pflag.ContinueOnError)
|
||||
s := NewKubeControllerManagerOptions()
|
||||
s, _ := NewKubeControllerManagerOptions()
|
||||
s.AddFlags(f, []string{""}, []string{""})
|
||||
|
||||
args := []string{
|
||||
|
||||
Reference in New Issue
Block a user