Skip to content

Commit

Permalink
Fix data insertion command for mongo & mariadb (#758)
Browse files Browse the repository at this point in the history
Signed-off-by: Arnob kumar saha <[email protected]>
  • Loading branch information
ArnobKumarSaha authored Feb 15, 2024
1 parent 3b3001d commit 8da97b4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion pkg/data/mariadb.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ import (
cmdutil "k8s.io/kubectl/pkg/cmd/util"
)

const (
mdCaFile = "/etc/mysql/certs/client/ca.crt"
mdCertFile = "/etc/mysql/certs/client/tls.crt"
mdKeyFile = "/etc/mysql/certs/client/tls.key"
)

func InsertMariaDBDataCMD(f cmdutil.Factory) *cobra.Command {
var (
dbName string
Expand Down Expand Up @@ -317,7 +323,7 @@ func (opts *mariadbOpts) getShellCommand(command string) (string, error) {
containerName := "mariadb"

if db.Spec.TLS != nil {
cmd = fmt.Sprintf("kubectl exec -n %s svc/%s -c %s -- mysql -u%s -p'%s' --host=%s --port=%s --ssl-ca='%v' --ssl-cert='%v' --ssl-key='%v' %s -e \"%s\"", db.Namespace, db.OffshootName(), containerName, user, password, "127.0.0.1", "3306", myCaFile, myCertFile, myKeyFile, api.ResourceSingularMySQL, command)
cmd = fmt.Sprintf("kubectl exec -n %s svc/%s -c %s -- mysql -u%s -p'%s' --host=%s --port=%s --ssl-ca='%v' --ssl-cert='%v' --ssl-key='%v' %s -e \"%s\"", db.Namespace, db.OffshootName(), containerName, user, password, "127.0.0.1", "3306", mdCaFile, mdCertFile, mdKeyFile, api.ResourceSingularMySQL, command)
} else {
cmd = fmt.Sprintf("kubectl exec -n %s svc/%s -c %s -- mysql -u%s -p'%s' %s -e \"%s\"", db.Namespace, db.OffshootName(), containerName, user, password, api.ResourceSingularMySQL, command)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/data/mongodb.go
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ func (opts *mongoDBOpts) getShellCommand(command string) (*shell.Session, error)
if err != nil {
return nil, err
}
mgCommand = append(mgCommand, c)
mgCommand = append(mgCommand, c...)
} else {
mgCommand = append(mgCommand,
KubeDBDatabaseName, "--quiet",
Expand Down Expand Up @@ -413,7 +413,7 @@ func (opts *mongoDBOpts) handleTLS() ([]interface{}, error) {
}

mgCommand := []interface{}{
"mongo", KubeDBDatabaseName, "--quiet",
KubeDBDatabaseName, "--quiet",
"--tls",
fmt.Sprintf("--tlsCAFile=%v", mgCAFile),
fmt.Sprintf("--tlsCertificateKeyFile=%v", mgPEMFile),
Expand Down

0 comments on commit 8da97b4

Please sign in to comment.