From 39d546baaa742dbb8194c91206544d50edacf253 Mon Sep 17 00:00:00 2001 From: souravbiswassanto Date: Tue, 11 Jun 2024 16:39:46 +0600 Subject: [PATCH] fix lint error Signed-off-by: souravbiswassanto --- elasticsearch/kubedb_client_builder.go | 3 ++- kafka/connect/kubedb_client_builder.go | 6 +++--- mariadb/kubedb_client_builder.go | 5 +++-- mongodb/kubedb_client_builder.go | 3 ++- mysql/kubedb_client_builder.go | 7 ++++--- perconaxtradb/kubedb_client_builder.go | 7 ++++--- pgbouncer/kubedb_client_builder.go | 3 ++- proxysql/kubedb_client_builder.go | 3 ++- rabbitmq/kubedb_client_builder.go | 7 ++++--- redis/kubedb_client_builder.go | 3 ++- redissentinel/kubedb_client_builder.go | 3 ++- singlestore/kubedb_client_builder.go | 5 +++-- 12 files changed, 33 insertions(+), 22 deletions(-) diff --git a/elasticsearch/kubedb_client_builder.go b/elasticsearch/kubedb_client_builder.go index fdc728992..51bdd5497 100644 --- a/elasticsearch/kubedb_client_builder.go +++ b/elasticsearch/kubedb_client_builder.go @@ -29,6 +29,7 @@ import ( catalog "kubedb.dev/apimachinery/apis/catalog/v1alpha1" "kubedb.dev/apimachinery/apis/elasticsearch/v1alpha1" + "kubedb.dev/apimachinery/apis/kubedb" api "kubedb.dev/apimachinery/apis/kubedb/v1alpha2" "github.com/Masterminds/semver/v3" @@ -539,5 +540,5 @@ func (o *KubeDBClientBuilder) getDefaultTLSConfig() (*tls.Config, error) { } func (o *KubeDBClientBuilder) ServiceURL() string { - return fmt.Sprintf("%v://%s.%s.svc:%d", o.db.GetConnectionScheme(), o.db.ServiceName(), o.db.GetNamespace(), api.ElasticsearchRestPort) + return fmt.Sprintf("%v://%s.%s.svc:%d", o.db.GetConnectionScheme(), o.db.ServiceName(), o.db.GetNamespace(), kubedb.ElasticsearchRestPort) } diff --git a/kafka/connect/kubedb_client_builder.go b/kafka/connect/kubedb_client_builder.go index c100b7934..be8b7a268 100644 --- a/kafka/connect/kubedb_client_builder.go +++ b/kafka/connect/kubedb_client_builder.go @@ -31,7 +31,7 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/klog/v2" kapi "kubedb.dev/apimachinery/apis/kafka/v1alpha1" - api "kubedb.dev/apimachinery/apis/kubedb/v1alpha2" + "kubedb.dev/apimachinery/apis/kubedb" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -107,8 +107,8 @@ func (o *KubeDBClientBuilder) GetConnectClusterClient() (*Client, error) { klog.Error(err, "failed to create certificate for TLS config") return nil, err } - clientCA.AppendCertsFromPEM(certSecret.Data[api.CACert]) - rootCA.AppendCertsFromPEM(certSecret.Data[api.CACert]) + clientCA.AppendCertsFromPEM(certSecret.Data[kubedb.CACert]) + rootCA.AppendCertsFromPEM(certSecret.Data[kubedb.CACert]) config.transport.TLSClientConfig = &tls.Config{ Certificates: []tls.Certificate{crt}, diff --git a/mariadb/kubedb_client_builder.go b/mariadb/kubedb_client_builder.go index e44e722b1..2bad69806 100644 --- a/mariadb/kubedb_client_builder.go +++ b/mariadb/kubedb_client_builder.go @@ -23,6 +23,7 @@ import ( "database/sql" "fmt" + "kubedb.dev/apimachinery/apis/kubedb" api "kubedb.dev/apimachinery/apis/kubedb/v1alpha2" sql_driver "github.com/go-sql-driver/mysql" @@ -191,14 +192,14 @@ func (o *KubeDBClientBuilder) getConnectionString() (string, error) { } var clientCert []tls.Certificate clientCert = append(clientCert, cert) - err = sql_driver.RegisterTLSConfig(api.MariaDBTLSConfigCustom, &tls.Config{ + err = sql_driver.RegisterTLSConfig(kubedb.MariaDBTLSConfigCustom, &tls.Config{ RootCAs: certPool, Certificates: clientCert, }) if err != nil { return "", err } - tlsConfig = fmt.Sprintf("tls=%s", api.MariaDBTLSConfigCustom) + tlsConfig = fmt.Sprintf("tls=%s", kubedb.MariaDBTLSConfigCustom) } connector := fmt.Sprintf("%v:%v@tcp(%s:%d)/%s?%s", user, pass, o.url, 3306, "mysql", tlsConfig) return connector, nil diff --git a/mongodb/kubedb_client_builder.go b/mongodb/kubedb_client_builder.go index 46b37001a..cc86e0867 100644 --- a/mongodb/kubedb_client_builder.go +++ b/mongodb/kubedb_client_builder.go @@ -23,6 +23,7 @@ import ( "strings" "time" + "kubedb.dev/apimachinery/apis/kubedb" api "kubedb.dev/apimachinery/apis/kubedb/v1alpha2" "go.mongodb.org/mongo-driver/mongo" @@ -144,7 +145,7 @@ func (o *KubeDBClientBuilder) GetMongoClient() (*Client, error) { func (o *KubeDBClientBuilder) getURL() string { nodeType := o.podName[:strings.LastIndex(o.podName, "-")] - if strings.HasSuffix(nodeType, api.NodeTypeArbiter) { + if strings.HasSuffix(nodeType, kubedb.NodeTypeArbiter) { // nodeType looks like -shard-arbiter for shard, -arbiter otherwise. // so excluding '-arbiter' will give us the stsName where this arbiter belongs as a member of rs nodeType = nodeType[:strings.LastIndex(nodeType, "-")] diff --git a/mysql/kubedb_client_builder.go b/mysql/kubedb_client_builder.go index c865ac0a5..aaa3767d3 100644 --- a/mysql/kubedb_client_builder.go +++ b/mysql/kubedb_client_builder.go @@ -23,6 +23,7 @@ import ( "database/sql" "fmt" + "kubedb.dev/apimachinery/apis/kubedb" api "kubedb.dev/apimachinery/apis/kubedb/v1alpha2" sql_driver "github.com/go-sql-driver/mysql" @@ -172,16 +173,16 @@ func (o *KubeDBClientBuilder) getConnectionString() (string, error) { // tls custom setup if o.db.Spec.RequireSSL { - err = sql_driver.RegisterTLSConfig(api.MySQLTLSConfigCustom, &tls.Config{ + err = sql_driver.RegisterTLSConfig(kubedb.MySQLTLSConfigCustom, &tls.Config{ RootCAs: certPool, Certificates: clientCert, }) if err != nil { return "", err } - tlsConfig = fmt.Sprintf("tls=%s", api.MySQLTLSConfigCustom) + tlsConfig = fmt.Sprintf("tls=%s", kubedb.MySQLTLSConfigCustom) } else { - tlsConfig = fmt.Sprintf("tls=%s", api.MySQLTLSConfigSkipVerify) + tlsConfig = fmt.Sprintf("tls=%s", kubedb.MySQLTLSConfigSkipVerify) } } diff --git a/perconaxtradb/kubedb_client_builder.go b/perconaxtradb/kubedb_client_builder.go index f1f9a5a32..96dcc0f69 100644 --- a/perconaxtradb/kubedb_client_builder.go +++ b/perconaxtradb/kubedb_client_builder.go @@ -23,6 +23,7 @@ import ( "database/sql" "fmt" + "kubedb.dev/apimachinery/apis/kubedb" api "kubedb.dev/apimachinery/apis/kubedb/v1alpha2" sql_driver "github.com/go-sql-driver/mysql" @@ -172,16 +173,16 @@ func (o *KubeDBClientBuilder) getConnectionString() (string, error) { // tls custom setup if o.db.Spec.RequireSSL { - err = sql_driver.RegisterTLSConfig(api.PerconaXtraDBTLSConfigCustom, &tls.Config{ + err = sql_driver.RegisterTLSConfig(kubedb.PerconaXtraDBTLSConfigCustom, &tls.Config{ RootCAs: certPool, Certificates: clientCert, }) if err != nil { return "", err } - tlsConfig = fmt.Sprintf("tls=%s", api.PerconaXtraDBTLSConfigCustom) + tlsConfig = fmt.Sprintf("tls=%s", kubedb.PerconaXtraDBTLSConfigCustom) } else { - tlsConfig = fmt.Sprintf("tls=%s", api.MySQLTLSConfigSkipVerify) + tlsConfig = fmt.Sprintf("tls=%s", kubedb.MySQLTLSConfigSkipVerify) } } diff --git a/pgbouncer/kubedb_client_builder.go b/pgbouncer/kubedb_client_builder.go index 337aaf354..c722635ed 100644 --- a/pgbouncer/kubedb_client_builder.go +++ b/pgbouncer/kubedb_client_builder.go @@ -20,6 +20,7 @@ import ( "context" "fmt" + "kubedb.dev/apimachinery/apis/kubedb" api "kubedb.dev/apimachinery/apis/kubedb/v1alpha2" _ "github.com/lib/pq" @@ -174,7 +175,7 @@ func (o *KubeDBClientBuilder) getConnectionString() (string, error) { o.url = o.getURL() } - var listeningPort int = api.PgBouncerDatabasePort + var listeningPort int = kubedb.PgBouncerDatabasePort if o.pgbouncer.Spec.ConnectionPool.Port != nil { listeningPort = int(*o.pgbouncer.Spec.ConnectionPool.Port) } diff --git a/proxysql/kubedb_client_builder.go b/proxysql/kubedb_client_builder.go index d68c8a4d9..2da729ae2 100644 --- a/proxysql/kubedb_client_builder.go +++ b/proxysql/kubedb_client_builder.go @@ -21,6 +21,7 @@ import ( "database/sql" "fmt" + "kubedb.dev/apimachinery/apis/kubedb" api "kubedb.dev/apimachinery/apis/kubedb/v1alpha2" core "k8s.io/api/core/v1" @@ -144,6 +145,6 @@ func (o *KubeDBClientBuilder) getConnectionString() (string, error) { o.url = o.getURL() } - connector := fmt.Sprintf("%v:%v@tcp(%s:%d)/", user, pass, o.url, api.ProxySQLAdminPort) + connector := fmt.Sprintf("%v:%v@tcp(%s:%d)/", user, pass, o.url, kubedb.ProxySQLAdminPort) return connector, nil } diff --git a/rabbitmq/kubedb_client_builder.go b/rabbitmq/kubedb_client_builder.go index 26ea19600..9cf7b60f8 100644 --- a/rabbitmq/kubedb_client_builder.go +++ b/rabbitmq/kubedb_client_builder.go @@ -28,6 +28,7 @@ import ( kerr "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/types" "k8s.io/klog/v2" + "kubedb.dev/apimachinery/apis/kubedb" api "kubedb.dev/apimachinery/apis/kubedb/v1alpha2" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -163,15 +164,15 @@ func (o *KubeDBClientBuilder) GetRabbitMQClient() (*Client, error) { } func (o *KubeDBClientBuilder) GetAMQPconnURL(username string, password string) string { - return fmt.Sprintf("amqp://%s:%s@%s.%s.svc.cluster.local:%d/", username, password, o.db.OffshootName(), o.db.Namespace, api.RabbitMQAMQPPort) + return fmt.Sprintf("amqp://%s:%s@%s.%s.svc.cluster.local:%d/", username, password, o.db.OffshootName(), o.db.Namespace, kubedb.RabbitMQAMQPPort) } func (o *KubeDBClientBuilder) GetHTTPconnURL() string { protocolScheme := rmqhttp.HTTP if o.podName != "" { - return fmt.Sprintf("%s://%s.%s.%s.svc:%d", protocolScheme, o.podName, o.db.GoverningServiceName(), o.db.Namespace, api.RabbitMQManagementUIPort) + return fmt.Sprintf("%s://%s.%s.%s.svc:%d", protocolScheme, o.podName, o.db.GoverningServiceName(), o.db.Namespace, kubedb.RabbitMQManagementUIPort) } - return fmt.Sprintf("%s://%s.%s.svc.cluster.local:%d", protocolScheme, o.db.ServiceName(), o.db.Namespace, api.RabbitMQManagementUIPort) + return fmt.Sprintf("%s://%s.%s.svc.cluster.local:%d", protocolScheme, o.db.ServiceName(), o.db.Namespace, kubedb.RabbitMQManagementUIPort) } // RabbitMQ server have a default virtual host "/" diff --git a/redis/kubedb_client_builder.go b/redis/kubedb_client_builder.go index 5241b0a37..7e7bd84d6 100644 --- a/redis/kubedb_client_builder.go +++ b/redis/kubedb_client_builder.go @@ -24,6 +24,7 @@ import ( "fmt" "time" + "kubedb.dev/apimachinery/apis/kubedb" api "kubedb.dev/apimachinery/apis/kubedb/v1alpha2" rd "github.com/redis/go-redis/v9" @@ -182,5 +183,5 @@ func (o *KubeDBClientBuilder) getTLSConfig(ctx context.Context) (*tls.Config, er } func (o *KubeDBClientBuilder) getPodURL() string { - return fmt.Sprintf("%v.%v.%v.svc:%d", o.podName, o.db.GoverningServiceName(), o.db.Namespace, api.RedisDatabasePort) + return fmt.Sprintf("%v.%v.%v.svc:%d", o.podName, o.db.GoverningServiceName(), o.db.Namespace, kubedb.RedisDatabasePort) } diff --git a/redissentinel/kubedb_client_builder.go b/redissentinel/kubedb_client_builder.go index 4c472fe3f..20231494c 100644 --- a/redissentinel/kubedb_client_builder.go +++ b/redissentinel/kubedb_client_builder.go @@ -24,6 +24,7 @@ import ( "fmt" "time" + "kubedb.dev/apimachinery/apis/kubedb" api "kubedb.dev/apimachinery/apis/kubedb/v1alpha2" rd "github.com/redis/go-redis/v9" @@ -141,5 +142,5 @@ func (o *KubeDBClientBuilder) getTLSConfig(ctx context.Context) (*tls.Config, er } func (o *KubeDBClientBuilder) getSentinelPodURL() string { - return fmt.Sprintf("%v.%v.%v.svc:%d", o.podName, o.db.GoverningServiceName(), o.db.Namespace, api.RedisSentinelPort) + return fmt.Sprintf("%v.%v.%v.svc:%d", o.podName, o.db.GoverningServiceName(), o.db.Namespace, kubedb.RedisSentinelPort) } diff --git a/singlestore/kubedb_client_builder.go b/singlestore/kubedb_client_builder.go index 492120156..7ed889c45 100644 --- a/singlestore/kubedb_client_builder.go +++ b/singlestore/kubedb_client_builder.go @@ -26,6 +26,7 @@ import ( sql_driver "github.com/go-sql-driver/mysql" core "k8s.io/api/core/v1" "k8s.io/klog/v2" + "kubedb.dev/apimachinery/apis/kubedb" api "kubedb.dev/apimachinery/apis/kubedb/v1alpha2" "sigs.k8s.io/controller-runtime/pkg/client" "xorm.io/xorm" @@ -170,14 +171,14 @@ func (o *KubeDBClientBuilder) getConnectionString() (string, error) { clientCert = append(clientCert, cert) // tls custom setup - err = sql_driver.RegisterTLSConfig(api.SinglestoreTLSConfigCustom, &tls.Config{ + err = sql_driver.RegisterTLSConfig(kubedb.SinglestoreTLSConfigCustom, &tls.Config{ RootCAs: certPool, Certificates: clientCert, }) if err != nil { return "", err } - tlsConfig = fmt.Sprintf("tls=%s", api.SinglestoreTLSConfigCustom) + tlsConfig = fmt.Sprintf("tls=%s", kubedb.SinglestoreTLSConfigCustom) } connector := fmt.Sprintf("%v:%v@tcp(%s:%d)/%s?%s", user, pass, o.url, 3306, "memsql", tlsConfig)