From a200ab35445d1afd2eff5eee12c5af24e4c49cf7 Mon Sep 17 00:00:00 2001 From: STeve Huang Date: Thu, 24 Oct 2024 09:31:43 -0400 Subject: [PATCH] Fix "tsh db connect" to MongoDB databases when cluster has separate MongoDB port --- tool/tsh/common/db.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tool/tsh/common/db.go b/tool/tsh/common/db.go index 738914fa86e4e..6bb7e75cf6cc1 100644 --- a/tool/tsh/common/db.go +++ b/tool/tsh/common/db.go @@ -653,7 +653,6 @@ func maybeStartLocalProxy(ctx context.Context, cf *CLIConf, host := "localhost" cmdOpts := []dbcmd.ConnectCommandFunc{ dbcmd.WithLocalProxy(host, addr.Port(0), profile.CACertPathForCluster(rootClusterName)), - dbcmd.WithGetDatabaseFunc(dbInfo.getDatabaseForDBCmd), } if requires.tunnel { cmdOpts = append(cmdOpts, dbcmd.WithNoTLS()) @@ -777,7 +776,10 @@ func onDatabaseConnect(cf *CLIConf) error { if err != nil { return trace.Wrap(err) } - opts = append(opts, dbcmd.WithLogger(log)) + opts = append(opts, + dbcmd.WithLogger(log), + dbcmd.WithGetDatabaseFunc(dbInfo.getDatabaseForDBCmd), + ) if opts, err = maybeAddDBUserPassword(cf, tc, dbInfo, opts); err != nil { return trace.Wrap(err)