get rid of copied fields in the options and using wraped componentconfig fields

This commit is contained in:
stewart-yu
2019-01-12 19:13:05 +08:00
parent 3478647333
commit 5b43a24318
24 changed files with 37 additions and 99 deletions

View File

@@ -24,8 +24,7 @@ import (
// CloudProviderOptions holds the cloudprovider options.
type CloudProviderOptions struct {
CloudConfigFile string
Name string
*kubectrlmgrconfig.CloudProviderConfiguration
}
// Validate checks validation of cloudprovider options.

View File

@@ -24,8 +24,7 @@ import (
// DebuggingOptions holds the Debugging options.
type DebuggingOptions struct {
EnableProfiling bool
EnableContentionProfiling bool
*componentbaseconfig.DebuggingConfiguration
}
// AddFlags adds flags related to debugging for controller manager to the specified FlagSet.

View File

@@ -20,7 +20,6 @@ import (
"fmt"
"strings"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/sets"
apiserverflag "k8s.io/apiserver/pkg/util/flag"
componentbaseconfig "k8s.io/component-base/config"
@@ -30,29 +29,19 @@ import (
// GenericControllerManagerConfigurationOptions holds the options which are generic.
type GenericControllerManagerConfigurationOptions struct {
Port int32
Address string
MinResyncPeriod metav1.Duration
ClientConnection componentbaseconfig.ClientConnectionConfiguration
ControllerStartInterval metav1.Duration
LeaderElection componentbaseconfig.LeaderElectionConfiguration
Debugging *DebuggingOptions
Controllers []string
*kubectrlmgrconfig.GenericControllerManagerConfiguration
Debugging *DebuggingOptions
}
// NewGenericControllerManagerConfigurationOptions returns generic configuration default values for both
// the kube-controller-manager and the cloud-contoller-manager. Any common changes should
// be made here. Any individual changes should be made in that controller.
func NewGenericControllerManagerConfigurationOptions(cfg kubectrlmgrconfig.GenericControllerManagerConfiguration) *GenericControllerManagerConfigurationOptions {
func NewGenericControllerManagerConfigurationOptions(cfg *kubectrlmgrconfig.GenericControllerManagerConfiguration) *GenericControllerManagerConfigurationOptions {
o := &GenericControllerManagerConfigurationOptions{
Port: cfg.Port,
Address: cfg.Address,
MinResyncPeriod: cfg.MinResyncPeriod,
ClientConnection: cfg.ClientConnection,
ControllerStartInterval: cfg.ControllerStartInterval,
LeaderElection: cfg.LeaderElection,
Debugging: &DebuggingOptions{},
Controllers: cfg.Controllers,
GenericControllerManagerConfiguration: cfg,
Debugging: &DebuggingOptions{
DebuggingConfiguration: &componentbaseconfig.DebuggingConfiguration{},
},
}
return o

View File

@@ -19,39 +19,25 @@ package options
import (
"github.com/spf13/pflag"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
kubectrlmgrconfig "k8s.io/kubernetes/pkg/controller/apis/config"
)
// KubeCloudSharedOptions holds the options shared between kube-controller-manager
// and cloud-controller-manager.
type KubeCloudSharedOptions struct {
CloudProvider *CloudProviderOptions
ExternalCloudVolumePlugin string
UseServiceAccountCredentials bool
AllowUntaggedCloud bool
RouteReconciliationPeriod metav1.Duration
NodeMonitorPeriod metav1.Duration
ClusterName string
ClusterCIDR string
AllocateNodeCIDRs bool
CIDRAllocatorType string
ConfigureCloudRoutes bool
NodeSyncPeriod metav1.Duration
*kubectrlmgrconfig.KubeCloudSharedConfiguration
CloudProvider *CloudProviderOptions
}
// NewKubeCloudSharedOptions returns common/default configuration values for both
// the kube-controller-manager and the cloud-contoller-manager. Any common changes should
// be made here. Any individual changes should be made in that controller.
func NewKubeCloudSharedOptions(cfg kubectrlmgrconfig.KubeCloudSharedConfiguration) *KubeCloudSharedOptions {
func NewKubeCloudSharedOptions(cfg *kubectrlmgrconfig.KubeCloudSharedConfiguration) *KubeCloudSharedOptions {
o := &KubeCloudSharedOptions{
CloudProvider: &CloudProviderOptions{},
ExternalCloudVolumePlugin: cfg.ExternalCloudVolumePlugin,
UseServiceAccountCredentials: cfg.UseServiceAccountCredentials,
RouteReconciliationPeriod: cfg.RouteReconciliationPeriod,
NodeMonitorPeriod: cfg.NodeMonitorPeriod,
ClusterName: cfg.ClusterName,
ConfigureCloudRoutes: cfg.ConfigureCloudRoutes,
KubeCloudSharedConfiguration: cfg,
CloudProvider: &CloudProviderOptions{
CloudProviderConfiguration: &kubectrlmgrconfig.CloudProviderConfiguration{},
},
}
return o
@@ -92,6 +78,7 @@ func (o *KubeCloudSharedOptions) ApplyTo(cfg *kubectrlmgrconfig.KubeCloudSharedC
if err := o.CloudProvider.ApplyTo(&cfg.CloudProvider); err != nil {
return err
}
cfg.ExternalCloudVolumePlugin = o.ExternalCloudVolumePlugin
cfg.UseServiceAccountCredentials = o.UseServiceAccountCredentials
cfg.AllowUntaggedCloud = o.AllowUntaggedCloud

View File

@@ -24,7 +24,7 @@ import (
// ServiceControllerOptions holds the ServiceController options.
type ServiceControllerOptions struct {
ConcurrentServiceSyncs int32
*kubectrlmgrconfig.ServiceControllerConfiguration
}
// AddFlags adds flags related to ServiceController for controller manager to the specified FlagSet.