Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

log-forwarding config: downplay spinner messaging #510

Merged
merged 2 commits into from
Jan 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
13 changes: 10 additions & 3 deletions src/commands/app/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,12 @@ class Deploy extends BuildCommand {
try {
const aioConfig = this.getFullConfig().aio
// 1. update log forwarding configuration
if (flags['log-forwarding-update'] && flags.actions) {
// note: it is possible that .aio file does not exist, which means there is no local lg config
if (aioConfig &&
aioConfig.project &&
aioConfig.project.workspace &&
flags['log-forwarding-update'] &&
flags.actions) {
spinner.start('Updating log forwarding configuration')
try {
const lf = await LogForwarding.init(aioConfig)
Expand All @@ -68,10 +73,12 @@ class Deploy extends BuildCommand {
await lf.updateServerConfig(lfConfig)
spinner.succeed(chalk.green(`Log forwarding is set to '${lfConfig.getDestination()}'`))
} else {
spinner.fail(chalk.green('Log forwarding is not updated: no configuration is provided'))
if (flags.verbose) {
spinner.info(chalk.dim('Log forwarding is not updated: no configuration is provided'))
}
}
} else {
spinner.fail(chalk.green('Log forwarding is not updated: configuration not changed since last update'))
spinner.info(chalk.dim('Log forwarding is not updated: configuration not changed since last update'))
}
} catch (error) {
spinner.fail(chalk.red('Log forwarding is not updated.'))
Expand Down
9 changes: 9 additions & 0 deletions test/commands/app/deploy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,15 @@ describe('run', () => {
expect(mockLogForwarding.updateServerConfig).toBeCalledTimes(0)
})

test('log forwarding is not updated on server when local config is absent --verbose', async () => {
command.getAppExtConfigs.mockReturnValueOnce(createAppConfig(command.appConfig))
const config = new LogForwarding.LogForwardingConfig()
mockLogForwarding.getLocalConfigWithSecrets.mockReturnValue(config)
command.argv = ['--verbose']
await command.run()
expect(mockLogForwarding.updateServerConfig).toBeCalledTimes(0)
})

test('log forwarding is not updated on server when local config not changed', async () => {
command.getAppExtConfigs.mockReturnValueOnce(createAppConfig(command.appConfig))
mockLogForwarding.isLocalConfigChanged.mockReturnValue(false)
Expand Down