def main( configfile, dry_run, log_level, gitlab_project_id, reports_path, thread_pool_size ): config.init_from_toml(configfile) init_log_level(log_level) config.init_from_toml(configfile) gql.init_from_config() now = datetime.now() apps = get_apps_data(now, thread_pool_size=thread_pool_size) reports = [Report(app, now).to_message() for app in apps] for report in reports: logging.info(["create_report", report["file_path"]]) if reports_path: report_file = os.path.join(reports_path, report["file_path"]) try: os.makedirs(os.path.dirname(report_file)) except FileExistsError: pass with open(report_file, "w") as f: f.write(report["content"]) if not dry_run: email_body = """\ Hello, A new report by the App SRE team is now available at: https://visual-app-interface.devshift.net/reports You can use the Search bar to search by App. You can also view reports per service here: https://visual-app-interface.devshift.net/services Having problems? Ping us on #sd-app-sre on Slack! You are receiving this message because you are a member of app-interface or subscribed to a mailing list specified as owning a service being run by the App SRE team: https://gitlab.cee.redhat.com/service/app-interface """ mr_cli = mr_client_gateway.init( gitlab_project_id=gitlab_project_id, sqs_or_gitlab="gitlab" ) mr = CreateAppInterfaceReporter( reports=reports, email_body=textwrap.dedent(email_body), reports_path=reports_path, ) result = mr.submit(cli=mr_cli) logging.info(["created_mr", result.web_url])
def main(configfile, dry_run, log_level, gitlab_project_id, reports_path): config.init_from_toml(configfile) init_log_level(log_level) config.init_from_toml(configfile) gql.init_from_config() now = datetime.now() apps = get_apps_data(now) reports = [Report(app, now).to_message() for app in apps] for report in reports: logging.info(['create_report', report['file_path']]) if reports_path: report_file = os.path.join(reports_path, report['file_path']) try: os.makedirs(os.path.dirname(report_file)) except FileExistsError: pass with open(report_file, 'w') as f: f.write(report['content']) if not dry_run: email_schema = '/app-interface/app-interface-email-1.yml' email_body = """\ Hello, A new report by the App SRE team is now available at: https://visual-app-interface.devshift.net/reports You can use the Search bar to search by App. You can also view reports per service here: https://visual-app-interface.devshift.net/services Having problems? Ping us on #sd-app-sre on Slack! You are receiving this message because you are a member of app-interface or subscribed to a mailing list specified as owning a service being run by the App SRE team: https://gitlab.cee.redhat.com/service/app-interface """ gw = prg.init(gitlab_project_id=gitlab_project_id, override_pr_gateway_type='gitlab') mr = gw.create_app_interface_reporter_mr(reports, email_schema, textwrap.dedent(email_body), reports_path) logging.info(['created_mr', mr.web_url])