in src/com/epam/digital/data/platform/pipelines/stages/impl/dataplatform/RestoreRedashAdminState.groovy [30:74]
void run() {
if (context.registryRegulations.deployStatus("restore-redash-admin-state",
"${RegulationType.REPORTS.value}")) {
context.script.retry(5) {
def response = context.script.httpRequest url: "${context.redash.adminUrl}/api/query_snippets",
httpMode: "GET",
contentType: "APPLICATION_JSON",
customHeaders: [[name: "Authorization", value: context.redash.adminApiKey, maskValue: true]],
consoleLogResponseBody: context.logLevel == "DEBUG",
quiet: context.logLevel != "DEBUG",
validResponseCodes: "200"
context.logger.debug("Redash admin response: ${response.content}")
if (response.content == "[]") {
try {
context.logger.info("Redash-admin is empty. Start restoring...")
context.script.sh(script: "set +x; java -jar " +
"-DREDASH_URL=${context.redash.adminUrl} " +
"-DREDASH_API_KEY=${context.redash.adminApiKey} " +
"-DPOSTGRES_PASSWORD=\'${context.postgres.analytical_pg_password}\' " +
"-DPOSTGRES_USER=${context.postgres.analytical_pg_user} " +
"-DDB_NAME=${context.registry.name} " +
"-DDB_URL=${context.postgres.ANALYTICAL_MASTER_URL} " +
"-DDB_PORT=${context.postgres.OPERATIONAL_MASTER_PORT} " +
"-DPWD_ADMIN=${context.postgres.analyticsAdminRolePass} " +
"-DPWD_AUDITOR=${context.postgres.auditRolePass} " +
"${REDASH_PUBLISHER_JAR} " +
"--reports " +
"${context.logLevel == "DEBUG" ? "1>&2" : ""}")
context.logger.info("Redash-admin has been successfully restored!")
}
catch (any) {
context.script.error("Error during restoring Redash-admin(")
}
context.logger.info("Redash-admin restoring have been finished.")
} else {
context.logger.info("Redash-admin is not empty. Skipping restoring.")
}
}
context.registryRegulations.getChangedStatusOrFiles("save", "restore-redash-admin-state",
"--file ${context.getWorkDir()}/${RegulationType.REPORTS.value}")
} else {
context.logger.info("Skip restore-redash-admin-state due to no changes")
}
}