Beispiel #1
0
    def __make_project_report(
        templates: dict, cluster: Cluster, project: Project
    ) -> str:
        # Templates
        reports_template: dict = templates['reports']
        report_template: str = reports_template['project']

        report: str = report_template
        report = MarkdownMediator.__keys_replace(
            report,
            **{
                'project_name': project.get_name(),
                'cluster_name_lower': cluster.get_name().lower(),
                'project_id': project.get_id(),
                'workloads': MarkdownMediator.
                __make_workloads_table(templates, project)
            }
        )
        return report
Beispiel #2
0
    def __make_workloads_table(
        templates: dict, project: Project
    ) -> str:
        # Templates
        tables_template: dict = templates['tables']
        header_template: str = tables_template['workloads']['header']
        entry_template: str = tables_template['workloads']['entry']
        footer_template: str = tables_template['workloads']['footer']

        # Base URl from Rancher domain
        base_url: str = app_config['rancher']['base_url']

        table_header: str = header_template
        table: str = table_header
        table += "\n"

        table_entries: list = []

        workloads: list = project.get_workloads()
        for i in range(len(workloads)):
            workload: Workload = workloads[i]

            table_entry: str = entry_template
            table_entry = MarkdownMediator.__keys_replace(
                table_entry,
                **{
                    'base_url': base_url,
                    'project_id': project.get_id(),
                    'workload_id': workload.get_id(),
                    'workload_namespace': workload.get_namespace(),
                    'workload_name': workload.get_name(),
                    'workload_version': workload.get_version()
                }
            )
            table_entries.append(table_entry)

        table += "\n".join(table_entries)
        table += "\n"

        table_footer: str = footer_template
        table += table_footer
        return table