Skip to content

Commit

Permalink
new dbs add in dashboard check
Browse files Browse the repository at this point in the history
Signed-off-by: sayedppqq <[email protected]>
  • Loading branch information
sayedppqq committed May 16, 2024
1 parent be669fc commit 4bc6cca
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
21 changes: 21 additions & 0 deletions pkg/cmds/monitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,15 +89,22 @@ var alertExample = templates.Examples(`
--prom-svc-name=prometheus-kube-prometheus-prometheus --prom-svc-namespace=monitoring --prom-svc-port=9090
Valid resource types include:
* connectcluster
* druid
* elasticsearch
* kafka
* mariadb
* mongodb
* mysql
* perconaxtradb
* pgpool
* postgres
* proxysql
* rabbitmq
* redis
* singlestore
* solr
* zookeeper
`)

func AlertCMD(f cmdutil.Factory) *cobra.Command {
Expand Down Expand Up @@ -131,15 +138,22 @@ var dashboardExample = templates.Examples(`
--prom-svc-name=prometheus-kube-prometheus-prometheus --prom-svc-namespace=monitoring --prom-svc-port=9090
Valid dashboards include:
* connectcluster
* druid
* elasticsearch
* kafka
* mariadb
* mongodb
* mysql
* perconaxtradb
* pgpool
* postgres
* proxysql
* rabbitmq
* redis
* singlestore
* solr
* zookeeper
If --file is given, that is the local file. absolute or relative path both accepted.
If --url is given, that is the remote file. You have to specify the full raw url.
Expand Down Expand Up @@ -186,15 +200,22 @@ var connectionExample = templates.Examples(`
--prom-svc-name=prometheus-kube-prometheus-prometheus --prom-svc-namespace=monitoring --prom-svc-port=9090
Valid resource types include:
* connectcluster
* druid
* elasticsearch
* kafka
* mariadb
* mongodb
* mysql
* perconaxtradb
* pgpool
* postgres
* proxysql
* rabbitmq
* redis
* singlestore
* solr
* zookeeper
`)

func ConnectionCMD(f cmdutil.Factory) *cobra.Command {
Expand Down
29 changes: 29 additions & 0 deletions pkg/monitor/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,18 @@ import (
"log"
"strings"

kapi "kubedb.dev/apimachinery/apis/kafka/v1alpha1"
api "kubedb.dev/apimachinery/apis/kubedb/v1alpha2"
)

func ConvertedResourceToPlural(resource string) string {
// standardizing the resource name
res := strings.ToLower(resource)
switch res {
case kapi.ResourceCodeConnectCluster, kapi.ResourcePluralConnectCluster, kapi.ResourceSingularConnectCluster:
res = kapi.ResourcePluralConnectCluster
case api.ResourceCodeDruid, api.ResourcePluralDruid, api.ResourceSingularDruid:
res = api.ResourcePluralDruid
case api.ResourceCodeElasticsearch, api.ResourcePluralElasticsearch, api.ResourceSingularElasticsearch:
res = api.ResourcePluralElasticsearch
case api.ResourceCodeKafka, api.ResourcePluralKafka, api.ResourceSingularKafka:
Expand All @@ -39,12 +44,22 @@ func ConvertedResourceToPlural(resource string) string {
res = api.ResourcePluralMySQL
case api.ResourceCodePerconaXtraDB, api.ResourcePluralPerconaXtraDB, api.ResourceSingularPerconaXtraDB:
res = api.ResourcePluralPerconaXtraDB
case api.ResourceCodePgpool, api.ResourcePluralPgpool, api.ResourceSingularPgpool:
res = api.ResourcePluralPgpool
case api.ResourceCodePostgres, api.ResourcePluralPostgres, api.ResourceSingularPostgres:
res = api.ResourcePluralPostgres
case api.ResourceCodeProxySQL, api.ResourcePluralProxySQL, api.ResourceSingularProxySQL:
res = api.ResourcePluralProxySQL
case api.ResourceCodeRabbitmq, api.ResourcePluralRabbitmq, api.ResourceSingularRabbitmq:
res = api.ResourcePluralRabbitmq
case api.ResourceCodeRedis, api.ResourcePluralRedis, api.ResourceSingularRedis:
res = api.ResourcePluralRedis
case api.ResourceCodeSinglestore, api.ResourcePluralSinglestore, api.ResourceSingularSinglestore:
res = api.ResourcePluralSinglestore
case api.ResourceCodeSolr, api.ResourcePluralSolr, api.ResourceSingularSolr:
res = api.ResourcePluralSolr
case api.ResourceCodeZooKeeper, api.ResourcePluralZooKeeper, api.ResourceSingularZooKeeper:
res = api.ResourcePluralZooKeeper
default:
log.Fatalf("%s is not a valid resource type \n", resource)
}
Expand All @@ -55,6 +70,10 @@ func ConvertedResourceToSingular(resource string) string {
// standardizing the resource name
res := strings.ToLower(resource)
switch res {
case kapi.ResourceCodeConnectCluster, kapi.ResourcePluralConnectCluster, kapi.ResourceSingularConnectCluster:
res = kapi.ResourceSingularConnectCluster
case api.ResourceCodeDruid, api.ResourcePluralDruid, api.ResourceSingularDruid:
res = api.ResourceSingularDruid
case api.ResourceCodeElasticsearch, api.ResourcePluralElasticsearch, api.ResourceSingularElasticsearch:
res = api.ResourceSingularElasticsearch
case api.ResourceCodeKafka, api.ResourcePluralKafka, api.ResourceSingularKafka:
Expand All @@ -67,12 +86,22 @@ func ConvertedResourceToSingular(resource string) string {
res = api.ResourceSingularMySQL
case api.ResourceCodePerconaXtraDB, api.ResourcePluralPerconaXtraDB, api.ResourceSingularPerconaXtraDB:
res = api.ResourceSingularPerconaXtraDB
case api.ResourceCodePgpool, api.ResourcePluralPgpool, api.ResourceSingularPgpool:
res = api.ResourceSingularPgpool
case api.ResourceCodePostgres, api.ResourcePluralPostgres, api.ResourceSingularPostgres:
res = api.ResourceSingularPostgres
case api.ResourceCodeProxySQL, api.ResourcePluralProxySQL, api.ResourceSingularProxySQL:
res = api.ResourceSingularProxySQL
case api.ResourceCodeRabbitmq, api.ResourcePluralRabbitmq, api.ResourceSingularRabbitmq:
res = api.ResourceSingularRabbitmq
case api.ResourceCodeRedis, api.ResourcePluralRedis, api.ResourceSingularRedis:
res = api.ResourceSingularRedis
case api.ResourceCodeSinglestore, api.ResourcePluralSinglestore, api.ResourceSingularSinglestore:
res = api.ResourceSingularSinglestore
case api.ResourceCodeSolr, api.ResourcePluralSolr, api.ResourceSingularSolr:
res = api.ResourceSingularSolr
case api.ResourceCodeZooKeeper, api.ResourcePluralZooKeeper, api.ResourceSingularZooKeeper:
res = api.ResourceSingularZooKeeper
default:
log.Fatalf("%s is not a valid resource type \n", resource)
}
Expand Down

0 comments on commit 4bc6cca

Please sign in to comment.