Skip to content

Commit

Permalink
Templatize event time in metadata.json (#2946)
Browse files Browse the repository at this point in the history
* Templatize event time in `metadata.json`

Signed-off-by: Willy Lulciuc <[email protected]>

* Use `metadata.template.json`

Signed-off-by: Willy Lulciuc <[email protected]>

---------

Signed-off-by: Willy Lulciuc <[email protected]>
  • Loading branch information
wslulciuc authored Oct 24, 2024
1 parent f444458 commit f7a9643
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 27 deletions.
2 changes: 1 addition & 1 deletion docker-compose.seed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ services:
volumes:
- ./docker/wait-for-it.sh:/usr/src/app/wait-for-it.sh
- ./docker/seed.sh:/usr/src/app/seed.sh
- ./docker/metadata.json:/usr/src/app/metadata.json
- ./docker/metadata.template.json:/usr/src/app/metadata.template.json
links:
- "db:postgres"
depends_on:
Expand Down
52 changes: 26 additions & 26 deletions docker/metadata.json → docker/metadata.template.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[
{
"eventType": "START",
"eventTime": "2020-02-22T22:42:42.000Z",
"eventTime": "{{RUN_START_TIME}}",
"run": {
"runId": "4d3b8069-69b6-4708-ade0-3275112c9f04",
"facets": {
Expand Down Expand Up @@ -82,7 +82,7 @@
},
{
"eventType": "COMPLETE",
"eventTime": "2020-02-22T22:45:52.000Z",
"eventTime": "{{RUN_END_TIME_AFTER_8_MINUTES}}",
"run": {
"runId": "4d3b8069-69b6-4708-ade0-3275112c9f04"
},
Expand All @@ -94,7 +94,7 @@
},
{
"eventType": "START",
"eventTime": "2020-02-22T22:42:42.000Z",
"eventTime": "{{RUN_START_TIME}}",
"run": {
"runId": "6f0c13a5-f29b-46a5-90c1-0ffbebbbd1aa",
"facets": {
Expand Down Expand Up @@ -171,7 +171,7 @@
},
{
"eventType": "COMPLETE",
"eventTime": "2020-02-22T22:44:52.000Z",
"eventTime": "{{RUN_END_TIME_AFTER_9_MINUTES}}",
"run": {
"runId": "6f0c13a5-f29b-46a5-90c1-0ffbebbbd1aa"
},
Expand All @@ -183,7 +183,7 @@
},
{
"eventType": "START",
"eventTime": "2020-02-22T22:42:42.000Z",
"eventTime": "{{RUN_START_TIME}}",
"run": {
"runId": "e05901b1-3a06-4b98-8d9c-aaf188c9a28c",
"facets": {
Expand Down Expand Up @@ -265,7 +265,7 @@
},
{
"eventType": "COMPLETE",
"eventTime": "2020-02-22T22:44:54.000Z",
"eventTime": "{{RUN_END_TIME_AFTER_8_MINUTES}}",
"run": {
"runId": "e05901b1-3a06-4b98-8d9c-aaf188c9a28c"
},
Expand All @@ -277,7 +277,7 @@
},
{
"eventType": "START",
"eventTime": "2020-02-22T22:42:42.000Z",
"eventTime": "{{RUN_START_TIME}}",
"run": {
"runId": "a43a8523-349f-4296-807f-3354ac491990",
"facets": {
Expand Down Expand Up @@ -364,7 +364,7 @@
},
{
"eventType": "COMPLETE",
"eventTime": "2020-02-22T22:44:52.000Z",
"eventTime": "{{RUN_END_TIME_AFTER_5_MINUTES}}",
"run": {
"runId": "a43a8523-349f-4296-807f-3354ac491990"
},
Expand All @@ -376,7 +376,7 @@
},
{
"eventType": "START",
"eventTime": "2020-02-22T22:42:42.000Z",
"eventTime": "{{RUN_START_TIME}}",
"run": {
"runId": "ffba2c14-4170-48da-bec3-ab5fd4ec9a3f",
"facets": {
Expand Down Expand Up @@ -570,7 +570,7 @@
},
{
"eventType": "COMPLETE",
"eventTime": "2020-02-22T22:44:02.000Z",
"eventTime": "{{RUN_END_TIME_AFTER_7_MINUTES}}",
"run": {
"runId": "ffba2c14-4170-48da-bec3-ab5fd4ec9a3f"
},
Expand All @@ -582,7 +582,7 @@
},
{
"eventType": "START",
"eventTime": "2020-02-22T22:42:42.000Z",
"eventTime": "{{RUN_START_TIME}}",
"run": {
"runId": "182a9eaf-881a-4d49-860c-f7e260b8bf60",
"facets": {
Expand Down Expand Up @@ -679,7 +679,7 @@
},
{
"eventType": "COMPLETE",
"eventTime": "2020-02-22T22:44:55.000Z",
"eventTime": "{{RUN_END_TIME_AFTER_10_MINUTES}}",
"run": {
"runId": "182a9eaf-881a-4d49-860c-f7e260b8bf60"
},
Expand All @@ -691,7 +691,7 @@
},
{
"eventType": "START",
"eventTime": "2020-02-22T22:42:42.000Z",
"eventTime": "{{RUN_START_TIME}}",
"run": {
"runId": "b7098939-87f0-4207-878f-dfd8e8804d8a",
"facets": {
Expand Down Expand Up @@ -788,7 +788,7 @@
},
{
"eventType": "COMPLETE",
"eventTime": "2020-02-22T22:44:52.000Z",
"eventTime": "{{RUN_END_TIME_AFTER_7_MINUTES}}",
"run": {
"runId": "b7098939-87f0-4207-878f-dfd8e8804d8a"
},
Expand All @@ -800,7 +800,7 @@
},
{
"eventType": "START",
"eventTime": "2020-02-22T22:42:42.000Z",
"eventTime": "{{RUN_START_TIME}}",
"run": {
"runId": "9f3db1c5-5e9a-4280-8184-18aca4592c77",
"facets": {
Expand Down Expand Up @@ -923,7 +923,7 @@
},
{
"eventType": "COMPLETE",
"eventTime": "2020-02-22T22:44:52.000Z",
"eventTime": "{{RUN_END_TIME_AFTER_5_MINUTES}}",
"run": {
"runId": "9f3db1c5-5e9a-4280-8184-18aca4592c77"
},
Expand All @@ -935,7 +935,7 @@
},
{
"eventType": "START",
"eventTime": "2020-02-22T22:42:42.000Z",
"eventTime": "{{RUN_START_TIME}}",
"run": {
"runId": "8ddfb1d9-415f-4850-bcd6-01d02f011abe",
"facets": {
Expand Down Expand Up @@ -1052,7 +1052,7 @@
},
{
"eventType": "COMPLETE",
"eventTime": "2020-02-22T22:44:56.000Z",
"eventTime": "{{RUN_END_TIME_AFTER_10_MINUTES}}",
"run": {
"runId": "8ddfb1d9-415f-4850-bcd6-01d02f011abe"
},
Expand All @@ -1064,7 +1064,7 @@
},
{
"eventType": "START",
"eventTime": "2020-02-22T22:42:42.000Z",
"eventTime": "{{RUN_START_TIME}}",
"run": {
"runId": "d5a2a4c4-fc78-428d-ae85-08c942ed8371",
"facets": {
Expand Down Expand Up @@ -1382,7 +1382,7 @@
},
{
"eventType": "COMPLETE",
"eventTime": "2020-02-22T22:48:12.000Z",
"eventTime": "{{RUN_END_TIME_AFTER_6_MINUTES}}",
"run": {
"runId": "d5a2a4c4-fc78-428d-ae85-08c942ed8371"
},
Expand All @@ -1394,7 +1394,7 @@
},
{
"eventType": "START",
"eventTime": "2020-02-22T22:42:42.000Z",
"eventTime": "{{RUN_START_TIME}}",
"run": {
"runId": "bd41a42a-bf18-4b74-9bb7-cd62637823d8",
"facets": {
Expand Down Expand Up @@ -1655,7 +1655,7 @@
},
{
"eventType": "COMPLETE",
"eventTime": "2020-02-22T22:58:02.000Z",
"eventTime": "{{RUN_END_TIME_AFTER_6_MINUTES}}",
"run": {
"runId": "bd41a42a-bf18-4b74-9bb7-cd62637823d8"
},
Expand All @@ -1667,7 +1667,7 @@
},
{
"eventType": "START",
"eventTime": "2020-02-22T22:42:42.000Z",
"eventTime": "{{RUN_START_TIME}}",
"run": {
"runId": "adc8507c-595e-4d76-9dac-be2bf0ffe1ee",
"facets": {
Expand Down Expand Up @@ -1776,7 +1776,7 @@
},
{
"eventType": "COMPLETE",
"eventTime": "2020-02-22T22:46:12.000Z",
"eventTime": "{{RUN_END_TIME_AFTER_5_MINUTES}}",
"run": {
"runId": "adc8507c-595e-4d76-9dac-be2bf0ffe1ee"
},
Expand All @@ -1788,7 +1788,7 @@
},
{
"eventType": "START",
"eventTime": "2020-02-22T22:42:42.000Z",
"eventTime": "{{RUN_START_TIME}}",
"run": {
"runId": "3ab25429-cf9c-4d1d-9166-1e1946f9d3c3",
"facets": {
Expand Down Expand Up @@ -1830,7 +1830,7 @@
},
{
"eventType": "COMPLETE",
"eventTime": "2020-02-22T22:56:01.000Z",
"eventTime": "{{RUN_END_TIME_AFTER_6_MINUTES}}",
"run": {
"runId": "3ab25429-cf9c-4d1d-9166-1e1946f9d3c3"
},
Expand Down
20 changes: 20 additions & 0 deletions docker/seed.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,24 @@

set -e

# As ISO-8601 format
NOW=$(date -u +"%Y-%m-%dT%H:%M:%S.000Z")

RUN_END_TIME_AFTER_5_MINUTES=$(date -u -d "5 minutes" +"%Y-%m-%dT%H:%M:%S.000Z")
RUN_END_TIME_AFTER_6_MINUTES=$(date -u -d "6 minutes" +"%Y-%m-%dT%H:%M:%S.000Z")
RUN_END_TIME_AFTER_7_MINUTES=$(date -u -d "7 minutes" +"%Y-%m-%dT%H:%M:%S.000Z")
RUN_END_TIME_AFTER_8_MINUTES=$(date -u -d "8 minutes" +"%Y-%m-%dT%H:%M:%S.000Z")
RUN_END_TIME_AFTER_9_MINUTES=$(date -u -d "9 minutes" +"%Y-%m-%dT%H:%M:%S.000Z")
RUN_END_TIME_AFTER_10_MINUTES=$(date -u -d "10 minutes" +"%Y-%m-%dT%H:%M:%S.000Z")

# Replace '{{RUN_START_TIME}}' and '{{RUN_END_TIME_AFTER_*_MINUTES}}'.
sed -e "s/{{RUN_START_TIME}}/$NOW/" \
-e "s/{{RUN_END_TIME_AFTER_5_MINUTES}}/$RUN_END_TIME_AFTER_5_MINUTES/" \
-e "s/{{RUN_END_TIME_AFTER_6_MINUTES}}/$RUN_END_TIME_AFTER_6_MINUTES/" \
-e "s/{{RUN_END_TIME_AFTER_7_MINUTES}}/$RUN_END_TIME_AFTER_7_MINUTES/" \
-e "s/{{RUN_END_TIME_AFTER_8_MINUTES}}/$RUN_END_TIME_AFTER_8_MINUTES/" \
-e "s/{{RUN_END_TIME_AFTER_9_MINUTES}}/$RUN_END_TIME_AFTER_9_MINUTES/" \
-e "s/{{RUN_END_TIME_AFTER_10_MINUTES}}/$RUN_END_TIME_AFTER_10_MINUTES/" \
metadata.template.json > metadata.json

java -jar marquez-api-*.jar seed --url "${MARQUEZ_URL:-http://localhost:5000}" --metadata metadata.json

0 comments on commit f7a9643

Please sign in to comment.