apiVersion: v1
kind: ConfigMap
metadata:
  name: "fedora-messaging-configmap"
  labels:
    app: resultsdb-ci-listener
data:
  config.toml: |-
    # A sample configuration for fedora-messaging. This file is in the TOML format.
    # For complete details on all configuration options, see the documentation
    # https://fedora-messaging.readthedocs.io/en/latest/configuration.html.

    amqp_url = "amqps://resultsdb{{ env_suffix }}_ci_listener:@rabbitmq{{ env_suffix }}.fedoraproject.org/%2Fpubsub"

{% if env == "staging" %}
    topic_prefix = "org.fedoraproject.stg"
{% else %}
    topic_prefix = "org.fedoraproject.prod"
{% endif %}

    publish_exchange = "amq.topic"
    passive_declares = true

    callback = "resultsdb_listener.consumer:Consumer"


    [queues."resultsdb{{ env_suffix }}_ci_listener"]
    durable = true
    auto_delete = false
    exclusive = true
    arguments = {}

    # Note the double brackets below.
    # To add another binding, add another [[bindings]] section.
    [[bindings]]
    queue = "resultsdb{{ env_suffix }}_ci_listener"
    exchange = "amq.topic"
    routing_keys = [
{% if  env == "staging" %}
        'org.centos.stage.ci.pipeline.allpackages-build.complete',
        'org.centos.stage.ci.pipeline.allpackages-build.image.complete',
        'org.centos.stage.ci.pipeline.allpackages-build.package.test.functional.complete',
        'org.centos.stage.ci.pipeline.allpackages-build.package.complete',
        'org.centos.stage.ci.pipeline.allpackages-build.package.ignored',
        'org.centos.stage.ci.koji-build.test.queued',
        'org.centos.stage.ci.koji-build.test.running',
        'org.centos.stage.ci.koji-build.test.complete',
        'org.centos.stage.ci.koji-build.test.error'
{% else %}
        'org.centos.prod.ci.pipeline.allpackages-build.complete',
        'org.centos.prod.ci.pipeline.allpackages-build.image.complete',
        'org.centos.prod.ci.pipeline.allpackages-build.package.test.functional.complete',
        'org.centos.prod.ci.pipeline.allpackages-build.package.complete',
        'org.centos.prod.ci.pipeline.allpackages-build.package.ignored',
        'org.centos.prod.ci.koji-build.test.queued',
        'org.centos.prod.ci.koji-build.test.running',
        'org.centos.prod.ci.koji-build.test.complete',
        'org.centos.prod.ci.koji-build.test.error'
{%- endif %}
    ]

    [tls]
    ca_cert = "/etc/pki/rabbitmq/ca/resultsdb-ci-listener.ca"
    keyfile = "/etc/pki/rabbitmq/key/resultsdb-ci-listener.key"
    certfile = "/etc/pki/rabbitmq/crt/resultsdb-ci-listener.crt"

    [client_properties]
    app = "resultsdb_listener"
    # Some suggested extra fields:
    # URL of the project that provides this consumer
    app_url = "https://pagure.io/ci-resultsdb-listener/"
    # Contact emails for the maintainer(s) of the consumer - in case the
    # broker admin needs to contact them, for e.g.
    app_contacts_email = [
      "pingou@fedoraproject.org",
      "lrossett@fedoraproject.org"
    ]

    [qos]
    prefetch_size = 0
    prefetch_count = 25

    [log_config]
    version = 1
    disable_existing_loggers = true

    [log_config.formatters.simple]
    format = "[%(name)s %(levelname)s] %(message)s"

    [log_config.handlers.console]
    class = "logging.StreamHandler"
    formatter = "simple"
    stream = "ext://sys.stdout"

    [log_config.loggers.fedora_messaging]
    level = "INFO"
    propagate = false
    handlers = ["console"]

    [log_config.loggers.resultsdb_listener]
    level = "DEBUG"
    propagate = false
    handlers = ["console"]

    [log_config.root]
    level = "WARNING"
    handlers = ["console"]
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: "resultsdb-ci-listener-cfg"
  labels:
    app: resultsdb-ci-listener
data:
  listener.cfg: |-
    [general]
{% if env == "staging" %}
    datagrepper_url = https://apps.stg.fedoraproject.org/datagrepper/raw
{% else %}
    datagrepper_url = https://apps.fedoraproject.org/datagrepper/raw
{% endif %}

    [sender]
    sender_type = ResultsdbSender
    resultsdb_url = http://resultsdb-api.resultsdb.svc.cluster.local:5001/api/v2.0
