mirror of https://github.com/k3s-io/k3s
should not ignore err when convert controllermanagerconfiguration api
parent
190ef1e01e
commit
956bbfd1a6
|
@ -54,7 +54,11 @@ const (
|
||||||
|
|
||||||
// NewCloudControllerManagerCommand creates a *cobra.Command object with default parameters
|
// NewCloudControllerManagerCommand creates a *cobra.Command object with default parameters
|
||||||
func NewCloudControllerManagerCommand() *cobra.Command {
|
func NewCloudControllerManagerCommand() *cobra.Command {
|
||||||
s := options.NewCloudControllerManagerOptions()
|
s, err := options.NewCloudControllerManagerOptions()
|
||||||
|
if err != nil {
|
||||||
|
glog.Fatalf("unable to initialize command options: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
cmd := &cobra.Command{
|
cmd := &cobra.Command{
|
||||||
Use: "cloud-controller-manager",
|
Use: "cloud-controller-manager",
|
||||||
Long: `The Cloud controller manager is a daemon that embeds
|
Long: `The Cloud controller manager is a daemon that embeds
|
||||||
|
|
|
@ -67,8 +67,11 @@ type CloudControllerManagerOptions struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewCloudControllerManagerOptions creates a new ExternalCMServer with a default config.
|
// NewCloudControllerManagerOptions creates a new ExternalCMServer with a default config.
|
||||||
func NewCloudControllerManagerOptions() *CloudControllerManagerOptions {
|
func NewCloudControllerManagerOptions() (*CloudControllerManagerOptions, error) {
|
||||||
componentConfig := NewDefaultComponentConfig(ports.InsecureCloudControllerManagerPort)
|
componentConfig, err := NewDefaultComponentConfig(ports.InsecureCloudControllerManagerPort)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
s := CloudControllerManagerOptions{
|
s := CloudControllerManagerOptions{
|
||||||
CloudProvider: &cmoptions.CloudProviderOptions{},
|
CloudProvider: &cmoptions.CloudProviderOptions{},
|
||||||
|
@ -96,11 +99,11 @@ func NewCloudControllerManagerOptions() *CloudControllerManagerOptions {
|
||||||
// TODO: enable HTTPS by default
|
// TODO: enable HTTPS by default
|
||||||
s.SecureServing.BindPort = 0
|
s.SecureServing.BindPort = 0
|
||||||
|
|
||||||
return &s
|
return &s, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultComponentConfig returns cloud-controller manager configuration object.
|
// NewDefaultComponentConfig returns cloud-controller manager configuration object.
|
||||||
func NewDefaultComponentConfig(insecurePort int32) componentconfig.CloudControllerManagerConfiguration {
|
func NewDefaultComponentConfig(insecurePort int32) (componentconfig.CloudControllerManagerConfiguration, error) {
|
||||||
scheme := runtime.NewScheme()
|
scheme := runtime.NewScheme()
|
||||||
componentconfigv1alpha1.AddToScheme(scheme)
|
componentconfigv1alpha1.AddToScheme(scheme)
|
||||||
componentconfig.AddToScheme(scheme)
|
componentconfig.AddToScheme(scheme)
|
||||||
|
@ -109,9 +112,11 @@ func NewDefaultComponentConfig(insecurePort int32) componentconfig.CloudControll
|
||||||
scheme.Default(&versioned)
|
scheme.Default(&versioned)
|
||||||
|
|
||||||
internal := componentconfig.CloudControllerManagerConfiguration{}
|
internal := componentconfig.CloudControllerManagerConfiguration{}
|
||||||
scheme.Convert(&versioned, &internal, nil)
|
if err := scheme.Convert(&versioned, &internal, nil); err != nil {
|
||||||
|
return internal, err
|
||||||
|
}
|
||||||
internal.KubeCloudShared.Port = insecurePort
|
internal.KubeCloudShared.Port = insecurePort
|
||||||
return internal
|
return internal, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddFlags adds flags for a specific ExternalCMServer to the specified FlagSet
|
// AddFlags adds flags for a specific ExternalCMServer to the specified FlagSet
|
||||||
|
|
|
@ -32,7 +32,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestDefaultFlags(t *testing.T) {
|
func TestDefaultFlags(t *testing.T) {
|
||||||
s := NewCloudControllerManagerOptions()
|
s, _ := NewCloudControllerManagerOptions()
|
||||||
|
|
||||||
expected := &CloudControllerManagerOptions{
|
expected := &CloudControllerManagerOptions{
|
||||||
CloudProvider: &cmoptions.CloudProviderOptions{
|
CloudProvider: &cmoptions.CloudProviderOptions{
|
||||||
|
@ -95,7 +95,7 @@ func TestDefaultFlags(t *testing.T) {
|
||||||
|
|
||||||
func TestAddFlags(t *testing.T) {
|
func TestAddFlags(t *testing.T) {
|
||||||
f := pflag.NewFlagSet("addflagstest", pflag.ContinueOnError)
|
f := pflag.NewFlagSet("addflagstest", pflag.ContinueOnError)
|
||||||
s := NewCloudControllerManagerOptions()
|
s, _ := NewCloudControllerManagerOptions()
|
||||||
s.AddFlags(f)
|
s.AddFlags(f)
|
||||||
|
|
||||||
args := []string{
|
args := []string{
|
||||||
|
|
|
@ -70,7 +70,11 @@ const (
|
||||||
|
|
||||||
// NewControllerManagerCommand creates a *cobra.Command object with default parameters
|
// NewControllerManagerCommand creates a *cobra.Command object with default parameters
|
||||||
func NewControllerManagerCommand() *cobra.Command {
|
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{
|
cmd := &cobra.Command{
|
||||||
Use: "kube-controller-manager",
|
Use: "kube-controller-manager",
|
||||||
Long: `The Kubernetes controller manager is a daemon that embeds
|
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.
|
// NewKubeControllerManagerOptions creates a new KubeControllerManagerOptions with a default config.
|
||||||
func NewKubeControllerManagerOptions() *KubeControllerManagerOptions {
|
func NewKubeControllerManagerOptions() (*KubeControllerManagerOptions, error) {
|
||||||
componentConfig := NewDefaultComponentConfig(ports.InsecureKubeControllerManagerPort)
|
componentConfig, err := NewDefaultComponentConfig(ports.InsecureKubeControllerManagerPort)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
s := KubeControllerManagerOptions{
|
s := KubeControllerManagerOptions{
|
||||||
CloudProvider: &cmoptions.CloudProviderOptions{},
|
CloudProvider: &cmoptions.CloudProviderOptions{},
|
||||||
Debugging: &cmoptions.DebuggingOptions{},
|
Debugging: &cmoptions.DebuggingOptions{},
|
||||||
|
@ -193,11 +197,11 @@ func NewKubeControllerManagerOptions() *KubeControllerManagerOptions {
|
||||||
|
|
||||||
s.GarbageCollectorController.GCIgnoredResources = gcIgnoredResources
|
s.GarbageCollectorController.GCIgnoredResources = gcIgnoredResources
|
||||||
|
|
||||||
return &s
|
return &s, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewDefaultComponentConfig returns kube-controller manager configuration object.
|
// NewDefaultComponentConfig returns kube-controller manager configuration object.
|
||||||
func NewDefaultComponentConfig(insecurePort int32) componentconfig.KubeControllerManagerConfiguration {
|
func NewDefaultComponentConfig(insecurePort int32) (componentconfig.KubeControllerManagerConfiguration, error) {
|
||||||
scheme := runtime.NewScheme()
|
scheme := runtime.NewScheme()
|
||||||
componentconfigv1alpha1.AddToScheme(scheme)
|
componentconfigv1alpha1.AddToScheme(scheme)
|
||||||
componentconfig.AddToScheme(scheme)
|
componentconfig.AddToScheme(scheme)
|
||||||
|
@ -206,9 +210,11 @@ func NewDefaultComponentConfig(insecurePort int32) componentconfig.KubeControlle
|
||||||
scheme.Default(&versioned)
|
scheme.Default(&versioned)
|
||||||
|
|
||||||
internal := componentconfig.KubeControllerManagerConfiguration{}
|
internal := componentconfig.KubeControllerManagerConfiguration{}
|
||||||
scheme.Convert(&versioned, &internal, nil)
|
if err := scheme.Convert(&versioned, &internal, nil); err != nil {
|
||||||
|
return internal, err
|
||||||
|
}
|
||||||
internal.KubeCloudShared.Port = insecurePort
|
internal.KubeCloudShared.Port = insecurePort
|
||||||
return internal
|
return internal, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddFlags adds flags for a specific KubeControllerManagerOptions to the specified FlagSet
|
// AddFlags adds flags for a specific KubeControllerManagerOptions to the specified FlagSet
|
||||||
|
|
|
@ -34,7 +34,7 @@ import (
|
||||||
|
|
||||||
func TestAddFlags(t *testing.T) {
|
func TestAddFlags(t *testing.T) {
|
||||||
f := pflag.NewFlagSet("addflagstest", pflag.ContinueOnError)
|
f := pflag.NewFlagSet("addflagstest", pflag.ContinueOnError)
|
||||||
s := NewKubeControllerManagerOptions()
|
s, _ := NewKubeControllerManagerOptions()
|
||||||
s.AddFlags(f, []string{""}, []string{""})
|
s.AddFlags(f, []string{""}, []string{""})
|
||||||
|
|
||||||
args := []string{
|
args := []string{
|
||||||
|
|
Loading…
Reference in New Issue