Skip to content

Commit

Permalink
fix lint error
Browse files Browse the repository at this point in the history
Signed-off-by: souravbiswassanto <[email protected]>
  • Loading branch information
souravbiswassanto committed Jun 11, 2024
1 parent 5055ad2 commit 39d546b
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 22 deletions.
3 changes: 2 additions & 1 deletion elasticsearch/kubedb_client_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
6 changes: 3 additions & 3 deletions kafka/connect/kubedb_client_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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},
Expand Down
5 changes: 3 additions & 2 deletions mariadb/kubedb_client_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion mongodb/kubedb_client_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 <DB_NAME>-shard<SHARD_NUMBER>-arbiter for shard, <DB_NAME>-arbiter otherwise.
// so excluding '-arbiter' will give us the stsName where this arbiter belongs as a member of rs
nodeType = nodeType[:strings.LastIndex(nodeType, "-")]
Expand Down
7 changes: 4 additions & 3 deletions mysql/kubedb_client_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
}

Expand Down
7 changes: 4 additions & 3 deletions perconaxtradb/kubedb_client_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
}

Expand Down
3 changes: 2 additions & 1 deletion pgbouncer/kubedb_client_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"context"
"fmt"

"kubedb.dev/apimachinery/apis/kubedb"
api "kubedb.dev/apimachinery/apis/kubedb/v1alpha2"

_ "github.com/lib/pq"
Expand Down Expand Up @@ -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)
}
Expand Down
3 changes: 2 additions & 1 deletion proxysql/kubedb_client_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
7 changes: 4 additions & 3 deletions rabbitmq/kubedb_client_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)
Expand Down Expand Up @@ -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 "/"
Expand Down
3 changes: 2 additions & 1 deletion redis/kubedb_client_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
3 changes: 2 additions & 1 deletion redissentinel/kubedb_client_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
5 changes: 3 additions & 2 deletions singlestore/kubedb_client_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 39d546b

Please sign in to comment.