Allow using PULSE_URL to define push_sources and task_sources

Defining PULSE_TASK_SOURCES and PULSE_PUSH_SOURCES is a bit of a nightmare
because `app.json` is a Json file and using double and single quotes for a
value in the file is impossible.
This commit is contained in:
Armen Zambrano G 2019-10-25 11:28:48 -04:00
Родитель 79a6bba8d1
Коммит 37c96d328d
5 изменённых файлов: 18 добавлений и 5 удалений

Просмотреть файл

@ -32,6 +32,7 @@
"HEROKU_APP_NAME": {
"required": true
},
"PULSE_URL": "amqp://treeherder-shared-pulse-user:mozilla123@pulse.mozilla.org:5671/?ssl=true",
"TREEHERDER_DJANGO_SECRET_KEY": {
"generator": "secret"
},

Просмотреть файл

@ -20,8 +20,6 @@ services:
- TREEHERDER_DEBUG=True
- TREEHERDER_DJANGO_SECRET_KEY=secret-key-of-at-least-50-characters-to-pass-check-deploy
- NEW_RELIC_DEVELOPER_MODE=True
- PULSE_TASK_SOURCES=${PULSE_TASK_SOURCES}
- PULSE_PUSH_SOURCES=${PULSE_PUSH_SOURCES}
entrypoint: './docker/entrypoint.sh'
command: './manage.py runserver 0.0.0.0:8000'
# Django's runserver doesn't listen to the default of SIGTERM, so docker-compose

Просмотреть файл

@ -31,9 +31,13 @@ would be:
You will need the root URL for the Taskcluster deployment, such as `https://firefox-ci-tc.services.mozilla.com`.
On your localhost set PULSE_PUSH_SOURCES as follows, subsituting the appropriate URLs:
NOTE: If you use PULSE_URL you will not need to configure the other env variables.
On your localhost set PULSE_URL or PULSE_PUSH_SOURCES as follows, subsituting the appropriate URLs:
```bash
export PULSE_URL=<pulse url>
# OR
export PULSE_PUSH_SOURCES='[{"root_url": "<root url>", "github": true, "hgmo": true, "pulse_url": "<pulse url>"}]'
```
@ -43,6 +47,8 @@ Next, run the Treeherder management command to read Pushes from the default **Pu
exchange:
```bash
docker-compose run -e PULSE_URL backend ./manage.py pulse_listener_pushes
# OR
docker-compose run -e PULSE_PUSH_SOURCES backend ./manage.py pulse_listener_pushes
```
@ -56,12 +62,16 @@ ingested in step 5.
As in step 3, open a new terminal and this time create `PULSE_TASK_SOURCES`:
```bash
export PULSE_URL=<pulse url>
# OR
export PULSE_TASK_SOURCES='[{"root_url": "<root url>", "pulse_url": "<pulse url>"}]'
```
Then run the management command for listing to jobs:
```bash
docker-compose run -e PULSE_URL backend ./manage.py pulse_listener_pushes
# OR
docker-compose run -e PULSE_TASK_SOURCES backend ./manage.py pulse_listener_tasks
```

Просмотреть файл

@ -21,7 +21,9 @@ class Command(BaseCommand):
# information. Sources can include properties `hgmo`, `github`, or both, to
# listen to events from those sources. The value is a JSON array of the form
# [{pulse_url: .., hgmo: true, root_url: ..}, ..]
push_sources = env.json('PULSE_PUSH_SOURCES', default=[])
push_sources = env.json(
"PULSE_PUSH_SOURCES",
default=[{"root_url": "https://taskcluster.net", "github": True, "hgmo": True, "pulse_url": env("PULSE_URL")}])
consumers = prepare_consumers(
PushConsumer,

Просмотреть файл

@ -20,7 +20,9 @@ class Command(BaseCommand):
# Specifies the Pulse services from which Treeherder will consume task
# information. This value is a JSON array of the form [{pulse_url: ..,
# root_url: ..}, ..]
task_sources = env.json("PULSE_TASK_SOURCES", default=[])
task_sources = env.json(
"PULSE_TASK_SOURCES",
default=[{"root_url": "https://taskcluster.net", "pulse_url": env("PULSE_URL")}])
consumers = prepare_consumers(
TaskConsumer,