Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/arg-parser/src/cli-options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export interface CliOptions {
quiet?: boolean;
retryWrites?: boolean;
shell?: boolean;
skipStartupWarnings?: boolean;
tls?: boolean;
tlsAllowInvalidCertificates?: boolean;
tlsAllowInvalidHostnames?: boolean;
Expand Down
1 change: 1 addition & 0 deletions packages/cli-repl/src/arg-parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const OPTIONS = {
'retryWrites',
'shell',
'smokeTests',
'skipStartupWarnings',
'ssl',
'sslAllowInvalidCertificates',
'sslAllowInvalidHostnames',
Expand Down
20 changes: 20 additions & 0 deletions packages/cli-repl/src/mongosh-repl.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1345,6 +1345,26 @@ describe('MongoshNodeRepl', function () {
'The server generated these startup warnings when booting'
);
});

it('startup warnings are absent when skipStartupWarnings flag is present', async function () {
mongoshRepl.shellCliOptions.skipStartupWarnings = true;
// Make sure the startupWarnings resolves with errors
sp.runCommandWithCheck
.withArgs(
ADMIN_DB,
{
getLog: 'startupWarnings',
},
{}
)
.resolves({ ok: 1, log: logLines });
// Make sure the connection info indicates a local Atlas server

await mongoshRepl.initialize(serviceProvider);
expect(output).to.not.contain(
'The server generated these startup warnings when booting'
);
});
});
}
});
Expand Down
11 changes: 7 additions & 4 deletions packages/cli-repl/src/mongosh-repl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ declare const __non_webpack_require__: any;
*/
export type MongoshCliOptions = ShellCliOptions & {
quiet?: boolean;
skipStartupWarnings?: boolean;
/**
* Whether to instantiate a Node.js REPL instance, including support
* for async error tracking, or not.
Expand Down Expand Up @@ -375,10 +376,12 @@ class MongoshNodeRepl implements EvaluationListener {
const { shellApi } = instanceState;
// Assuming `instanceState.fetchConnectionInfo()` was already called above
const connectionInfo = instanceState.cachedConnectionInfo();
// Skipping startup warnings (see https://jira.mongodb.org/browse/MONGOSH-1776)
const bannerCommands = connectionInfo?.extraInfo?.is_local_atlas
? ['automationNotices', 'nonGenuineMongoDBCheck']
: ['startupWarnings', 'automationNotices', 'nonGenuineMongoDBCheck'];
// Skipping startup warnings (see https://jira.mongodb.org/browse/MONGOSH-1776 and https://jira.mongodb.org/browse/MONGOSH-2371)
const bannerCommands =
connectionInfo?.extraInfo?.is_local_atlas ||
this.shellCliOptions.skipStartupWarnings
? ['automationNotices', 'nonGenuineMongoDBCheck']
: ['startupWarnings', 'automationNotices', 'nonGenuineMongoDBCheck'];
const banners = await Promise.all(
bannerCommands.map(
async (command) => await shellApi._untrackedShow(command)
Expand Down