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 on stdout only new config and exit process #939

Merged
merged 1 commit into from
Nov 16, 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
9 changes: 3 additions & 6 deletions src/server/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,16 +165,13 @@ program
.addOption(passwordOption)
.action((url, { verbose, username, password }) => {
const auth = parseCredentials(username, password, "http-basic");
const { appSettings, serverSettings, sources } = settingsForDruidConnection(url, { verbose }, auth);
printIntrospectedSettings(
serverSettings,
appSettings,
sources,
settingsForDruidConnection(url, { verbose }, auth),
verbose,
version
).catch((e: Error) => {
program.error("There was an error generating a config: " + e.message);
});
program.error("There was an error generating a config: " + e.message);
});
});

program.showHelpAfterError();
Expand Down
35 changes: 15 additions & 20 deletions src/server/cli/introspect-cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,40 +14,35 @@
* limitations under the License.
*/

import { LOGGER } from "../../common/logger/logger";
import { AppSettings } from "../../common/models/app-settings/app-settings";
import { Sources } from "../../common/models/sources/sources";
import { NULL_LOGGER } from "../../common/logger/logger";
import { appSettingsToYaml, printExtra, sourcesToYaml } from "../../common/utils/yaml-helper/yaml-helper";
import { ServerSettings } from "../models/server-settings/server-settings";
import { SettingsManager } from "../utils/settings-manager/settings-manager";
import { TurniloSettings } from "./run-turnilo";

export default function printIntrospectedSettings(
serverSettings: ServerSettings,
appSettings: AppSettings,
sources: Sources,
verbose: boolean,
{ serverSettings, sources, appSettings }: TurniloSettings,
withComments: boolean,
version: string
) {
const settingsManager = new SettingsManager(appSettings, sources, {
anchorPath: process.cwd(),
initialLoadTimeout: serverSettings.pageMustLoadTimeout,
verbose,
logger: LOGGER
logger: NULL_LOGGER
});

return settingsManager.getFreshSources({
timeout: 10000
}).then(sources => {
const extra = {
header: true,
version,
verbose
};
const config = [
printExtra(extra, verbose),
appSettingsToYaml(appSettings, verbose),
sourcesToYaml(sources, verbose)
].join("\n");
process.stdout.write(config);
printExtra({
header: true,
version
}, withComments),
appSettingsToYaml(appSettings, withComments),
sourcesToYaml(sources, withComments)
];

process.stdout.write(config.join("\n"));
process.exit();
});
}