def generate_app_ci_content(config, git_clone_dir):
    for private in (False, True):
        for arch in config.arches:
            context = Context(config, arch, private)

            with genlib.GenDoc(
                    config.paths.path_rc_deployments.joinpath(
                        f'admin_deploy-{context.is_namespace}-controller.yaml'
                    ), context) as gendoc:
                content.add_imagestream_namespace_rbac(gendoc)

            with genlib.GenDoc(
                    config.paths.path_rc_deployments.joinpath(
                        f'deploy-{context.is_namespace}-controller.yaml'),
                    context) as gendoc:
                content.add_osd_rc_deployments(gendoc)
                content.add_osd_files_cache_service_account_resources(gendoc)
                content.add_osd_files_cache_resources(gendoc)

    with genlib.GenDoc(
            config.paths.path_rc_deployments.joinpath('serviceaccount.yaml'),
            context=config) as gendoc:
        content.add_osd_rc_service_account_resources(gendoc)

    with genlib.GenDoc(config.paths.path_rc_deployments.joinpath(
            'admin_deploy-ocp-publish-art.yaml'),
                       context=config) as gendoc:
        content.add_art_publish(gendoc)

    with genlib.GenDoc(
            config.paths.path_rc_rpms.joinpath('rpms-ocp-3.11.yaml'),
            context=config) as gendoc:
        content.add_rpm_mirror_service(gendoc, git_clone_dir, '3.11')

    for major_minor in config.releases:
        with genlib.GenDoc(config.paths.path_rc_rpms.joinpath(
                f'rpms-ocp-{major_minor}.yaml'),
                           context=config) as gendoc:
            content.add_rpm_mirror_service(gendoc, git_clone_dir, major_minor)

    # Generate the release-controller one-offs...
    context = Context(config, "x86_64", False)

    # Origin release-controller
    with genlib.GenDoc(
            config.paths.path_rc_deployments.joinpath(
                'admin_deploy-origin-controller.yaml'), context) as gendoc:
        content.generate_origin_admin_resources(gendoc)

    with genlib.GenDoc(
            config.paths.path_rc_deployments.joinpath(
                'deploy-origin-controller.yaml'), context) as gendoc:
        content.generate_origin_resources(gendoc)

    # Signer
    with genlib.GenDoc(
            config.paths.path_rc_deployments.joinpath('deploy-ci-signer.yaml'),
            context) as gendoc:
        content.generate_signer_resources(gendoc)
def generate_app_ci_content(config, git_clone_dir):
    for private in (False, True):
        for arch in config.arches:
            context = Context(config, arch, private)

            with genlib.GenDoc(
                    config.paths.path_rc_deployments.joinpath(
                        f'admin_deploy-{context.is_namespace}-controller.yaml'
                    ), context) as gendoc:
                content.add_imagestream_namespace_rbac(gendoc)

            with genlib.GenDoc(
                    config.paths.path_rc_deployments.joinpath(
                        f'deploy-{context.is_namespace}-controller.yaml'),
                    context) as gendoc:
                content.add_osd_rc_deployments(gendoc)
                content.add_osd_files_cache_service_account_resources(gendoc)
                content.add_osd_files_cache_resources(gendoc)

    with genlib.GenDoc(
            config.paths.path_rc_deployments.joinpath('serviceaccount.yaml'),
            context=config) as gendoc:
        content.add_osd_rc_service_account_resources(gendoc)

    with genlib.GenDoc(config.paths.path_rc_deployments.joinpath(
            'admin_deploy-ocp-publish-art.yaml'),
                       context=config) as gendoc:
        content.add_art_publish(gendoc)

    with genlib.GenDoc(
            config.paths.path_rc_rpms.joinpath('rpms-ocp-3.11.yaml'),
            context=config) as gendoc:
        content.add_rpm_mirror_service(gendoc, git_clone_dir, '3.11')

    for major_minor in config.releases:
        with genlib.GenDoc(config.paths.path_rc_rpms.joinpath(
                f'rpms-ocp-{major_minor}.yaml'),
                           context=config) as gendoc:
            content.add_rpm_mirror_service(gendoc, git_clone_dir, major_minor)

    # If there is an annotation defined for the public release controller, use it as a template
    # for the private annotations.
    for annotation_path in config.paths.path_rc_annotations.glob(
            'release-ocp-*.json'):
        if annotation_path.name.endswith(
                'ci.json'
        ):  # There are no CI annotations for the private controllers
            continue
        if '-stable' in annotation_path.name:  # There are no stable streams in private release controllers
            continue
        annotation_filename = os.path.basename(annotation_path)
        with open(annotation_path, mode='r', encoding='utf-8') as f:
            pub_annotation = json.load(f)
        print(str(annotation_path))
        priv_annotation = dict(pub_annotation)
        priv_annotation['name'] += '-priv'
        priv_annotation['mirrorPrefix'] += '-priv'
        # The "multi" release-controller purposefully does not use the "to" annotation:
        if 'to' in pub_annotation:
            priv_annotation['to'] += '-priv'
        priv_annotation.pop(
            'check', None)  # Don't worry about the state of other releases
        priv_annotation.pop('publish',
                            None)  # Don't publish these images anywhere
        priv_annotation.pop('periodic', None)  # Don't configure periodics
        priv_annotation[
            'message'] = "<!-- GENERATED FROM PUBLIC ANNOTATION CONFIG - DO NOT EDIT. -->" + priv_annotation[
                'message']
        for _, test_config in priv_annotation['verify'].items():
            test_config['prowJob']['name'] += '-priv'
            # TODO: Private jobs are disabled until the -priv variants can be generated by prowgen
            test_config['disabled'] = True

        with config.paths.path_priv_rc_annotations.joinpath(
                annotation_filename).open(mode='w+', encoding='utf-8') as f:
            json.dump(priv_annotation, f, sort_keys=True, indent=4)

    # Generate the release-controller one-offs...
    context = Context(config, "x86_64", False)

    # Origin release-controller
    with genlib.GenDoc(
            config.paths.path_rc_deployments.joinpath(
                'admin_deploy-origin-controller.yaml'), context) as gendoc:
        content.generate_origin_admin_resources(gendoc)

    with genlib.GenDoc(
            config.paths.path_rc_deployments.joinpath(
                'deploy-origin-controller.yaml'), context) as gendoc:
        content.generate_origin_resources(gendoc)

    # Signer
    with genlib.GenDoc(
            config.paths.path_rc_deployments.joinpath('deploy-ci-signer.yaml'),
            context) as gendoc:
        content.generate_signer_resources(gendoc)

    # Development RBAC
    generate_development_rbac(config)