custom alerting use the same API group and flagset to alerting

Signed-off-by: junotx <junotx@126.com>
This commit is contained in:
junotx
2021-01-12 16:43:13 +08:00
parent 6f9d306368
commit 514fec7eb4
21 changed files with 261 additions and 294 deletions

View File

@@ -25,7 +25,6 @@ import (
"kubesphere.io/kubesphere/pkg/simple/client/alerting"
auditingclient "kubesphere.io/kubesphere/pkg/simple/client/auditing/elasticsearch"
"kubesphere.io/kubesphere/pkg/simple/client/cache"
"kubesphere.io/kubesphere/pkg/simple/client/customalerting"
"kubesphere.io/kubesphere/pkg/simple/client/devops/jenkins"
eventsclient "kubesphere.io/kubesphere/pkg/simple/client/events/elasticsearch"
"kubesphere.io/kubesphere/pkg/simple/client/k8s"
@@ -98,7 +97,6 @@ type Config struct {
AuditingOptions *auditingclient.Options `json:"auditing,omitempty" yaml:"auditing,omitempty" mapstructure:"auditing"`
AlertingOptions *alerting.Options `json:"alerting,omitempty" yaml:"alerting,omitempty" mapstructure:"alerting"`
NotificationOptions *notification.Options `json:"notification,omitempty" yaml:"notification,omitempty" mapstructure:"notification"`
CustomAlertingOptions *customalerting.Options `json:"customalerting,omitempty" yaml:"customalerting,omitempty" mapstructure:"customalerting"`
}
// newConfig creates a default non-empty Config
@@ -122,7 +120,6 @@ func New() *Config {
MultiClusterOptions: multicluster.NewOptions(),
EventsOptions: eventsclient.NewElasticSearchOptions(),
AuditingOptions: auditingclient.NewElasticSearchOptions(),
CustomAlertingOptions: customalerting.NewOptions(),
}
}
@@ -250,7 +247,8 @@ func (conf *Config) stripEmptyOptions() {
conf.S3Options = nil
}
if conf.AlertingOptions != nil && conf.AlertingOptions.Endpoint == "" {
if conf.AlertingOptions != nil && conf.AlertingOptions.Endpoint == "" &&
conf.AlertingOptions.PrometheusEndpoint == "" && conf.AlertingOptions.ThanosRulerEndpoint == "" {
conf.AlertingOptions = nil
}