# vim: ft=proto
instance_name: '{{ janitor_instance_name }}'
apt_location: '{{ janitor_apt_path }}'
logs_location: '{{ janitor_logs_path }}'
vcs_location: '{{ janitor_vcs_path }}'
artifact_location: '{{ janitor_artifact_path }}'
database_location: 'postgresql://{{ janitor_db_user }}@{{ janitor_db_host }}:{{ janitor_db_port }}/{{ janitor_db_name }}'
committer: "{{ janitor_committer }}"
{% if janitor_archive_origin %}
origin: "{{ janitor_archive_origin }}"
{% endif %}

{% for distro in janitor_distributions %}
distribution {
  name: "{{ distro['name'] }}"
{% if 'vendor' in distro %}  vendor: "{{ distro['vendor'] }}"
{% endif %}
  archive_mirror_uri: "{{ distro['mirror_uri'] }}"
{% if 'tracker_url' in distro %}  tracker_url: "{{ distro['tracker_url'] }}"
{% endif %}
{% for component in distro['components'] %}  component: "{{ component }}"
{% endfor %}
{% if 'chroot' in distro %}  chroot: "{{ distro['chroot'] }}"
{% endif %}
{% if 'lintian_profile' in distro %}  lintian_profile: "{{ distro['lintian_profile'] }}"
{% endif %}
{% for tag in distro.get('lintian_suppress_tags', []) %}  lintian_suppress_tag: "{{ tag }}"
{% endfor %}
{% if 'build_command' in distro %}  build_command: "{{ distro['build_command'] }}"
{% endif %}
}
{% endfor %}

{% for campaign in janitor_campaigns %}
campaign {
  name: "{{ campaign['name'] }}"
  branch_name: "{{ campaign.get('branch_name') or campaign['name'] }}"
{% if 'merge_proposal' in campaign %}
  merge_proposal {
    {% if 'value_threshold' in campaign['merge_proposal'] %}value_threshold: {{ campaign['merge_proposal']['value_threshold'] }}{% endif %}
    {% if 'commit_message' in campaign['merge_proposal'] %}commit_message: "{{ campaign['merge_proposal']['commit_message'] }}"{% endif %}
    {% if 'title' in campaign['merge_proposal'] %}title: "{{ campaign['merge_proposal']['title'] }}"{% endif %}
    {% for label in campaign['merge_proposal'].get('label', []) %}label: "{{ label }}"
    {% endfor %}
  }
{% endif %}
{% if 'generic_chroot' in campaign %}
  generic_build {
    chroot: "{{ campaign['generic_chroot'] }}"
  }
{% else %}
  debian_build {
    archive_description: "{{ campaign['archive_description'] }}"
    base_distribution: "{{ campaign['base_distribution'] }}"
{% if 'build_distribution' in campaign %}    build_distribution: "{{ campaign['build_distribution'] }}"
{% endif %}
{% if 'build_suffix' in campaign %}    build_suffix: "{{ campaign['build_suffix'] }}"
{% endif %}
{% if 'build_command' in campaign %}     build_command: "{{ campaign['build_command'] }}"
{% endif %}
{% for extra_distribution in campaign.get('extra_build_distributions', []) %}    extra_build_distribution: "{{ extra_distribution }}"
{% endfor %}
  }
{% endif %}
{% if campaign.get('force_build', False) %}  force_build: true
{% endif %}
}
{% endfor %}

{% if janitor_openid %}
oauth2_provider {
  client_id: "{{ janitor_openid.client_id }}"
  client_secret: "{{ janitor_openid.client_secret }}"
  base_url: "{{ janitor_openid.base_url }}"
{% if janitor_openid.qa_reviewer_group %}
  qa_reviewer_group: "{{ janitor_openid.qa_reviewer_group }}"
{% endif %}
{% if janitor_openid.admin_group %}
  admin_group: "{{ janitor_openid.admin_group }}"
{% endif %}
}
{% endif %}
