fix servicemesh options nil bug
This commit is contained in:
@@ -280,7 +280,7 @@ func Complete(s *options.ServerRunOptions) error {
|
||||
LoggingOptions: s.LoggingOptions,
|
||||
})
|
||||
|
||||
s = &options.ServerRunOptions{
|
||||
*s = options.ServerRunOptions{
|
||||
GenericServerRunOptions: s.GenericServerRunOptions,
|
||||
KubernetesOptions: conf.KubernetesOptions,
|
||||
DevopsOptions: conf.DevopsOptions,
|
||||
|
||||
@@ -91,7 +91,7 @@ func Load() error {
|
||||
}
|
||||
}
|
||||
|
||||
conf := &Config{}
|
||||
conf := newConfig()
|
||||
if err := viper.Unmarshal(conf); err != nil {
|
||||
klog.Error(fmt.Errorf("error unmarshal configuration %v", err))
|
||||
return err
|
||||
|
||||
@@ -70,8 +70,8 @@ func newTestConfig() *Config {
|
||||
},
|
||||
S3Options: &s2is3.S3Options{
|
||||
Endpoint: "http://minio.openpitrix-system.svc",
|
||||
Region: "us-east-1",
|
||||
DisableSSL: true,
|
||||
Region: "",
|
||||
DisableSSL: false,
|
||||
ForcePathStyle: false,
|
||||
AccessKeyID: "ABCDEFGHIJKLMN",
|
||||
SecretAccessKey: "OPQRSTUVWXYZ",
|
||||
@@ -137,7 +137,7 @@ func cleanTestConfig(t *testing.T) {
|
||||
func TestGet(t *testing.T) {
|
||||
conf := newTestConfig()
|
||||
saveTestConfig(t, conf)
|
||||
//defer cleanTestConfig(t)
|
||||
defer cleanTestConfig(t)
|
||||
|
||||
err := Load()
|
||||
if err != nil {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package alerting
|
||||
|
||||
type AlertingOptions struct {
|
||||
Endpoint string
|
||||
Endpoint string `json:"endpoint" yaml:"endpoint"`
|
||||
}
|
||||
|
||||
func NewAlertingOptions() *AlertingOptions {
|
||||
|
||||
@@ -7,10 +7,10 @@ import (
|
||||
)
|
||||
|
||||
type DevopsOptions struct {
|
||||
Host string `json:",omitempty" yaml:",omitempty" description:"Jenkins service host address"`
|
||||
Username string `json:",omitempty" yaml:",omitempty" description:"Jenkins admin username"`
|
||||
Password string `json:",omitempty" yaml:",omitempty" description:"Jenkins admin password"`
|
||||
MaxConnections int `json:"maxConnections,omitempty" yaml:"maxConnections,omitempty" description:"Maximum connections allowed to connect to Jenkins"`
|
||||
Host string `json:",omitempty" yaml:"host" description:"Jenkins service host address"`
|
||||
Username string `json:",omitempty" yaml:"username" description:"Jenkins admin username"`
|
||||
Password string `json:",omitempty" yaml:"password" description:"Jenkins admin password"`
|
||||
MaxConnections int `json:"maxConnections,omitempty" yaml:"maxConnections" description:"Maximum connections allowed to connect to Jenkins"`
|
||||
}
|
||||
|
||||
// NewDevopsOptions returns a `zero` instance
|
||||
@@ -25,11 +25,6 @@ func NewDevopsOptions() *DevopsOptions {
|
||||
|
||||
// ApplyTo apply configuration to another options
|
||||
func (s *DevopsOptions) ApplyTo(options *DevopsOptions) {
|
||||
if options == nil {
|
||||
options = s
|
||||
return
|
||||
}
|
||||
|
||||
if s.Host != "" {
|
||||
reflectutils.Override(options, s)
|
||||
}
|
||||
|
||||
@@ -6,12 +6,12 @@ import (
|
||||
)
|
||||
|
||||
type ElasticSearchOptions struct {
|
||||
Host string `json:"host,omitempty" yaml:"host,omitempty"`
|
||||
LogstashFormat bool `json:"logstashFormat,omitempty" yaml:"logstashFormat,omitempty"`
|
||||
Index string `json:",omitempty" yaml:",omitempty"`
|
||||
LogstashPrefix string `json:"logstashPrefix,omitempty" yaml:"logstashPrefix,omitempty"`
|
||||
Match string `json:",omitempty" yaml:",omitempty"`
|
||||
Version string `json:",omitempty" yaml:",omitempty"`
|
||||
Host string `json:"host" yaml:"host"`
|
||||
LogstashFormat bool `json:"logstashFormat" yaml:"logstashFormat"`
|
||||
Index string `json:"index" yaml:"index"`
|
||||
LogstashPrefix string `json:"logstashPrefix,omitempty" yaml:"logstashPrefix"`
|
||||
Match string `json:"match" yaml:"match"`
|
||||
Version string `json:"version" yaml:"version"`
|
||||
}
|
||||
|
||||
func NewElasticSearchOptions() *ElasticSearchOptions {
|
||||
@@ -26,11 +26,6 @@ func NewElasticSearchOptions() *ElasticSearchOptions {
|
||||
}
|
||||
|
||||
func (s *ElasticSearchOptions) ApplyTo(options *ElasticSearchOptions) {
|
||||
if options == nil {
|
||||
options = s
|
||||
return
|
||||
}
|
||||
|
||||
if s.Host != "" {
|
||||
reflectutils.Override(options, s)
|
||||
}
|
||||
|
||||
@@ -14,15 +14,15 @@ type KubernetesOptions struct {
|
||||
// kubernetes apiserver public address, used to generate kubeconfig
|
||||
// for downloading, default to host defined in kubeconfig
|
||||
// +optional
|
||||
Master string `json:"master,omitempty" yaml:"master,omitempty"`
|
||||
Master string `json:"master,omitempty" yaml:"master"`
|
||||
|
||||
// kubernetes clientset qps
|
||||
// +optional
|
||||
QPS float32 `json:"qps,omitemtpy" yaml:"qps,omitempty"`
|
||||
QPS float32 `json:"qps,omitemtpy" yaml:"qps"`
|
||||
|
||||
// kubernetes clientset burst
|
||||
// +optional
|
||||
Burst int `json:"burst,omitempty" yaml:"burst,omitempty"`
|
||||
Burst int `json:"burst,omitempty" yaml:"burst"`
|
||||
}
|
||||
|
||||
// NewKubernetesOptions returns a `zero` instance
|
||||
@@ -46,10 +46,6 @@ func (k *KubernetesOptions) Validate() []error {
|
||||
}
|
||||
|
||||
func (k *KubernetesOptions) ApplyTo(options *KubernetesOptions) {
|
||||
if options == nil {
|
||||
options = k
|
||||
return
|
||||
}
|
||||
reflectutils.Override(options, k)
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,8 @@ package kubesphere
|
||||
import "github.com/spf13/pflag"
|
||||
|
||||
type KubeSphereOptions struct {
|
||||
APIServer string
|
||||
AccountServer string
|
||||
APIServer string `json:"apiServer" yaml:"apiServer"`
|
||||
AccountServer string `json:"accountServer" yaml:"accountServer"`
|
||||
}
|
||||
|
||||
// NewKubeSphereOptions create a default options
|
||||
@@ -16,10 +16,6 @@ func NewKubeSphereOptions() *KubeSphereOptions {
|
||||
}
|
||||
|
||||
func (s *KubeSphereOptions) ApplyTo(options *KubeSphereOptions) {
|
||||
if options == nil {
|
||||
options = s
|
||||
return
|
||||
}
|
||||
if s.AccountServer != "" {
|
||||
options.AccountServer = s.AccountServer
|
||||
}
|
||||
|
||||
@@ -6,11 +6,11 @@ import (
|
||||
)
|
||||
|
||||
type LdapOptions struct {
|
||||
Host string `json:"host,omitempty" yaml:"host,omitempty"`
|
||||
ManagerDN string `json:"managerDN,omitempty" yaml:"managerDN,omitempty"`
|
||||
ManagerPassword string `json:"managerPassword,omitempty" yaml:"managerPassword,omitempty"`
|
||||
UserSearchBase string `json:"userSearchBase,omitempty" yaml:"userSearchBase,omitempty"`
|
||||
GroupSearchBase string `json:"groupSearchBase,omitempty" yaml:"groupSearchBase,omitempty"`
|
||||
Host string `json:"host,omitempty" yaml:"host"`
|
||||
ManagerDN string `json:"managerDN,omitempty" yaml:"managerDN"`
|
||||
ManagerPassword string `json:"managerPassword,omitempty" yaml:"managerPassword"`
|
||||
UserSearchBase string `json:"userSearchBase,omitempty" yaml:"userSearchBase"`
|
||||
GroupSearchBase string `json:"groupSearchBase,omitempty" yaml:"groupSearchBase"`
|
||||
}
|
||||
|
||||
// NewLdapOptions return a default option
|
||||
@@ -31,11 +31,6 @@ func (l *LdapOptions) Validate() []error {
|
||||
}
|
||||
|
||||
func (l *LdapOptions) ApplyTo(options *LdapOptions) {
|
||||
if options == nil {
|
||||
options = l
|
||||
return
|
||||
}
|
||||
|
||||
if l.Host != "" {
|
||||
reflectutils.Override(options, l)
|
||||
}
|
||||
|
||||
@@ -7,12 +7,12 @@ import (
|
||||
)
|
||||
|
||||
type MySQLOptions struct {
|
||||
Host string `json:"host,omitempty" yaml:"host,omitempty" description:"MySQL service host address"`
|
||||
Username string `json:"username,omitempty" yaml:"username,omitempty"`
|
||||
Password string `json:"-" yaml:"password,omitempty"`
|
||||
MaxIdleConnections int `json:"maxIdleConnections,omitempty" yaml:"maxIdleConnections,omitempty"`
|
||||
MaxOpenConnections int `json:"maxOpenConnections,omitempty" yaml:"maxOpenConnections,omitempty"`
|
||||
MaxConnectionLifeTime time.Duration `json:"maxConnectionLifeTime,omitempty" yaml:"maxConnectionLifeTime,omitempty"`
|
||||
Host string `json:"host,omitempty" yaml:"host" description:"MySQL service host address"`
|
||||
Username string `json:"username,omitempty" yaml:"username"`
|
||||
Password string `json:"-" yaml:"password"`
|
||||
MaxIdleConnections int `json:"maxIdleConnections,omitempty" yaml:"maxIdleConnections"`
|
||||
MaxOpenConnections int `json:"maxOpenConnections,omitempty" yaml:"maxOpenConnections"`
|
||||
MaxConnectionLifeTime time.Duration `json:"maxConnectionLifeTime,omitempty" yaml:"maxConnectionLifeTime"`
|
||||
}
|
||||
|
||||
// NewMySQLOptions create a `zero` value instance
|
||||
@@ -34,10 +34,6 @@ func (m *MySQLOptions) Validate() []error {
|
||||
}
|
||||
|
||||
func (m *MySQLOptions) ApplyTo(options *MySQLOptions) {
|
||||
if options == nil {
|
||||
options = m
|
||||
return
|
||||
}
|
||||
reflectutils.Override(options, m)
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,8 @@ import (
|
||||
)
|
||||
|
||||
type OpenPitrixOptions struct {
|
||||
APIServer string `json:"apiServer,omitempty" yaml:"apiServer,omitempty"`
|
||||
Token string `json:"token,omitempty" yaml:"token,omitempty"`
|
||||
APIServer string `json:"apiServer,omitempty" yaml:"apiServer"`
|
||||
Token string `json:"token,omitempty" yaml:"token"`
|
||||
}
|
||||
|
||||
func NewOpenPitrixOptions() *OpenPitrixOptions {
|
||||
@@ -19,11 +19,6 @@ func NewOpenPitrixOptions() *OpenPitrixOptions {
|
||||
}
|
||||
|
||||
func (s *OpenPitrixOptions) ApplyTo(options *OpenPitrixOptions) {
|
||||
if options == nil {
|
||||
options = s
|
||||
return
|
||||
}
|
||||
|
||||
if s.APIServer != "" {
|
||||
reflectutils.Override(options, s)
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
)
|
||||
|
||||
type PrometheusOptions struct {
|
||||
Endpoint string `json:"endpoint,omitempty" yaml:"endpoint,omitempty"`
|
||||
SecondaryEndpoint string `json:"secondaryEndpoint,omitempty" yaml:"secondaryEndpoint,omitempty"`
|
||||
Endpoint string `json:"endpoint,omitempty" yaml:"endpoint"`
|
||||
SecondaryEndpoint string `json:"secondaryEndpoint,omitempty" yaml:"secondaryEndpoint"`
|
||||
}
|
||||
|
||||
func NewPrometheusOptions() *PrometheusOptions {
|
||||
@@ -23,11 +23,6 @@ func (s *PrometheusOptions) Validate() []error {
|
||||
}
|
||||
|
||||
func (s *PrometheusOptions) ApplyTo(options *PrometheusOptions) {
|
||||
if options == nil {
|
||||
options = s
|
||||
return
|
||||
}
|
||||
|
||||
if s.Endpoint != "" {
|
||||
options.Endpoint = s.Endpoint
|
||||
}
|
||||
|
||||
@@ -44,11 +44,6 @@ func (r *RedisOptions) Validate() []error {
|
||||
|
||||
// ApplyTo apply to another options if it's a enabled option(non empty host)
|
||||
func (r *RedisOptions) ApplyTo(options *RedisOptions) {
|
||||
if options == nil {
|
||||
options = r
|
||||
return
|
||||
}
|
||||
|
||||
if r.Host != "" {
|
||||
reflectutils.Override(options, r)
|
||||
}
|
||||
|
||||
@@ -7,14 +7,14 @@ import (
|
||||
|
||||
// S3Options contains configuration to access a s3 service
|
||||
type S3Options struct {
|
||||
Endpoint string `json:"endpoint,omitempty" yaml:"endpoint,omitempty"`
|
||||
Region string `json:"region,omitempty" yaml:"region,omitempty"`
|
||||
Endpoint string `json:"endpoint,omitempty" yaml:"endpoint"`
|
||||
Region string `json:"region,omitempty" yaml:"region"`
|
||||
DisableSSL bool `json:"disableSSL" yaml:"disableSSL"`
|
||||
ForcePathStyle bool `json:"forcePathStyle" yaml:"forePathStyle"`
|
||||
AccessKeyID string `json:"accessKeyID,omitempty" yaml:"accessKeyID,omitempty"`
|
||||
SecretAccessKey string `json:"secretAccessKey,omitempty" yaml:"secretAccessKey,omitempty"`
|
||||
SessionToken string `json:"sessionToken,omitempty" yaml:"sessionToken,omitempty"`
|
||||
Bucket string `json:"bucket,omitempty" yaml:"bucket,omitempty"`
|
||||
ForcePathStyle bool `json:"forcePathStyle" yaml:"forcePathStyle"`
|
||||
AccessKeyID string `json:"accessKeyID,omitempty" yaml:"accessKeyID"`
|
||||
SecretAccessKey string `json:"secretAccessKey,omitempty" yaml:"secretAccessKey"`
|
||||
SessionToken string `json:"sessionToken,omitempty" yaml:"sessionToken"`
|
||||
Bucket string `json:"bucket,omitempty" yaml:"bucket"`
|
||||
}
|
||||
|
||||
// NewS3Options creates a default disabled S3Options(empty endpoint)
|
||||
@@ -40,11 +40,6 @@ func (s *S3Options) Validate() []error {
|
||||
|
||||
// ApplyTo overrides options if it's valid, which endpoint is not empty
|
||||
func (s *S3Options) ApplyTo(options *S3Options) {
|
||||
if options == nil {
|
||||
options = s
|
||||
return
|
||||
}
|
||||
|
||||
if s.Endpoint != "" {
|
||||
reflectutils.Override(options, s)
|
||||
}
|
||||
|
||||
@@ -5,13 +5,13 @@ import "github.com/spf13/pflag"
|
||||
type ServiceMeshOptions struct {
|
||||
|
||||
// istio pilot discovery service url
|
||||
IstioPilotHost string `json:"istioPilotHost,omitempty" yaml:"istioPilotHost,omitempty"`
|
||||
IstioPilotHost string `json:"istioPilotHost,omitempty" yaml:"istioPilotHost"`
|
||||
|
||||
// jaeger query service url
|
||||
JaegerQueryHost string `json:"jaegerQueryHost,omitempty" yaml:"jaegerQueryHost,omitempty"`
|
||||
JaegerQueryHost string `json:"jaegerQueryHost,omitempty" yaml:"jaegerQueryHost"`
|
||||
|
||||
// prometheus service url for servicemesh metrics
|
||||
ServicemeshPrometheusHost string `json:"servicemeshPrometheusHost,omitempty" yaml:"servicemeshPrometheusHost,omitempty"`
|
||||
ServicemeshPrometheusHost string `json:"servicemeshPrometheusHost,omitempty" yaml:"servicemeshPrometheusHost"`
|
||||
}
|
||||
|
||||
// NewServiceMeshOptions returns a `zero` instance
|
||||
@@ -30,11 +30,6 @@ func (s *ServiceMeshOptions) Validate() []error {
|
||||
}
|
||||
|
||||
func (s *ServiceMeshOptions) ApplyTo(options *ServiceMeshOptions) {
|
||||
if options == nil {
|
||||
options = s
|
||||
return
|
||||
}
|
||||
|
||||
if s.ServicemeshPrometheusHost != "" {
|
||||
options.ServicemeshPrometheusHost = s.ServicemeshPrometheusHost
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
)
|
||||
|
||||
type SonarQubeOptions struct {
|
||||
Host string `json:",omitempty" yaml:",omitempty" description:"SonarQube service host address"`
|
||||
Token string `json:",omitempty" yaml:",omitempty" description:"SonarQube service token"`
|
||||
Host string `json:",omitempty" yaml:"host" description:"SonarQube service host address"`
|
||||
Token string `json:",omitempty" yaml:"token" description:"SonarQube service token"`
|
||||
}
|
||||
|
||||
func NewSonarQubeOptions() *SonarQubeOptions {
|
||||
@@ -27,11 +27,6 @@ func (s *SonarQubeOptions) Validate() []error {
|
||||
}
|
||||
|
||||
func (s *SonarQubeOptions) ApplyTo(options *SonarQubeOptions) {
|
||||
if options == nil {
|
||||
options = s
|
||||
return
|
||||
}
|
||||
|
||||
if s.Host != "" {
|
||||
options.Host = s.Host
|
||||
options.Token = s.Token
|
||||
|
||||
Reference in New Issue
Block a user